]> granicus.if.org Git - clang/commitdiff
When building CFGs we now (unconditionally) add an empty CFGBlock to the CFG
authorTed Kremenek <kremenek@apple.com>
Mon, 17 Sep 2007 16:18:02 +0000 (16:18 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 17 Sep 2007 16:18:02 +0000 (16:18 +0000)
to serve as the entry block.  An empty entry block (just as with an
empty exit block, which we already have) simplifies building analyses on top
of CFGs with very little extra overhead.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42031 91177308-0d34-0410-b5e6-96231b3b80d8

AST/CFG.cpp

index 10318f8a710db651982719d408c3aa3668b5d180..42b27d23ab36badaaef7b717feb9c39795fe3d2c 100644 (file)
@@ -175,11 +175,8 @@ CFG* CFGBuilder::buildCFG(Stmt* Statement) {
       }
                                                         
     // Create an empty entry block that has no predecessors.    
-    if (B->pred_size() > 0) {
-      Succ = B;
-      cfg->setEntry(createBlock());
-    }
-    else cfg->setEntry(B);
+    Succ = B;
+    cfg->setEntry(createBlock());
     
     // NULL out cfg so that repeated calls to the builder will fail and that
     // the ownership of the constructed CFG is passed to the caller.
@@ -187,7 +184,10 @@ CFG* CFGBuilder::buildCFG(Stmt* Statement) {
     cfg = NULL;
     return t;
   }
-  else return NULL;
+  else {
+    assert (false && "CFG construction failed.");
+    return NULL;
+  }
 }
   
 /// createBlock - Used to lazily create blocks that are connected