Visit if, switch statements properly

llvm-svn: 94126
diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp
index c17f50a..e84d15c 100644
--- a/clang/tools/CIndex/CIndex.cpp
+++ b/clang/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) {