Enhance GRBranchNodeBuilderImpl (part of GRCoreEngine) to understand the case
where the true or false CFGBlock* for a branch could be NULL. This will handle
the case where we can determine during CFG construction that a branch is
infeasible.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76450 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/GRCoreEngine.cpp b/lib/Analysis/GRCoreEngine.cpp
index d55bf6d..5641baa 100644
--- a/lib/Analysis/GRCoreEngine.cpp
+++ b/lib/Analysis/GRCoreEngine.cpp
@@ -452,7 +452,12 @@
 }
 
 ExplodedNodeImpl* GRBranchNodeBuilderImpl::generateNodeImpl(const void* State,
-                                                            bool branch) {  
+                                                            bool branch) {
+  
+  // If the branch has been marked infeasible we should not generate a node.
+  if (!isFeasible(branch))
+    return NULL;
+  
   bool IsNew;
   
   ExplodedNodeImpl* Succ =
@@ -460,8 +465,10 @@
   
   Succ->addPredecessor(Pred);
   
-  if (branch) GeneratedTrue = true;
-  else GeneratedFalse = true;  
+  if (branch)
+    GeneratedTrue = true;
+  else
+    GeneratedFalse = true;  
   
   if (IsNew) {
     Deferred.push_back(Succ);
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index 8a1bd18..97e75fa 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -706,16 +706,20 @@
   }
     
   // Process the true branch.
-  if (const GRState *state = PrevState->assume(V, true))
-    builder.generateNode(MarkBranch(state, Term, true), true);
-  else
-    builder.markInfeasible(true);
+  if (builder.isFeasible(true)) {
+    if (const GRState *state = PrevState->assume(V, true))
+      builder.generateNode(MarkBranch(state, Term, true), true);
+    else
+      builder.markInfeasible(true);
+  }
       
   // Process the false branch.  
-  if (const GRState *state = PrevState->assume(V, false))
-    builder.generateNode(MarkBranch(state, Term, false), false);
-  else
-    builder.markInfeasible(false);
+  if (builder.isFeasible(false)) {
+    if (const GRState *state = PrevState->assume(V, false))
+      builder.generateNode(MarkBranch(state, Term, false), false);
+    else
+      builder.markInfeasible(false);
+  }
 }
 
 /// ProcessIndirectGoto - Called by GRCoreEngine.  Used to generate successor