mirror of
https://github.com/golang/go
synced 2024-11-22 05:34:39 -07:00
gc: better linenumbers for inlined functions
Fixes #2580 up to a point. R=rsc CC=golang-dev https://golang.org/cl/5498068
This commit is contained in:
parent
7350c771f8
commit
86deacc0bc
@ -28,6 +28,8 @@ static Node* newlabel(void);
|
|||||||
static Node* inlsubst(Node *n);
|
static Node* inlsubst(Node *n);
|
||||||
static NodeList* inlsubstlist(NodeList *ll);
|
static NodeList* inlsubstlist(NodeList *ll);
|
||||||
|
|
||||||
|
static void setlno(Node*, int);
|
||||||
|
|
||||||
// Used during inlsubst[list]
|
// Used during inlsubst[list]
|
||||||
static Node *inlfn; // function currently being inlined
|
static Node *inlfn; // function currently being inlined
|
||||||
static Node *inlretlabel; // target of the goto substituted in place of a return
|
static Node *inlretlabel; // target of the goto substituted in place of a return
|
||||||
@ -496,9 +498,10 @@ mkinlcall(Node **np, Node *fn)
|
|||||||
call->nbody = body;
|
call->nbody = body;
|
||||||
call->rlist = inlretvars;
|
call->rlist = inlretvars;
|
||||||
call->type = n->type;
|
call->type = n->type;
|
||||||
call->lineno = n->lineno;
|
|
||||||
call->typecheck = 1;
|
call->typecheck = 1;
|
||||||
|
|
||||||
|
setlno(call, n->lineno);
|
||||||
|
|
||||||
*np = call;
|
*np = call;
|
||||||
|
|
||||||
inlfn = saveinlfn;
|
inlfn = saveinlfn;
|
||||||
@ -686,3 +689,32 @@ inlsubst(Node *n)
|
|||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Plaster over linenumbers
|
||||||
|
static void
|
||||||
|
setlnolist(NodeList *ll, int lno)
|
||||||
|
{
|
||||||
|
for(;ll;ll=ll->next)
|
||||||
|
setlno(ll->n, lno);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setlno(Node *n, int lno)
|
||||||
|
{
|
||||||
|
if(!n)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// don't clobber names, unless they're freshly synthesized
|
||||||
|
if(n->op != ONAME || n->lineno == 0)
|
||||||
|
n->lineno = lno;
|
||||||
|
|
||||||
|
setlno(n->left, lno);
|
||||||
|
setlno(n->right, lno);
|
||||||
|
setlnolist(n->list, lno);
|
||||||
|
setlnolist(n->rlist, lno);
|
||||||
|
setlnolist(n->ninit, lno);
|
||||||
|
setlno(n->ntest, lno);
|
||||||
|
setlno(n->nincr, lno);
|
||||||
|
setlnolist(n->nbody, lno);
|
||||||
|
setlnolist(n->nelse, lno);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user