]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj: change linkgetline from C to Go func style
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 21 Mar 2016 17:47:24 +0000 (10:47 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 21 Mar 2016 18:45:20 +0000 (18:45 +0000)
Passes toolstash -cmp.

Change-Id: I8725dee490778be9c1fd31990a6b27df9713c3c9
Reviewed-on: https://go-review.googlesource.com/20957
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/internal/obj/line_test.go
src/cmd/internal/obj/obj.go
src/cmd/internal/obj/pcln.go

index 56bf5844fd32a44c3757850c393cefe3852b45e8..8f9bcd1ec6eb121a8d7a77b49259bf97aa933af0 100644 (file)
@@ -40,9 +40,7 @@ func TestLineHist(t *testing.T) {
        }
 
        for i, want := range expect {
-               var f *LSym
-               var l int32
-               linkgetline(ctxt, int32(i), &f, &l)
+               f, l := linkgetline(ctxt, int32(i))
                have := fmt.Sprintf("%s:%d", f.Name, l)
                if have != want {
                        t.Errorf("linkgetline(%d) = %q, want %q", i, have, want)
index f38078fca869292bbcef253766eab9a0f6f04ebd..3eb37b3bbc28957348a40c48528a20f8738cee49 100644 (file)
@@ -273,18 +273,15 @@ func (h *LineHist) AbsFileLine(lineno int) (file string, line int) {
 // This is a simplified copy of linklinefmt above.
 // It doesn't allow printing the full stack, and it returns the file name and line number separately.
 // TODO: Unify with linklinefmt somehow.
-func linkgetline(ctxt *Link, lineno int32, f **LSym, l *int32) {
+func linkgetline(ctxt *Link, lineno int32) (f *LSym, l int32) {
        stk := ctxt.LineHist.At(int(lineno))
        if stk == nil || stk.AbsFile == "" {
-               *f = Linklookup(ctxt, "??", HistVersion)
-               *l = 0
-               return
+               return Linklookup(ctxt, "??", HistVersion), 0
        }
        if stk.Sym == nil {
                stk.Sym = Linklookup(ctxt, stk.AbsFile, HistVersion)
        }
-       *f = stk.Sym
-       *l = int32(stk.fileLineAt(int(lineno)))
+       return stk.Sym, int32(stk.fileLineAt(int(lineno)))
 }
 
 func Linkprfile(ctxt *Link, line int) {
index 9a2e3f3aa8d733b9d93d566b875b52ee111a18fa..9770c96fccffd0e33192ff55d5ad665c7f5401e4 100644 (file)
@@ -143,9 +143,7 @@ func pctofileline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg
        if p.As == ATEXT || p.As == ANOP || p.As == AUSEFIELD || p.Lineno == 0 || phase == 1 {
                return oldval
        }
-       var l int32
-       var f *LSym
-       linkgetline(ctxt, p.Lineno, &f, &l)
+       f, l := linkgetline(ctxt, p.Lineno)
        if f == nil {
                //      print("getline failed for %s %v\n", ctxt->cursym->name, p);
                return oldval