From 1678dcc3784459ccf818779ba013e12c5b31df31 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 9 Sep 2010 17:11:51 -0400 Subject: [PATCH] gc: more accurate line numbers for ATEXT and other begin and end of function code R=ken2 CC=golang-dev https://golang.org/cl/2158044 --- src/cmd/5g/ggen.c | 4 ++++ src/cmd/6g/ggen.c | 4 ++++ src/cmd/8g/ggen.c | 4 ++++ src/cmd/gc/go.y | 1 + 4 files changed, 13 insertions(+) diff --git a/src/cmd/5g/ggen.c b/src/cmd/5g/ggen.c index 328d3284da2..c906064584e 100644 --- a/src/cmd/5g/ggen.c +++ b/src/cmd/5g/ggen.c @@ -61,6 +61,8 @@ compile(Node *fn) pl = newplist(); pl->name = curfn->nname; + + setlineno(curfn); nodconst(&nod1, types[TINT32], 0); ptxt = gins(ATEXT, curfn->nname, &nod1); @@ -93,6 +95,8 @@ compile(Node *fn) genlist(curfn->exit); if(nerrors != 0) goto ret; + if(curfn->endlineno) + lineno = curfn->endlineno; pc->as = ARET; // overwrite AEND pc->lineno = lineno; diff --git a/src/cmd/6g/ggen.c b/src/cmd/6g/ggen.c index f0aa16cb429..6d005d7ece3 100644 --- a/src/cmd/6g/ggen.c +++ b/src/cmd/6g/ggen.c @@ -62,6 +62,8 @@ compile(Node *fn) pl = newplist(); pl->name = curfn->nname; + setlineno(curfn); + nodconst(&nod1, types[TINT32], 0); ptxt = gins(ATEXT, curfn->nname, &nod1); afunclit(&ptxt->from); @@ -83,6 +85,8 @@ compile(Node *fn) checklabels(); if(nerrors != 0) goto ret; + if(curfn->endlineno) + lineno = curfn->endlineno; if(curfn->type->outtuple != 0) ginscall(throwreturn, 0); diff --git a/src/cmd/8g/ggen.c b/src/cmd/8g/ggen.c index 5c51833ea20..0c3a8260c2b 100644 --- a/src/cmd/8g/ggen.c +++ b/src/cmd/8g/ggen.c @@ -64,6 +64,8 @@ compile(Node *fn) pl = newplist(); pl->name = curfn->nname; + setlineno(curfn); + nodconst(&nod1, types[TINT32], 0); ptxt = gins(ATEXT, curfn->nname, &nod1); afunclit(&ptxt->from); @@ -85,6 +87,8 @@ compile(Node *fn) checklabels(); if(nerrors != 0) goto ret; + if(curfn->endlineno) + lineno = curfn->endlineno; if(curfn->type->outtuple != 0) ginscall(throwreturn, 0); diff --git a/src/cmd/gc/go.y b/src/cmd/gc/go.y index 48b8c711e1e..e210fbd2cd3 100644 --- a/src/cmd/gc/go.y +++ b/src/cmd/gc/go.y @@ -1100,6 +1100,7 @@ xfndcl: if($$ == N) break; $$->nbody = $3; + $$->endlineno = lineno; funcbody($$); }