diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-10-27 03:23:10 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-10-27 03:23:10 +0000 |
commit | d95ccd58a9fd96880c94ca995b334501738df5e8 (patch) | |
tree | d7b9821b06f2e5031fc7731678306d71b684ca88 /clang/lib/Analysis/CFG.cpp | |
parent | 9ad2166899e6438c22234b4a13fd276875dd9528 (diff) | |
download | bcm5719-llvm-d95ccd58a9fd96880c94ca995b334501738df5e8.tar.gz bcm5719-llvm-d95ccd58a9fd96880c94ca995b334501738df5e8.zip |
If visiting RHS causes us to finish 'Block', e.g. the RHS is a StmtExpr
containing a DoStmt, and the LHS doesn't create a new block, then we should
return RBlock. Otherwise we'll incorrectly return NULL.
Also relax an assertion in VisitWhileStmt(). Reset 'Block' when it is finished.
llvm-svn: 117436
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index f003879b7a7..3653500f925 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -935,8 +935,12 @@ CFGBlock *CFGBuilder::VisitBinaryOperator(BinaryOperator *B, AppendStmt(Block, B, asc); } - Visit(B->getRHS()); - return Visit(B->getLHS()); + CFGBlock *RBlock = Visit(B->getRHS()); + CFGBlock *LBlock = Visit(B->getLHS()); + // If visiting RHS causes us to finish 'Block', e.g. the RHS is a StmtExpr + // containing a DoStmt, and the LHS doesn't create a new block, then we should + // return RBlock. Otherwise we'll incorrectly return NULL. + return (LBlock ? LBlock : RBlock); } CFGBlock *CFGBuilder::VisitBlockExpr(BlockExpr *E, AddStmtChoice asc) { @@ -1736,7 +1740,8 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) { if (Stmt* C = W->getCond()) { Block = ExitConditionBlock; EntryConditionBlock = addStmt(C); - assert(Block == EntryConditionBlock); + // The condition might finish the current 'Block'. + Block = EntryConditionBlock; // If this block contains a condition variable, add both the condition // variable and initializer to the CFG. |