diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-01 03:52:47 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-01 03:52:47 +0000 |
commit | 1b37951f36ebd296711b0c8050f28346a7d3d615 (patch) | |
tree | 74ddaf7fff0ab95915557b76c2d050d6627274d8 | |
parent | 2ec6e8e2baa4e4c686de780f94bcdc00772efbba (diff) | |
download | bcm5719-llvm-1b37951f36ebd296711b0c8050f28346a7d3d615.tar.gz bcm5719-llvm-1b37951f36ebd296711b0c8050f28346a7d3d615.zip |
CFG: For 'if(...) {}' (empty body) construct an empty CFGBlock so that we can
distinguish between the true and false branches for path-sensitive analyses.
llvm-svn: 68185
-rw-r--r-- | clang/lib/AST/CFG.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/AST/CFG.cpp b/clang/lib/AST/CFG.cpp index fc893d5b649..cd07aacbffc 100644 --- a/clang/lib/AST/CFG.cpp +++ b/clang/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); } |