[cfe-dev] Missing statements in the Clang print AST
Miguel Aguilar
miguel.aguilar at ice.rwth-aachen.de
Fri Jan 18 02:39:07 PST 2013
Hi Dimitri,
I wanted to be sure that the functions in the AST have the complete body
of the original code. By using the -ast-dump I got the following:
void main() (CompoundStmt 0x57fca90 <pc/consumer.cc:28:1, line:42:1>
(DeclStmt 0x57fc110 <line:29:3, col:10>
(0x57fc030 "int n")
(0x57fc0a0 "int j"))
(ForStmt 0x57fca50 <line:37:3, line:41:3>
(DeclStmt 0x57fc358 <line:37:8, col:15>
(0x57fc2e0 "int i =
(IntegerLiteral 0x57fc338 <col:14> 'int' 0)"))
(<<<NULL>>>)
(BinaryOperator 0x57fc3f0 <col:17, col:19> '_Bool' '<'
(ImplicitCastExpr 0x57fc3c0 <col:17> 'int' <LValueToRValue>
(DeclRefExpr 0x57fc370 <col:17> 'int' lvalue Var 0x57fc2e0 'i'
'int'))
(ImplicitCastExpr 0x57fc3d8 <col:19> 'int' <LValueToRValue>
(DeclRefExpr 0x57fc398 <col:19> 'int' lvalue Var 0x57fc030 'n'
'int')))
(UnaryOperator 0x57fc440 <col:22, col:23> 'int' postfix '++'
(DeclRefExpr 0x57fc418 <col:22> 'int' lvalue Var 0x57fc2e0 'i'
'int'))
(CompoundStmt 0x57fc5d0 <line:38:3, line:41:3>)))
However, here I don't see the function call to the "printf" and the
statement "s = 5". Any ideas?
Miguel
On 01/18/2013 11:31 AM, Dmitri Gribenko wrote:
> On Fri, Jan 18, 2013 at 12:23 PM, Miguel Aguilar
> <miguel.aguilar at ice.rwth-aachen.de> wrote:
>> Hi,
>>
>> I am trying to inspect the AST generated by clang of a simple C++ program.
>> However in the body of the printed function are missing statements and
>> functions call with respect to the original code. Can you tell me what
>> parameters are missing while calling clang?
> Hello Miguel,
>
> The parameters are correct. The AST printer in Clang is a bit broken.
> Patches welcome!
>
> If you just need to inspect the AST, try -ast-dump. It displays all AST nodes.
>
> Dmitri
>
More information about the cfe-dev
mailing list