Visit if, switch statements properly

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94126 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp
index c17f50a..e84d15c 100644
--- a/tools/CIndex/CIndex.cpp
+++ b/tools/CIndex/CIndex.cpp
@@ -224,6 +224,9 @@
   // Statement visitors
   bool VisitStmt(Stmt *S);
   bool VisitDeclStmt(DeclStmt *S);
+  // FIXME: LabelStmt label?
+  bool VisitIfStmt(IfStmt *S);
+  bool VisitSwitchStmt(SwitchStmt *S);
 };
   
 } // end anonymous namespace
@@ -677,6 +680,35 @@
   return false;
 }
 
+bool CursorVisitor::VisitIfStmt(IfStmt *S) {
+  if (VarDecl *Var = S->getConditionVariable()) {
+    if (Visit(MakeCXCursor(Var, TU)))
+      return true;
+  } else 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::VisitSwitchStmt(SwitchStmt *S) {
+  if (VarDecl *Var = S->getConditionVariable()) {
+    if (Visit(MakeCXCursor(Var, TU)))
+      return true;
+  } else if (S->getCond() && Visit(MakeCXCursor(S->getCond(), StmtParent, TU)))
+    return true;
+
+  if (S->getBody() && Visit(MakeCXCursor(S->getBody(), StmtParent, TU)))
+    return true;
+  
+  return false;
+}
+
 CXString CIndexer::createCXString(const char *String, bool DupString){
   CXString Str;
   if (DupString) {