From d39620c45135cf30e964258d6518218438e44f9b Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Mon, 22 Feb 2010 02:59:27 +0000 Subject: [PATCH] Simplify code: Succ is guaranteed to be not NULL. llvm-svn: 96772 --- clang/lib/Analysis/CFG.cpp | 58 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 5b8aeae5d1c5..6b315002a66f 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -264,44 +264,44 @@ CFG* CFGBuilder::buildCFG(const Decl *D, Stmt* Statement, ASTContext* C, if (!B) B = Succ; - if (B) { - // Finalize the last constructed block. This usually involves reversing the - // order of the statements in the block. - if (Block) FinishBlock(B); + assert(B); - // Backpatch the gotos whose label -> block mappings we didn't know when we - // encountered them. - for (BackpatchBlocksTy::iterator I = BackpatchBlocks.begin(), + // 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(), E = BackpatchBlocks.end(); I != E; ++I ) { - CFGBlock* B = *I; - GotoStmt* G = cast(B->getTerminator()); - LabelMapTy::iterator LI = LabelMap.find(G->getLabel()); + CFGBlock* B = *I; + GotoStmt* G = cast(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 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); + } + + // 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); + + // 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); } - // 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); - - // 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); - } - - Succ = B; - } + Succ = B; // Create an empty entry block that has no predecessors. cfg->setEntry(createBlock());