From: Ted Kremenek Date: Wed, 27 Feb 2008 00:28:17 +0000 (+0000) Subject: Fixed CFG construction bug that occurred when a condition for a loop spanned X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a9d996dbeb719200c4a9d86f68166a237583025f;p=clang Fixed CFG construction bug that occurred when a condition for a loop spanned multiple basic blocks (which can happen when they contain '&&', '||', '?'). The bug was that the loop backedge when to the last block in the loop condition, not the first. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47649 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/CFG.cpp b/AST/CFG.cpp index 335d833e26..431b2e23af 100644 --- a/AST/CFG.cpp +++ b/AST/CFG.cpp @@ -656,7 +656,7 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) { CFGBlock* BodyBlock = Visit(F->getBody()); if (!BodyBlock) - BodyBlock = ExitConditionBlock; // can happen for "for (...;...; ) ;" + BodyBlock = EntryConditionBlock; // can happen for "for (...;...; ) ;" else if (Block) FinishBlock(BodyBlock); @@ -710,6 +710,7 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) { if (Stmt* C = W->getCond()) { Block = ExitConditionBlock; EntryConditionBlock = addStmt(C); + assert (Block == EntryConditionBlock); if (Block) FinishBlock(EntryConditionBlock); } @@ -739,7 +740,7 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) { CFGBlock* BodyBlock = Visit(W->getBody()); if (!BodyBlock) - BodyBlock = ExitConditionBlock; // can happen for "while(...) ;" + BodyBlock = EntryConditionBlock; // can happen for "while(...) ;" else if (Block) FinishBlock(BodyBlock); @@ -817,7 +818,7 @@ CFGBlock* CFGBuilder::VisitDoStmt(DoStmt* D) { BodyBlock = Visit(D->getBody()); if (!BodyBlock) - BodyBlock = ExitConditionBlock; // can happen for "do ; while(...)" + BodyBlock = EntryConditionBlock; // can happen for "do ; while(...)" else if (Block) FinishBlock(BodyBlock);