[cfe-commits] r118927 - /cfe/trunk/tools/libclang/CIndex.cpp
Ted Kremenek
kremenek at apple.com
Fri Nov 12 13:34:10 PST 2010
Author: kremenek
Date: Fri Nov 12 15:34:09 2010
New Revision: 118927
URL: http://llvm.org/viewvc/llvm-project?rev=118927&view=rev
Log:
CursorVisitor: add data-recursion support for InitListExprs.
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=118927&r1=118926&r2=118927&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Nov 12 15:34:09 2010
@@ -343,7 +343,6 @@
bool VisitAddrLabelExpr(AddrLabelExpr *E);
bool VisitTypesCompatibleExpr(TypesCompatibleExpr *E);
bool VisitVAArgExpr(VAArgExpr *E);
- bool VisitInitListExpr(InitListExpr *E);
bool VisitDesignatedInitExpr(DesignatedInitExpr *E);
bool VisitCXXTypeidExpr(CXXTypeidExpr *E);
bool VisitCXXUuidofExpr(CXXUuidofExpr *E);
@@ -366,11 +365,12 @@
DATA_RECURSIVE_VISIT(CXXOperatorCallExpr)
DATA_RECURSIVE_VISIT(DoStmt)
DATA_RECURSIVE_VISIT(IfStmt)
+ DATA_RECURSIVE_VISIT(InitListExpr)
DATA_RECURSIVE_VISIT(ForStmt)
DATA_RECURSIVE_VISIT(MemberExpr)
DATA_RECURSIVE_VISIT(SwitchStmt)
DATA_RECURSIVE_VISIT(WhileStmt)
-
+
// Data-recursive visitor functions.
bool IsInRegionOfInterest(CXCursor C);
bool RunVisitorWorkList(VisitorWorkList &WL);
@@ -1587,14 +1587,6 @@
return Visit(MakeCXCursor(E->getSubExpr(), StmtParent, TU));
}
-bool CursorVisitor::VisitInitListExpr(InitListExpr *E) {
- // We care about the syntactic form of the initializer list, only.
- if (InitListExpr *Syntactic = E->getSyntacticForm())
- return VisitExpr(Syntactic);
-
- return VisitExpr(E);
-}
-
bool CursorVisitor::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
// Visit the designators.
typedef DesignatedInitExpr::Designator Designator;
@@ -1841,23 +1833,26 @@
// Data-recursive visitor methods.
//===----------------------------------------------------------------------===//
+static void EnqueueChildren(VisitorWorkList &WL, CXCursor Parent, Stmt *S) {
+ unsigned size = WL.size();
+ for (Stmt::child_iterator Child = S->child_begin(), ChildEnd = S->child_end();
+ Child != ChildEnd; ++Child) {
+ WLAddStmt(WL, Parent, *Child);
+ }
+ if (size == WL.size())
+ return;
+ // Now reverse the entries we just added. This will match the DFS
+ // ordering performed by the worklist.
+ VisitorWorkList::iterator I = WL.begin() + size, E = WL.end();
+ std::reverse(I, E);
+}
+
void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, Stmt *S) {
CXCursor C = MakeCXCursor(S, StmtParent, TU);
switch (S->getStmtClass()) {
- default: {
- unsigned size = WL.size();
- for (Stmt::child_iterator Child = S->child_begin(),
- ChildEnd = S->child_end(); Child != ChildEnd; ++Child) {
- WLAddStmt(WL, C, *Child);
- }
- if (size == WL.size())
- return;
- // Now reverse the entries we just added. This will match the DFS
- // ordering performed by the worklist.
- VisitorWorkList::iterator I = WL.begin() + size, E = WL.end();
- std::reverse(I, E);
+ default:
+ EnqueueChildren(WL, C, S);
break;
- }
case Stmt::CXXOperatorCallExprClass: {
CXXOperatorCallExpr *CE = cast<CXXOperatorCallExpr>(S);
// Note that we enqueue things in reverse order so that
@@ -1892,6 +1887,14 @@
WLAddDecl(WL, C, If->getConditionVariable());
break;
}
+ case Stmt::InitListExprClass: {
+ InitListExpr *IE = cast<InitListExpr>(S);
+ // We care about the syntactic form of the initializer list, only.
+ if (InitListExpr *Syntactic = IE->getSyntacticForm())
+ IE = Syntactic;
+ EnqueueChildren(WL, C, IE);
+ break;
+ }
case Stmt::MemberExprClass: {
MemberExpr *M = cast<MemberExpr>(S);
WL.push_back(MemberExprParts(M, C));
@@ -1973,6 +1976,7 @@
case Stmt::DoStmtClass:
case Stmt::ForStmtClass:
case Stmt::IfStmtClass:
+ case Stmt::InitListExprClass:
case Stmt::MemberExprClass:
case Stmt::ParenExprClass:
case Stmt::SwitchStmtClass:
More information about the cfe-commits
mailing list