Visit if, switch statements properly

llvm-svn: 94126
This commit is contained in:
Douglas Gregor 2010-01-22 01:00:11 +00:00
parent 88c46d713b
commit e1084fa2d2
1 changed files with 32 additions and 0 deletions

View File

@ -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) {