From: Josh Bleecher Snyder Date: Mon, 20 Mar 2017 22:32:00 +0000 (-0700) Subject: cmd/compile: use autogenerated position for init functions X-Git-Tag: go1.9beta1~1072 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=49a533e212973d4403de640005fdcf88a23f91c4;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky --- 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("", ""), 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 "" 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() }