[cfe-dev] how to get label from a statement and VisitLabelExpr
Rajendra
rks at cse.iitb.ac.in
Tue May 14 02:04:27 PDT 2013
Here below is my code of VisitStmt() and VisitLabelStmt(), I know when to
return true//false from visitor method and I have tried
VisitLabelStmt(LabelStmt* s) and VisitLabelDecl(LabelDecl* d) too. No luck.
bool MyProcessStmtBox::VisitStmt(Stmt *s)
{
clang::SourceManager & sm = this->m_compilerInstance->getSourceManager();
clang::SourceLocation locStart = s->getLocStart();
std::cerr << "\n found stmt \n";
std::cerr << "\t" << stmtToStr(s) << " at ";
locStart.dump(sm);
std::cerr << "\n";
std::cerr << "StmtClassName = " << s->getStmtClassName();
if (strcmp(s->getStmtClassName(), "LabelStmt") == 0)
{
std::cerr << "\n found LabelStmt\n";
s->dump();
}
// Returning false from one of the overridden visitor functions
// will abort the entire traversal.
return true;
}
bool MyProcessStmtBox::VisitLabelStmt(Stmt* s)
{
std::cerr << "\tLabelStmt: \n";
s->dump(); // TODO: remove
return false;
}
--
View this message in context: http://clang-developers.42468.n3.nabble.com/how-to-get-label-from-a-statement-and-VisitLabelExpr-tp4032103p4032106.html
Sent from the Clang Developers mailing list archive at Nabble.com.
More information about the cfe-dev
mailing list