]> granicus.if.org Git - clang/commitdiff
CFG: For 'if(...) {}' (empty body) construct an empty CFGBlock so that we can
authorTed Kremenek <kremenek@apple.com>
Wed, 1 Apr 2009 03:52:47 +0000 (03:52 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 1 Apr 2009 03:52:47 +0000 (03:52 +0000)
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

lib/AST/CFG.cpp

index fc893d5b649a3c647274b94c7826e86604d621fb..cd07aacbffc96e7512ac94ce716e671ef78bebaa 100644 (file)
@@ -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);
   }