[llvm-branch-commits] [cfe-branch] r119630 - /cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp

Daniel Dunbar daniel at zuster.org
Wed Nov 17 18:36:46 PST 2010


Author: ddunbar
Date: Wed Nov 17 20:36:45 2010
New Revision: 119630

URL: http://llvm.org/viewvc/llvm-project?rev=119630&view=rev
Log:
Merge r118927:
--
Author: Ted Kremenek <kremenek at apple.com>
Date:   Fri Nov 12 21:34:09 2010 +0000

    CursorVisitor: add data-recursion support for InitListExprs.

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=119630&r1=119629&r2=119630&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Wed Nov 17 20:36:45 2010
@@ -357,7 +357,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);
@@ -380,11 +379,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);
@@ -1602,14 +1602,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;
@@ -1856,23 +1848,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
@@ -1907,6 +1902,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));
@@ -1988,6 +1991,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 llvm-branch-commits mailing list