[cfe-commits] r118912 - /cfe/trunk/tools/libclang/CIndex.cpp
Ted Kremenek
kremenek at apple.com
Fri Nov 12 10:27:04 PST 2010
Author: kremenek
Date: Fri Nov 12 12:27:04 2010
New Revision: 118912
URL: http://llvm.org/viewvc/llvm-project?rev=118912&view=rev
Log:
CursorVisitor: migrate 'DoStmt', 'ForStmt', and 'WhileStmt' over to data-recursion algorithm.
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=118912&r1=118911&r2=118912&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Nov 12 12:27:04 2010
@@ -330,8 +330,6 @@
bool VisitStmt(Stmt *S);
bool VisitDeclStmt(DeclStmt *S);
bool VisitGotoStmt(GotoStmt *S);
- bool VisitWhileStmt(WhileStmt *S);
- bool VisitForStmt(ForStmt *S);
// Expression visitors
bool VisitDeclRefExpr(DeclRefExpr *E);
@@ -366,9 +364,12 @@
DATA_RECURSIVE_VISIT(BinaryOperator)
DATA_RECURSIVE_VISIT(CXXMemberCallExpr)
DATA_RECURSIVE_VISIT(CXXOperatorCallExpr)
+ DATA_RECURSIVE_VISIT(DoStmt)
DATA_RECURSIVE_VISIT(IfStmt)
+ DATA_RECURSIVE_VISIT(ForStmt)
DATA_RECURSIVE_VISIT(MemberExpr)
DATA_RECURSIVE_VISIT(SwitchStmt)
+ DATA_RECURSIVE_VISIT(WhileStmt)
// Data-recursive visitor functions.
bool IsInRegionOfInterest(CXCursor C);
@@ -1472,38 +1473,6 @@
return Visit(MakeCursorLabelRef(S->getLabel(), S->getLabelLoc(), TU));
}
-bool CursorVisitor::VisitWhileStmt(WhileStmt *S) {
- if (VarDecl *Var = S->getConditionVariable()) {
- if (Visit(MakeCXCursor(Var, TU)))
- return true;
- }
-
- if (S->getCond() && Visit(MakeCXCursor(S->getCond(), StmtParent, TU)))
- return true;
- if (S->getBody() && Visit(MakeCXCursor(S->getBody(), StmtParent, TU)))
- return true;
-
- return false;
-}
-
-bool CursorVisitor::VisitForStmt(ForStmt *S) {
- if (S->getInit() && Visit(MakeCXCursor(S->getInit(), StmtParent, TU)))
- return true;
- if (VarDecl *Var = S->getConditionVariable()) {
- if (Visit(MakeCXCursor(Var, TU)))
- return true;
- }
-
- if (S->getCond() && Visit(MakeCXCursor(S->getCond(), StmtParent, TU)))
- return true;
- if (S->getInc() && Visit(MakeCXCursor(S->getInc(), StmtParent, TU)))
- return true;
- if (S->getBody() && Visit(MakeCXCursor(S->getBody(), StmtParent, TU)))
- return true;
-
- return false;
-}
-
bool CursorVisitor::VisitDeclRefExpr(DeclRefExpr *E) {
// Visit nested-name-specifier, if present.
if (NestedNameSpecifier *Qualifier = E->getQualifier())
@@ -1906,6 +1875,15 @@
WLAddStmt(WL, C, B->getLHS());
break;
}
+ case Stmt::ForStmtClass: {
+ ForStmt *FS = cast<ForStmt>(S);
+ WLAddStmt(WL, C, FS->getBody());
+ WLAddStmt(WL, C, FS->getInc());
+ WLAddStmt(WL, C, FS->getCond());
+ WLAddDecl(WL, C, FS->getConditionVariable());
+ WLAddStmt(WL, C, FS->getInit());
+ break;
+ }
case Stmt::IfStmtClass: {
IfStmt *If = cast<IfStmt>(S);
WLAddStmt(WL, C, If->getElse());
@@ -1931,6 +1909,13 @@
WLAddDecl(WL, C, SS->getConditionVariable());
break;
}
+ case Stmt::WhileStmtClass: {
+ WhileStmt *W = cast<WhileStmt>(S);
+ WLAddStmt(WL, C, W->getBody());
+ WLAddStmt(WL, C, W->getCond());
+ WLAddDecl(WL, C, W->getConditionVariable());
+ break;
+ }
}
}
@@ -1985,11 +1970,14 @@
case Stmt::CXXMemberCallExprClass:
case Stmt::CXXOperatorCallExprClass:
case Stmt::DefaultStmtClass:
+ case Stmt::DoStmtClass:
+ case Stmt::ForStmtClass:
case Stmt::IfStmtClass:
case Stmt::MemberExprClass:
case Stmt::ParenExprClass:
case Stmt::SwitchStmtClass:
case Stmt::UnaryOperatorClass:
+ case Stmt::WhileStmtClass:
{
if (!IsInRegionOfInterest(Cursor))
continue;
More information about the cfe-commits
mailing list