[cfe-dev] Clang - get type and identifier from Expr class object

Rajendra rks at cse.iitb.ac.in
Tue Nov 6 08:24:28 PST 2012


Hi,

I am using RecursiveASTVisitor class from clang.

I have following code in an overridden method 
VisitBinaryOperator(BinaryOperator *E):

Expr* lhs = E->getLHS();
Expr* rhs = E->getRHS();

I want to get type and variable name from expression lhs and rhs.

Say I have Stmt x = 10;, then I want to get identifier x from lhs and 
10 from rhs.
If I have Stmt x = x + 10; then I want to get identifier x from lhs and 
x + 10 as sub expression from rhs

How this can be done using clang API? Any pointer is welcome.

- Rajendra



More information about the cfe-dev mailing list