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/reader.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/cmd/compile/internal/noder/reader.go') diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go index 5481812b18..985453a1bb 100644 --- a/src/cmd/compile/internal/noder/reader.go +++ b/src/cmd/compile/internal/noder/reader.go @@ -194,16 +194,15 @@ func (pr *pkgReader) posBaseIdx(idx int) *src.PosBase { r := pr.newReader(relocPosBase, idx, syncPosBase) var b *src.PosBase - fn := r.string() - absfn := r.string() + filename := r.string() if r.bool() { - b = src.NewFileBase(fn, absfn) + b = src.NewFileBase(filename, filename) } else { pos := r.pos0() line := r.uint() col := r.uint() - b = src.NewLinePragmaBase(pos, fn, absfn, line, col) + b = src.NewLinePragmaBase(pos, filename, filename, line, col) } pr.posBases[idx] = b -- cgit v1.2.3-54-g00ecf