From: Ted Kremenek Date: Thu, 27 Feb 2014 00:24:03 +0000 (+0000) Subject: [CFG] Encode unreachable block information for successors when visiting 'if' statements. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5610fa2f6a3f7f17667fa78a595489ed87809f46;p=clang [CFG] Encode unreachable block information for successors when visiting 'if' statements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202326 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index 72272c0d34..0251927cc5 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -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