From: Ted Kremenek Date: Mon, 17 Sep 2007 16:18:02 +0000 (+0000) Subject: When building CFGs we now (unconditionally) add an empty CFGBlock to the CFG X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=94b3316ee37743cb60bf552d5616b03d17e277da;p=clang When building CFGs we now (unconditionally) add an empty CFGBlock to the CFG 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 --- diff --git a/AST/CFG.cpp b/AST/CFG.cpp index 10318f8a71..42b27d23ab 100644 --- a/AST/CFG.cpp +++ b/AST/CFG.cpp @@ -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