[cfe-dev] How to now step into macro while using RecursiveASTVisitor?

rayjcwu rayjcwu at gmail.com
Tue Nov 26 01:52:34 PST 2013


Thanks for your help, I could skip macros now.
Another problem I found is if I have source code like this:

     int t = square_enix(3) + func();

AST of right hand side is 

   `-BinaryOperator 0x2ebf808 'int' '+'
     |-ParenExpr 0x2e78540 'int'
     | `-BinaryOperator 0x2e78518 'int' '*'
     |   |-ParenExpr 0x2e784b8 'int'
     |   | `-IntegerLiteral 0x2e78498 'int' 3
     |   `-ParenExpr 0x2e784f8 'int'
     |     `-IntegerLiteral 0x2e784d8 'int' 3
     `-CallExpr 0x2ebf7e0 'int'
       `-ImplicitCastExpr 0x2ebf7c8 'int (*)()' <FunctionToPointerDecay>
         `-DeclRefExpr 0x2e78620 'int ()' Function 0x2e78580 'func' 'int ()'

WalkUpFrom* in RecursiveASTVisitor will invoke Visit* from Base class to
Derived class. Since BinaryOperator and ParenExpr start at the same
location, my approach will skip whole BinaryOperator instead of just
ParenExpr.

Right now I visit preprocessed source code and store macro information
separately. Not sure if there is a easier way to handle this in
RecursiveASTVisitor.



--
View this message in context: http://clang-developers.42468.n3.nabble.com/How-to-avoid-visiting-children-of-macro-while-using-RecursiveASTVisitor-tp4036170p4036304.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list