[cfe-commits] r96772 - /cfe/trunk/lib/Analysis/CFG.cpp

Zhongxing Xu xuzhongxing at gmail.com
Sun Feb 21 18:59:27 PST 2010


Author: zhongxingxu
Date: Sun Feb 21 20:59:27 2010
New Revision: 96772

URL: http://llvm.org/viewvc/llvm-project?rev=96772&view=rev
Log:
Simplify code: Succ is guaranteed to be not NULL.

Modified:
    cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=96772&r1=96771&r2=96772&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Sun Feb 21 20:59:27 2010
@@ -264,44 +264,44 @@
   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);
-
-    // Backpatch the gotos whose label -> block mappings we didn't know when we
-    // encountered them.
-    for (BackpatchBlocksTy::iterator I = BackpatchBlocks.begin(),
+  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(),
          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());





More information about the cfe-commits mailing list