[llvm-branch-commits] [cfe-branch] r119629 - /cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
Daniel Dunbar
daniel at zuster.org
Wed Nov 17 18:36:43 PST 2010
Author: ddunbar
Date: Wed Nov 17 20:36:43 2010
New Revision: 119629
URL: http://llvm.org/viewvc/llvm-project?rev=119629&view=rev
Log:
Merge r118912:
--
Author: Ted Kremenek <kremenek at apple.com>
Date: Fri Nov 12 18:27:04 2010 +0000
CursorVisitor: migrate 'DoStmt', 'ForStmt', and 'WhileStmt' over to data-recursion algorithm.
Modified:
cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
Modified: cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp?rev=119629&r1=119628&r2=119629&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Wed Nov 17 20:36:43 2010
@@ -344,8 +344,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);
@@ -380,9 +378,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);
@@ -1487,38 +1488,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())
@@ -1921,6 +1890,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());
@@ -1946,6 +1924,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;
+ }
}
}
@@ -2000,11 +1985,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 llvm-branch-commits
mailing list