diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-04-15 05:11:28 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-04-15 05:11:28 +0000 |
commit | 42e7fe5685de54c18d1c466632dacacabde0b202 (patch) | |
tree | 98a6e9ddec3dbccf528c0c8c626efed9327a1224 | |
parent | 37622081d8a139a3249613acaa80106ec97261fb (diff) |
Bug fix in VisitChildren: Only visit the last statement in a StmtExpr and the RHS of a comma expression, as the other Stmts will be visited elsewhere in a CFGBlock.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49710 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Analysis/Visitors/CFGStmtVisitor.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/clang/Analysis/Visitors/CFGStmtVisitor.h b/include/clang/Analysis/Visitors/CFGStmtVisitor.h index 5cc8bc57e0..5c3b283944 100644 --- a/include/clang/Analysis/Visitors/CFGStmtVisitor.h +++ b/include/clang/Analysis/Visitors/CFGStmtVisitor.h @@ -118,6 +118,26 @@ public: /// VisitChildren: Call "Visit" on each child of S. void VisitChildren(Stmt* S) { + + switch (S->getStmtClass()) { + default: + break; + + case Stmt::StmtExprClass: { + CompoundStmt* CS = cast<StmtExpr>(S)->getSubStmt(); + if (CS->body_empty()) return; + static_cast<ImplClass*>(this)->Visit(CS->body_back()); + return; + } + + case Stmt::BinaryOperatorClass: { + BinaryOperator* B = cast<BinaryOperator>(S); + if (B->getOpcode() != BinaryOperator::Comma) break; + static_cast<ImplClass*>(this)->Visit(B->getRHS()); + return; + } + } + for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I != E;++I) if (*I) static_cast<ImplClass*>(this)->Visit(*I); } |