From: Ted Kremenek Date: Wed, 1 Apr 2009 03:52:47 +0000 (+0000) Subject: CFG: For 'if(...) {}' (empty body) construct an empty CFGBlock so that we can X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbdf7949a7a50f5a65055a3e95f6432ecc541056;p=clang CFG: For 'if(...) {}' (empty body) construct an empty CFGBlock so that we can distinguish between the true and false branches for path-sensitive analyses. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68185 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/CFG.cpp b/lib/AST/CFG.cpp index fc893d5b64..cd07aacbff 100644 --- a/lib/AST/CFG.cpp +++ b/lib/AST/CFG.cpp @@ -605,8 +605,13 @@ CFGBlock* CFGBuilder::VisitIfStmt(IfStmt* I) { Block = NULL; ThenBlock = Visit(Then); - if (!ThenBlock) // Can occur when the Then body has all NullStmts. - ThenBlock = sv.get(); + if (!ThenBlock) { + // We can reach here if the "then" body has all NullStmts. + // Create an empty block so we can distinguish between true and false + // branches in path-sensitive analyses. + ThenBlock = createBlock(false); + ThenBlock->addSuccessor(sv.get()); + } else if (Block) FinishBlock(ThenBlock); }