]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use autogenerated position for init functions
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 20 Mar 2017 22:32:00 +0000 (15:32 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 21 Mar 2017 03:59:54 +0000 (03:59 +0000)
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>
src/cmd/compile/internal/gc/init.go
src/cmd/compile/internal/gc/noder.go

index 500def7658b62681cf401561499e776dc179a623..8355a735a9274ebce12c58b99572e2ca810778e4 100644 (file)
@@ -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
index ada34406221c592c7c0a3a22a9d276c60cbc584d..a7f0ba54f04259b0ac9c714c155a89718cf8493e 100644 (file)
@@ -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()
 }