Open
Description
Hi,
The following legal C++17 code produces the following AST if you call clang from the terminal with -Xclang -ast-dump -std=c++17 -fsyntax-only
:
void x() {
if (int i = 0; i < 1)
return;
}
[...]
FunctionDecl 0x20b5aafe150 <Test.cpp:1:1, line:4:1> line:1:6 x 'void ()'
`-CompoundStmt 0x20b5aafe3a8 <col:10, line:4:1>
`-IfStmt 0x20b5aafe388 <line:2:1, line:3:4> has_init
|-DeclStmt 0x20b5aafe2e0 <line:2:4, col:13>
| `-VarDecl 0x20b5aafe250 <col:4, col:12> col:8 used i 'int' cinit
| `-IntegerLiteral 0x20b5aafe2b8 <col:12> 'int' 0
|-BinaryOperator 0x20b5aafe358 <col:15, col:19> 'bool' '<'
| |-ImplicitCastExpr 0x20b5aafe340 <col:15> 'int' <LValueToRValue>
| | `-DeclRefExpr 0x20b5aafe2f8 <col:15> 'int' lvalue Var 0x20b5aafe250 'i' 'int'
| `-IntegerLiteral 0x20b5aafe318 <col:19> 'int' 1
`-ReturnStmt 0x20b5aafe378 <line:3:4>
Note the DeclStmt cursor and children.
However, when using libclang on the same code by calling clang_visitChildren
, the DeclStmt cursor and its children are never 'visited'. This was tested using the latest Windows x64 build (9.0.0)