From: Ted Kremenek Date: Wed, 27 Feb 2008 07:20:00 +0000 (+0000) Subject: Bug fix in CFG construction: Properly register the loop head as the implicit X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5482713d70ecbfe608940018046aa248b3d03443;p=clang Bug fix in CFG construction: Properly register the loop head as the implicit successor of blocks created above it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47666 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/CFG.cpp b/AST/CFG.cpp index 431b2e23af..3ea5313619 100644 --- a/AST/CFG.cpp +++ b/AST/CFG.cpp @@ -679,6 +679,7 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) { // There is no loop initialization. We are thus basically a while // loop. NULL out Block to force lazy block construction. Block = NULL; + Succ = EntryConditionBlock; return EntryConditionBlock; } } @@ -758,6 +759,7 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) { Block = NULL; // Return the condition block, which is the dominating block for the loop. + Succ = EntryConditionBlock; return EntryConditionBlock; } @@ -790,11 +792,9 @@ CFGBlock* CFGBuilder::VisitDoStmt(DoStmt* D) { if (Block) FinishBlock(EntryConditionBlock); } - // The condition block is the implicit successor for the loop body as - // well as any code above the loop. + // The condition block is the implicit successor for the loop body. Succ = EntryConditionBlock; - // Process the loop body. CFGBlock* BodyBlock = NULL; { @@ -836,6 +836,7 @@ CFGBlock* CFGBuilder::VisitDoStmt(DoStmt* D) { Block = NULL; // Return the loop body, which is the dominating block for the loop. + Succ = BodyBlock; return BodyBlock; }