Commit 49a533e2 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

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: default avatarMatthew Dempsky <mdempsky@google.com>
parent 346d5883
......@@ -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
......
......@@ -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()
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment