Following up on a post from long ago, here is a patch which prints #line directives before goto statements and sets the location of gotos inserted when an && or || is unfolded to the location of the statement within which the operator resides. (Before, such inserted goto statements were given the locUnknown location.) This helps the locations of transformed code be more faithful to the original code. (This had caused some headaches for my research group because it meant that, if we measured line coverage based on reading in the text form of the transformed program, we would get inaccurate results.)

Elnatan

Attachment: goto.patch
Description: Binary data




On Apr 7, 2009, at 2:57 PM, Elnatan Reisner wrote:

Is there a reason the defaultCilPrinterClass doesn't print line
directives before gotos? Not printing them makes the line numbers of the
output not quite agree with the original source. For example, CIL
converts:

int main() { goto L; L: return 0; }

into

#line 1 "file.c"
int main(void)
{

 {
 goto L;
 L:
#line 1
 return (0);
}
}

which makes 'goto L;' seem to be on line 5 of this one-line program!

Getting line directives for gotos that are in the original source
essentially just requires adding a call to 'self#pLineDirective' in the Goto case of the printer class's pStmtKind method. But is there an easy way of getting line directives to print before gotos that were inserted
by CIL?

-Elnatan
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to