From 4c98b1f67cdf385e05a86d54201b319cf1f1c042 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Sat, 22 Jun 2013 00:23:20 +0000 Subject: [PATCH] =?utf8?q?[CFG]=20Set=20the=20=E2=80=9Cloop=20target?= =?utf8?q?=E2=80=9D=20(back=20edge)=20for=20VisitObjCForCollectionStmt=20l?= =?utf8?q?oops?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add the back edge info by creating a basic block, marked as loop target. This is consistent with how other loops are processed, but was omitted from VisitObjCForCollectionStmt. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184617 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/CFG.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index f485895185..14b8fd4a10 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -2183,17 +2183,24 @@ CFGBlock *CFGBuilder::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { // Now create the true branch. { // Save the current values for Succ, continue and break targets. - SaveAndRestore save_Succ(Succ); + SaveAndRestore save_Block(Block), save_Succ(Succ); SaveAndRestore save_continue(ContinueJumpTarget), - save_break(BreakJumpTarget); + save_break(BreakJumpTarget); + // Add an intermediate block between the BodyBlock and the + // EntryConditionBlock to represent the "loop back" transition, for looping + // back to the head of the loop. + CFGBlock *LoopBackBlock = 0; + Succ = LoopBackBlock = createBlock(); + LoopBackBlock->setLoopTarget(S); + BreakJumpTarget = JumpTarget(LoopSuccessor, ScopePos); - ContinueJumpTarget = JumpTarget(EntryConditionBlock, ScopePos); + ContinueJumpTarget = JumpTarget(Succ, ScopePos); CFGBlock *BodyBlock = addStmt(S->getBody()); if (!BodyBlock) - BodyBlock = EntryConditionBlock; // can happen for "for (X in Y) ;" + BodyBlock = ContinueJumpTarget.block; // can happen for "for (X in Y) ;" else if (Block) { if (badCFG) return 0; -- 2.40.0