aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CFG.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-02-22 05:58:59 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-02-22 05:58:59 +0000
commitc3daac59e26b63c08208de2fbaceb1ff01be3492 (patch)
tree9048688a58f82c58c6a94e4ca4cc1c86950a190b /lib/Analysis/CFG.cpp
parent44b713938266685b1b1dd452a672f9f21b6060f8 (diff)
Revert "Simplify code: Succ is guaranteed to be not NULL.", which turns out to
not be guaranteed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96782 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFG.cpp')
-rw-r--r--lib/Analysis/CFG.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 6b315002a6..5b8aeae5d1 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -264,44 +264,44 @@ CFG* CFGBuilder::buildCFG(const Decl *D, Stmt* Statement, ASTContext* C,
if (!B)
B = Succ;
- assert(B);
-
- // Finalize the last constructed block. This usually involves reversing the
- // order of the statements in the block.
- FinishBlock(B);
-
- // Backpatch the gotos whose label -> block mappings we didn't know when we
- // encountered them.
- for (BackpatchBlocksTy::iterator I = BackpatchBlocks.begin(),
+ if (B) {
+ // Finalize the last constructed block. This usually involves reversing the
+ // order of the statements in the block.
+ if (Block) FinishBlock(B);
+
+ // Backpatch the gotos whose label -> block mappings we didn't know when we
+ // encountered them.
+ for (BackpatchBlocksTy::iterator I = BackpatchBlocks.begin(),
E = BackpatchBlocks.end(); I != E; ++I ) {
- CFGBlock* B = *I;
- GotoStmt* G = cast<GotoStmt>(B->getTerminator());
- LabelMapTy::iterator LI = LabelMap.find(G->getLabel());
+ CFGBlock* B = *I;
+ GotoStmt* G = cast<GotoStmt>(B->getTerminator());
+ LabelMapTy::iterator LI = LabelMap.find(G->getLabel());
- // If there is no target for the goto, then we are looking at an
- // incomplete AST. Handle this by not registering a successor.
- if (LI == LabelMap.end()) continue;
+ // If there is no target for the goto, then we are looking at an
+ // incomplete AST. Handle this by not registering a successor.
+ if (LI == LabelMap.end()) continue;
- AddSuccessor(B, LI->second);
- }
+ AddSuccessor(B, LI->second);
+ }
- // Add successors to the Indirect Goto Dispatch block (if we have one).
- if (CFGBlock* B = cfg->getIndirectGotoBlock())
- for (LabelSetTy::iterator I = AddressTakenLabels.begin(),
+ // Add successors to the Indirect Goto Dispatch block (if we have one).
+ if (CFGBlock* B = cfg->getIndirectGotoBlock())
+ for (LabelSetTy::iterator I = AddressTakenLabels.begin(),
E = AddressTakenLabels.end(); I != E; ++I ) {
- // Lookup the target block.
- LabelMapTy::iterator LI = LabelMap.find(*I);
+ // Lookup the target block.
+ LabelMapTy::iterator LI = LabelMap.find(*I);
- // If there is no target block that contains label, then we are looking
- // at an incomplete AST. Handle this by not registering a successor.
- if (LI == LabelMap.end()) continue;
+ // If there is no target block that contains label, then we are looking
+ // at an incomplete AST. Handle this by not registering a successor.
+ if (LI == LabelMap.end()) continue;
- AddSuccessor(B, LI->second);
- }
+ AddSuccessor(B, LI->second);
+ }
- Succ = B;
+ Succ = B;
+ }
// Create an empty entry block that has no predecessors.
cfg->setEntry(createBlock());