diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2017-03-20 15:32:00 -0700 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2017-03-21 03:59:54 +0000 |
| commit | 49a533e212973d4403de640005fdcf88a23f91c4 (patch) | |
| tree | 92aaa5a450467ff8ac843514034b3e5e096d2a85 /src | |
| parent | 346d5883eb53d3e3a5bac7ee37beaa3db5c01fd8 (diff) | |
| download | go-49a533e212973d4403de640005fdcf88a23f91c4.tar.xz | |
cmd/compile: use autogenerated position for init functions
This eliminates an old TODO,
and stabilizes the position information
for init functions.
Change-Id: Idf2d9a16a60e097ee08f42541b87e170da2f9d3a
Reviewed-on: https://go-review.googlesource.com/38388
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/compile/internal/gc/init.go | 6 | ||||
| -rw-r--r-- | src/cmd/compile/internal/gc/noder.go | 13 |
2 files changed, 4 insertions, 15 deletions
diff --git a/src/cmd/compile/internal/gc/init.go b/src/cmd/compile/internal/gc/init.go index 500def7658..8355a735a9 100644 --- a/src/cmd/compile/internal/gc/init.go +++ b/src/cmd/compile/internal/gc/init.go @@ -4,6 +4,8 @@ package gc +import "cmd/internal/src" + // a function named init is a special case. // it is called by the initialization before // main is run. to make it unique within a @@ -75,9 +77,7 @@ func anyinit(n []*Node) bool { } func fninit(n []*Node) { - // This code is using the last value of lineno for position information - // (see comment in noder.go, noder.file method, for details). - + lineno = makePos(src.NewFileBase("<autogenerated>", "<autogenerated>"), 1, 0) nf := initfix(n) if !anyinit(nf) { return diff --git a/src/cmd/compile/internal/gc/noder.go b/src/cmd/compile/internal/gc/noder.go index ada3440622..a7f0ba54f0 100644 --- a/src/cmd/compile/internal/gc/noder.go +++ b/src/cmd/compile/internal/gc/noder.go @@ -101,18 +101,7 @@ func (p *noder) node() { } pragcgobuf += p.pragcgobuf - - // For compatibility with old code only (comparisons w/ toolstash): - // The old line number tracking simply continued incrementing the - // virtual line number (lexlineno) and using it also for lineno. - // After processing the last function, the lineno was used for the - // line number information of the initialization code (fninit). - // It would be better to use an explicit "<autogenerated>" filename - // for fninit and set lineno to NoPos here. - // TODO(gri) fix this once we switched permanently to the new - // position information. - lineno = makePos(p.file.Pos().Base(), uint(p.file.Lines), 0) - + lineno = src.NoXPos clearImports() } |
