[cfe-commits] r55800 - /cfe/trunk/lib/AST/CFG.cpp
Ted Kremenek
kremenek at apple.com
Thu Sep 4 14:48:47 PDT 2008
Author: kremenek
Date: Thu Sep 4 16:48:47 2008
New Revision: 55800
URL: http://llvm.org/viewvc/llvm-project?rev=55800&view=rev
Log:
Fix CFG construction bug:
- Within for loops, 'continue' should jump to a basic block containing the
increment code
Modified:
cfe/trunk/lib/AST/CFG.cpp
Modified: cfe/trunk/lib/AST/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CFG.cpp?rev=55800&r1=55799&r2=55800&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CFG.cpp (original)
+++ cfe/trunk/lib/AST/CFG.cpp Thu Sep 4 16:48:47 2008
@@ -721,18 +721,24 @@
SaveAndRestore<CFGBlock*> save_Block(Block), save_Succ(Succ),
save_continue(ContinueTargetBlock),
save_break(BreakTargetBlock);
-
- // All continues within this loop should go to the condition block
- ContinueTargetBlock = EntryConditionBlock;
-
- // All breaks should go to the code following the loop.
- BreakTargetBlock = LoopSuccessor;
-
+
// Create a new block to contain the (bottom) of the loop body.
Block = NULL;
- // If we have increment code, insert it at the end of the body block.
- if (Stmt* I = F->getInc()) Block = addStmt(I);
+ 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;
+ ContinueTargetBlock = Succ;
+ }
+ else {
+ // No increment code. Continues should go the the entry condition block.
+ ContinueTargetBlock = EntryConditionBlock;
+ }
+
+ // All breaks should go to the code following the loop.
+ BreakTargetBlock = LoopSuccessor;
// Now populate the body block, and in the process create new blocks
// as we walk the body of the loop.
More information about the cfe-commits
mailing list