summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-11-24 20:50:24 +0000
committerTed Kremenek <kremenek@apple.com>2008-11-24 20:50:24 +0000
commite03879b8ad738b9b6df2dcb370ec0da02b282cef (patch)
treea1d74fdac12557739679e11cc6eb09d6a9efc158 /clang/lib/AST
parente6fe59df6deff3835537305eafddd7abd9476cf7 (diff)
downloadbcm5719-llvm-e03879b8ad738b9b6df2dcb370ec0da02b282cef.tar.gz
bcm5719-llvm-e03879b8ad738b9b6df2dcb370ec0da02b282cef.zip
Fix CFG bug where the 'increment' block for a 'for' statement would not be
properly reversed once constructed. This fixes PR 3125: http://llvm.org/bugs/show_bug.cgi?id=3125 llvm-svn: 59982
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/CFG.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/AST/CFG.cpp b/clang/lib/AST/CFG.cpp
index f8c3c26bb11..82336a44e08 100644
--- a/clang/lib/AST/CFG.cpp
+++ b/clang/lib/AST/CFG.cpp
@@ -745,8 +745,15 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
if (Stmt* I = F->getInc()) {
// Generate increment code in its own basic block. This is the target
// of continue statements.
- Succ = addStmt(I);
- Block = 0;
+ Succ = Visit(I);
+
+ // Finish up the increment block if it hasn't been already.
+ if (Block) {
+ assert (Block == Succ);
+ FinishBlock(Block);
+ Block = 0;
+ }
+
ContinueTargetBlock = Succ;
}
else {
@@ -1621,6 +1628,7 @@ void CFG::print(llvm::raw_ostream& OS) const {
// Print the exit block.
print_block(OS, this, getExit(), &Helper, true);
+ OS.flush();
}
/// dump - A simply pretty printer of a CFGBlock that outputs to stderr.
OpenPOWER on IntegriCloud