forked from OSchip/llvm-project
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. llvm-svn: 47649
This commit is contained in:
parent
ae2b6fbb8e
commit
39321aa199
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue