[cfe-dev] Missing statements in the Clang print AST
Miguel Aguilar
miguel.aguilar at ice.rwth-aachen.de
Fri Jan 18 03:03:56 PST 2013
Dimitri,
I think my mistake is that I was trying to have a look into the AST but
the code is still not completely compiling due to errors while searching
for headers. The standard c/c++ libraries are already set by default in
clang or should I specify the paths to the system headers (e.g
/usr/include ..)?
Thanks,
Miguel
On 01/18/2013 11:46 AM, Dmitri Gribenko wrote:
> On Fri, Jan 18, 2013 at 12:39 PM, Miguel Aguilar
> <miguel.aguilar at ice.rwth-aachen.de> wrote:
>> 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?
> Did you show us the complete source code file? Do you get any errors
> if you remove -ast-dump? (For example, errors about undeclared
> 'printf'?) If there are errors, then what you see is the AST after
> error recovery.
>
> Dmitri
>
More information about the cfe-dev
mailing list