[llvm-branch-commits] [cfe-branch] r119627 - /cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
Daniel Dunbar
daniel at zuster.org
Wed Nov 17 18:36:39 PST 2010
Author: ddunbar
Date: Wed Nov 17 20:36:39 2010
New Revision: 119627
URL: http://llvm.org/viewvc/llvm-project?rev=119627&view=rev
Log:
Merge r118910:
--
Author: Ted Kremenek <kremenek at apple.com>
Date: Fri Nov 12 18:26:58 2010 +0000
CursorVisitor: migrate 'IfStmt' over to data-recursive 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=119627&r1=119626&r2=119627&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Wed Nov 17 20:36:39 2010
@@ -163,6 +163,14 @@
DEF_JOB(MemberExprParts, MemberExpr, MemberExprPartsKind)
#undef DEF_JOB
+static inline void WLAddStmt(VisitorWorkList &WL, CXCursor Parent, Stmt *S) {
+ if (S)
+ WL.push_back(StmtVisit(S, Parent));
+}
+static inline void WLAddDecl(VisitorWorkList &WL, CXCursor Parent, Decl *D) {
+ if (D)
+ WL.push_back(DeclVisit(D, Parent));
+}
// Cursor visitor.
class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
@@ -336,7 +344,6 @@
bool VisitStmt(Stmt *S);
bool VisitDeclStmt(DeclStmt *S);
bool VisitGotoStmt(GotoStmt *S);
- bool VisitIfStmt(IfStmt *S);
bool VisitWhileStmt(WhileStmt *S);
bool VisitForStmt(ForStmt *S);
@@ -371,9 +378,10 @@
#define DATA_RECURSIVE_VISIT(NAME)\
bool Visit##NAME(NAME *S) { return VisitDataRecursive(S); }
DATA_RECURSIVE_VISIT(BinaryOperator)
- DATA_RECURSIVE_VISIT(MemberExpr)
DATA_RECURSIVE_VISIT(CXXMemberCallExpr)
DATA_RECURSIVE_VISIT(CXXOperatorCallExpr)
+ DATA_RECURSIVE_VISIT(IfStmt)
+ DATA_RECURSIVE_VISIT(MemberExpr)
DATA_RECURSIVE_VISIT(SwitchStmt)
// Data-recursive visitor functions.
@@ -1479,22 +1487,6 @@
return Visit(MakeCursorLabelRef(S->getLabel(), S->getLabelLoc(), TU));
}
-bool CursorVisitor::VisitIfStmt(IfStmt *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->getThen() && Visit(MakeCXCursor(S->getThen(), StmtParent, TU)))
- return true;
- if (S->getElse() && Visit(MakeCXCursor(S->getElse(), StmtParent, TU)))
- return true;
-
- return false;
-}
-
bool CursorVisitor::VisitWhileStmt(WhileStmt *S) {
if (VarDecl *Var = S->getConditionVariable()) {
if (Visit(MakeCXCursor(Var, TU)))
@@ -1934,6 +1926,14 @@
WL.push_back(StmtVisit(B->getLHS(), C));
break;
}
+ case Stmt::IfStmtClass: {
+ IfStmt *If = cast<IfStmt>(S);
+ WLAddStmt(WL, C, If->getElse());
+ WLAddStmt(WL, C, If->getThen());
+ WLAddStmt(WL, C, If->getCond());
+ WLAddDecl(WL, C, If->getConditionVariable());
+ break;
+ }
case Stmt::MemberExprClass: {
MemberExpr *M = cast<MemberExpr>(S);
WL.push_back(MemberExprParts(M, C));
@@ -2008,6 +2008,7 @@
case Stmt::CXXMemberCallExprClass:
case Stmt::CXXOperatorCallExprClass:
case Stmt::DefaultStmtClass:
+ case Stmt::IfStmtClass:
case Stmt::MemberExprClass:
case Stmt::ParenExprClass:
case Stmt::SwitchStmtClass:
More information about the llvm-branch-commits
mailing list