Skip to content

Commit

Permalink
Fixed CFG construction bug that occurred when a condition for a loop …
Browse files Browse the repository at this point in the history
…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.

llvm-svn: 47649
  • Loading branch information
tkremenek committed Feb 27, 2008
1 parent ae2b6fb commit 39321aa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions clang/AST/CFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 39321aa

Please sign in to comment.