aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2017-03-07 15:58:28 -0800
committerRobert Griesemer <gri@golang.org>2017-03-08 18:26:16 +0000
commit2123a6c64455f6e1cceeefa97e4a033c873e2631 (patch)
treee209bef4e03e3319cc7a49a298d546dcbcbb8dba /src
parent82e1732f14d6b50ba29dcc3f0eb71c80fa52c2d3 (diff)
downloadgo-2123a6c64455f6e1cceeefa97e4a033c873e2631.tar.xz
cmd/compile: fix recorded export data position info
The position information recorded now consists of the line- directive relative filename and line number. It would be relatively easy to also encode absolute position information as necessary (by serializing src.PosBase data). For example, given $GOROOT/src/tmp/x.go: package p const C0 = 0 //line c.go:10 const C1 = 1 //line t.go:20 type T int //line v.go:30 var V T //line f.go:40 func F() {} The recorded positions for the exported entities are: C0 $GOROOT/src/tmp/x.go 3 C1 c.go 10 T t.go 20 V v.go 30 F f.go 40 Fix verified by manual inspection. There's currently no easy way to test this, but it will eventually be tested when we fix #7311. Fixes #19391. Change-Id: I6269067ea58358250fe6dd1f73bdf9e5d2adfe3d Reviewed-on: https://go-review.googlesource.com/37936 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/gc/bexport.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/gc/bexport.go b/src/cmd/compile/internal/gc/bexport.go
index 5f71ca0b71..24e043cacb 100644
--- a/src/cmd/compile/internal/gc/bexport.go
+++ b/src/cmd/compile/internal/gc/bexport.go
@@ -568,8 +568,8 @@ func (p *exporter) pos(n *Node) {
func fileLine(n *Node) (file string, line int) {
if n != nil {
pos := Ctxt.PosTable.Pos(n.Pos)
- file = pos.AbsFilename()
- line = int(pos.Line())
+ file = pos.Base().AbsFilename()
+ line = int(pos.RelLine())
}
return
}