Iterating through an Expression in the Clang AST


I want to iterate through an Expression while visiting the nodes in the
Clang AST. Using the function VisitExpr(),
I am able to visit various expressions, but I wish to find sub expessions
for analysis.

Eg. given an expression: 3+A+B, I wish to iterate through this expression
and visit 3,A and B.

Does anyone have any idea how this can be done?


Expressions are derived from Statements. You can use the child_begin and
child_end iterators in Statement to iterate through child statements. Use
dump() to output the whole expression (including children) on to the std

thanks! i used the iterators to iterate through a stmt but how do i check
what type the sub statement contains? eg. how do i find out if the sub
statement is say, a binary operator?

Thanks everyone!