Commit b07a214d authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/internal/obj: change linkgetline from C to Go func style

Passes toolstash -cmp.

Change-Id: I8725dee490778be9c1fd31990a6b27df9713c3c9
Reviewed-on: https://go-review.googlesource.com/20957Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 075d6664
......@@ -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)
......
......@@ -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) {
......
......@@ -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
......
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