Hi,
I'm trying to use GCC 4.3.0 for a program analysis frontend, and I've
noticed that for, while, and do-while loops are all converted to a lower
level representation using goto statements during the parsing phase.
I've been trying to recover the source-code-like higher-level loop
representation; however, I'm confused about a few things.
Consider the following nested for loop:
int i, j;
for(i = 0; i<size; i++)
{
for(j=i, j>i, j--){
....
}
...
}
In the function c_parser_for_statement in the file c-parser.c, it seems
like the body of the outer for loop is an _empty statement list_. It
seems to me that this statement list is somehow being correctly patched
at a later point in time, but I don't quite understand how this works.
My idea was to maintain a mapping from the original loop representation
with the original loop body, init-expression, etc to the modified lower
level gcc representation, but since the body is an empty statement list
at this point, I can't recover the original structure of the loop.
I'd really appreciate any explanation about how specifically loops are
converted to a lower-level representation and why the body of the loop
looks like an empty statement list during parsing. Or if there is a
better way of recovering the higher-level loop representation, I would
also appreciate any tips about that.
Thanks a lot in advance,
Isil