[cfe-dev] A newbie question on getting operator in Expr
Adrien Chauve
adrien.chauve at gmail.com
Sat Jun 18 02:46:28 PDT 2011
Hi,
To simplify the code and avoid handwritten recursion, maybe you could
use the RecursiveASTVisitor insted of 3 visitors:
class MyConsumer : public ASTConsumer, public RecursiveASTVisitor<MyConsumer>
{
virtual void HandleTranslationUnit(ASTContext &context)
{
// traverse AST to visit declarations and statements
TraverseDecl(context.getTranslationUnitDecl());
}
bool VisitBinaryOperator(BinaryOperator* expr)
{
// ... handle expr
return true;
}
bool VisitDeclRefExpr(DeclRefExpr* expr)
{
// ... handle expr
return true;
}
};
Adrien
On Sat, Jun 18, 2011 at 07:46, sirinda <sxp969 at psu.edu> wrote:
> sorry, I forgot to include the following code to check if the stmt is an
> expr.
>
> // this code is inside VisitStmt(Stmt* Node)
> if (isa<Expr>(Node)) {
> Expr *expr = (Expr*)Node;
> VisitExpr(expr);
>
> --
> View this message in context: http://clang-developers.42468.n3.nabble.com/A-newbie-question-on-getting-operator-in-Expr-tp3073430p3078936.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
More information about the cfe-dev
mailing list