From a1523a38f9d4991bcbd90be9b30e19fe94f2332f Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 27 Feb 2008 07:20:00 +0000 Subject: [PATCH] Bug fix in CFG construction: Properly register the loop head as the implicit successor of blocks created above it. llvm-svn: 47666 --- clang/AST/CFG.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/AST/CFG.cpp b/clang/AST/CFG.cpp index 431b2e23af14..3ea531361947 100644 --- a/clang/AST/CFG.cpp +++ b/clang/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; }