[cfe-dev] clang::RecursiveASTVisitor does not visit ObjCMessageExpr statement

PavelKatunin wk.katunin at gmail.com
Mon Nov 25 01:13:52 PST 2013


I am wondering that in RewriteObjC source RecursiveASTVisitor not used
http://clang.llvm.org/doxygen/RewriteObjC_8cpp_source.html

I need to do some actions with all ObjCMessageExpr in my code,
so I am trying to handle all expressions with RecursiveASTVisitor,

I made subclass 
class MyASTVisitor : public clang::RecursiveASTVisitor<MyASTVisitor>  

and I defined method 

bool MyASTVisitor::VisitStmt(Stmt *statement) {
    cout << "LOG: Visit stmt " << GetStatementString(*m_compiler,
*statement) << endl;
    if (ObjCMessageExpr *messageExpr = dyn_cast<ObjCMessageExpr>(statement))
{
        // some methods
    }
    else if (Expr *expression = dyn_cast<Expr>(statement)) {
        cout << "LOG: expression" << endl;
    }
    return true;
}


in my cunsumer I call 

void MyASTConsumer::HandleTopLevelSingleDecl(Decl *declaration) {
    cout << "LOG: HandleTopLevelSingleDecl" << endl;
    m_visitor->TraverseDecl(declaration);
}

But I cannot extract ObjCMessageExpr with this code,

What should I do for that?







--
View this message in context: http://clang-developers.42468.n3.nabble.com/clang-RecursiveASTVisitor-does-not-visit-ObjCMessageExpr-statement-tp4036268.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list