CursorVisitor: Pull ObjCMessageExpr and explicit casts into data-recursion algorithm.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118934 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index df1937a..ae0f5c7 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -359,7 +359,6 @@
   // Expression visitors
   bool VisitDeclRefExpr(DeclRefExpr *E);
   bool VisitBlockExpr(BlockExpr *B);
-  bool VisitExplicitCastExpr(ExplicitCastExpr *E);
   bool VisitObjCEncodeExpr(ObjCEncodeExpr *E);
   bool VisitOffsetOfExpr(OffsetOfExpr *E);
   bool VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
@@ -385,6 +384,7 @@
   DATA_RECURSIVE_VISIT(CompoundLiteralExpr)
   DATA_RECURSIVE_VISIT(CXXMemberCallExpr)
   DATA_RECURSIVE_VISIT(CXXOperatorCallExpr)
+  DATA_RECURSIVE_VISIT(ExplicitCastExpr)
   DATA_RECURSIVE_VISIT(DoStmt)
   DATA_RECURSIVE_VISIT(IfStmt)
   DATA_RECURSIVE_VISIT(InitListExpr)
@@ -1580,14 +1580,6 @@
   return VisitExpr(E);
 }
 
-bool CursorVisitor::VisitExplicitCastExpr(ExplicitCastExpr *E) {
-  if (TypeSourceInfo *TSInfo = E->getTypeInfoAsWritten())
-    if (Visit(TSInfo->getTypeLoc()))
-      return true;
-
-  return VisitCastExpr(E);
-}
-
 bool CursorVisitor::VisitAddrLabelExpr(AddrLabelExpr *E) {
   return Visit(MakeCursorLabelRef(E->getLabel(), E->getLabelLoc(), TU));
 }
@@ -1824,8 +1816,16 @@
   WL.push_back(OverloadExprParts(E, Parent));
 }
 
+// FIXME: Refactor into StmtVisitor?
 void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, Stmt *S) {
   CXCursor C = MakeCXCursor(S, StmtParent, TU);
+
+  if (ExplicitCastExpr *E = dyn_cast<ExplicitCastExpr>(S)) {
+    EnqueueChildren(WL, C, S);
+    WLAddTypeLoc(WL, C, cast<ExplicitCastExpr>(S)->getTypeInfoAsWritten());
+    return;
+  }
+
   switch (S->getStmtClass()) {
     default:
       EnqueueChildren(WL, C, S);
@@ -1964,10 +1964,15 @@
         
         switch (S->getStmtClass()) {
           default: {
-            // Perform default visitation for other cases.
-            if (Visit(Cursor))
-              return true;
-            continue;
+            // FIXME: this entire switch stmt will eventually
+            // go away.
+            if (!isa<ExplicitCastExpr>(S)) {
+              // Perform default visitation for other cases.
+              if (Visit(Cursor))
+                return true;
+              continue;
+            }
+            // Fall-through.
           }
           case Stmt::BinaryOperatorClass:
           case Stmt::CallExprClass: