diff options
author | Timothy Gu <timothygu99@gmail.com> | 2021-05-14 13:06:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-14 16:06:12 -0400 |
commit | 0582543d742132e9bd911473d88fb3db8ddbfa93 (patch) | |
tree | e5965eb4059dad42b9028fa458333eac7b46a1c6 /go/tools/builders/nogo_main.go | |
parent | 71042b949a84ae275660f45b8da9499a5877bb9c (diff) | |
download | bazelbuild-rules_go-0582543d742132e9bd911473d88fb3db8ddbfa93.tar.gz |
nogo: check adjusted filename for inclusion/exclusion (#2863)
Go files could include `//line` or `/*line` comments that indicate the
original location of the line. This functionality is used, among other
things, cgo's code rewrite step. This commit changes the
include/exclude_files logic to use the adjusted location in order to
better align with user expectations.
Fixes #2862
Diffstat (limited to 'go/tools/builders/nogo_main.go')
-rw-r--r-- | go/tools/builders/nogo_main.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/go/tools/builders/nogo_main.go b/go/tools/builders/nogo_main.go index c248282e..631cf0e5 100644 --- a/go/tools/builders/nogo_main.go +++ b/go/tools/builders/nogo_main.go @@ -394,10 +394,10 @@ func checkAnalysisResults(actions []*action, pkg *goPackage) string { for _, d := range act.diagnostics { // NOTE(golang.org/issue/31008): nilness does not set positions, // so don't assume the position is valid. - f := pkg.fset.File(d.Pos) + p := pkg.fset.Position(d.Pos) filename := "-" - if f != nil { - filename = f.Name() + if p.IsValid() { + filename = p.Filename } include := true if len(config.onlyFiles) > 0 { |