[cfe-dev] A newbie question on getting operator in Expr

Adam Smalin acidzombie24 at gmail.com
Sat Jun 18 03:43:44 PDT 2011


I dont want to hijack this thread but how would i start the
RecursiveASTVisitor? The problem is, i dont know what to do after i call
LoadFromASTFile
My question is in more detail here
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-June/015613.html

On Sat, Jun 18, 2011 at 5:46 AM, Adrien Chauve <adrien.chauve at gmail.com>wrote:

> 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
> >
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110618/cd793be9/attachment.html>


More information about the cfe-dev mailing list