diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-01-22 01:00:11 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-01-22 01:00:11 +0000 |
| commit | e1084fa2d24cae2ac75d388c010037012f67caff (patch) | |
| tree | bac4d697b65bb0222bdca3cb24237437f6b258aa /clang/tools | |
| parent | 88c46d713ba1ea96b22913177d67a88574cb3446 (diff) | |
| download | bcm5719-llvm-e1084fa2d24cae2ac75d388c010037012f67caff.tar.gz bcm5719-llvm-e1084fa2d24cae2ac75d388c010037012f67caff.zip | |
Visit if, switch statements properly
llvm-svn: 94126
Diffstat (limited to 'clang/tools')
| -rw-r--r-- | clang/tools/CIndex/CIndex.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp index c17f50a0a2b..e84d15ceae1 100644 --- a/clang/tools/CIndex/CIndex.cpp +++ b/clang/tools/CIndex/CIndex.cpp @@ -224,6 +224,9 @@ public: // 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 @@ bool CursorVisitor::VisitDeclStmt(DeclStmt *S) { 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) { |

