]> granicus.if.org Git - clang/commitdiff
[CFG] Encode unreachable block information for successors when visiting 'if' statements.
authorTed Kremenek <kremenek@apple.com>
Thu, 27 Feb 2014 00:24:03 +0000 (00:24 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 27 Feb 2014 00:24:03 +0000 (00:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202326 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFG.cpp

index 72272c0d34f1fc64148e0b8f27603e42e7715522..0251927cc53ae002f832729c311b7061d0a32cb7 100644 (file)
@@ -1880,9 +1880,10 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
   // See if this is a known constant.
   const TryResult &KnownVal = tryEvaluateBool(I->getCond());
 
-  // Now add the successors.
-  addSuccessor(Block, KnownVal.isFalse() ? NULL : ThenBlock);
-  addSuccessor(Block, KnownVal.isTrue()? NULL : ElseBlock);
+  // Add the successors.  If we know that specific branches are
+  // unreachable, inform addSuccessor() of that knowledge.
+  addSuccessor(Block, ThenBlock, /* isReachable = */ !KnownVal.isFalse());
+  addSuccessor(Block, ElseBlock, /* isReachable = */ !KnownVal.isTrue());
 
   // Add the condition as the last statement in the new block.  This may create
   // new blocks as the condition may contain control-flow.  Any newly created