From ab9aaf46ee5585317b5c796d6fb7e31383385eeb Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Thu, 19 Aug 2021 15:52:53 -0700 Subject: cmd/compile/internal/syntax: add PosBase.Trimmed With types2, some syntax.PosBases need to be constructed from export data, which must only contain "trimmed" filenames (i.e., that they've already been made absolute and undergone -trimpath processing). However, it's not safe to apply trimming to a filename multiple times, and in general we can't distinguish trimmed from untrimmed filenames. This CL resolves this by adding a PosBase.Trimmed boolean so we can distinguish whether the associated filename has been trimmed yet. This is a bit hacky, but is the least bad solution I've come up with so far. This unblocks enabling -G=3 by default. Change-Id: I7383becfb704680a36f7603e3246af38b21f100b Reviewed-on: https://go-review.googlesource.com/c/go/+/343731 Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Trust: Matthew Dempsky Trust: Dan Scales Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/noder/reader2.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/cmd/compile/internal/noder/reader2.go') diff --git a/src/cmd/compile/internal/noder/reader2.go b/src/cmd/compile/internal/noder/reader2.go index 22c742ab25..64c1612f70 100644 --- a/src/cmd/compile/internal/noder/reader2.go +++ b/src/cmd/compile/internal/noder/reader2.go @@ -109,15 +109,14 @@ func (pr *pkgReader2) posBaseIdx(idx int) *syntax.PosBase { var b *syntax.PosBase filename := r.string() - _ = r.string() // absolute file name if r.bool() { - b = syntax.NewFileBase(filename) + b = syntax.NewTrimmedFileBase(filename, true) } else { pos := r.pos() line := r.uint() col := r.uint() - b = syntax.NewLineBase(pos, filename, line, col) + b = syntax.NewLineBase(pos, filename, true, line, col) } pr.posBases[idx] = b -- cgit v1.3-5-g9baa