diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-08-17 20:59:56 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-08-17 20:59:56 +0000 |
commit | 110974dfa4cbf1f89934df337de1bf2a7fe177fd (patch) | |
tree | c0de2d2ed485caa445ee7cd724412a6ce4425f59 /clang/lib/Analysis/CFG.cpp | |
parent | e0db9d01d9acc6ae0536d2151d69193ad9961d4b (diff) | |
download | bcm5719-llvm-110974dfa4cbf1f89934df337de1bf2a7fe177fd.tar.gz bcm5719-llvm-110974dfa4cbf1f89934df337de1bf2a7fe177fd.zip |
CFGBuilder: don't create the empty "loop back" block for DoStmts if the loop edge can never be taken.
llvm-svn: 111282
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index f8f26f61075..1d5d8521ad5 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -1476,18 +1476,22 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt* D) { return 0; } - // Add an intermediate block between the BodyBlock and the - // ExitConditionBlock to represent the "loop back" transition. Create an - // empty block to represent the transition block for looping back to the - // head of the loop. - // FIXME: Can we do this more efficiently without adding another block? - Block = NULL; - Succ = BodyBlock; - CFGBlock *LoopBackBlock = createBlock(); - LoopBackBlock->setLoopTarget(D); - - // Add the loop body entry as a successor to the condition. - AddSuccessor(ExitConditionBlock, KnownVal.isFalse() ? NULL : LoopBackBlock); + if (!KnownVal.isFalse()) { + // Add an intermediate block between the BodyBlock and the + // ExitConditionBlock to represent the "loop back" transition. Create an + // empty block to represent the transition block for looping back to the + // head of the loop. + // FIXME: Can we do this more efficiently without adding another block? + Block = NULL; + Succ = BodyBlock; + CFGBlock *LoopBackBlock = createBlock(); + LoopBackBlock->setLoopTarget(D); + + // Add the loop body entry as a successor to the condition. + AddSuccessor(ExitConditionBlock, LoopBackBlock); + } + else + AddSuccessor(ExitConditionBlock, NULL); } // Link up the condition block with the code that follows the loop. |