[CFG] Encode unreachable block information for successors when visiting 'if' statements.

llvm-svn: 202326
This commit is contained in:
Ted Kremenek 2014-02-27 00:24:03 +00:00
parent 4b6fee6cc4
commit f389861052
1 changed files with 4 additions and 3 deletions

View 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