Teach GRExprEngine to handle the initialization of the condition variable of a SwitchStmt.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92102 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index ceefea8..d7486f8 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -665,7 +665,7 @@
     case Stmt::IfStmtClass:
       // This case isn't for branch processing, but for handling the
       // initialization of a condition variable.
-      VisitIfStmtCondInit(cast<IfStmt>(S), Pred, Dst);
+      VisitCondInit(cast<IfStmt>(S)->getConditionVariable(), S, Pred, Dst);
       break;
 
     case Stmt::InitListExprClass:
@@ -733,6 +733,12 @@
     case Stmt::StringLiteralClass:
       VisitLValue(cast<StringLiteral>(S), Pred, Dst);
       break;
+      
+    case Stmt::SwitchStmtClass:
+      // This case isn't for branch processing, but for handling the
+      // initialization of a condition variable.
+      VisitCondInit(cast<SwitchStmt>(S)->getConditionVariable(), S, Pred, Dst);
+      break;
 
     case Stmt::UnaryOperatorClass: {
       UnaryOperator *U = cast<UnaryOperator>(S);
@@ -2230,12 +2236,10 @@
   }
 }
 
-void GRExprEngine::VisitIfStmtCondInit(IfStmt *IS, ExplodedNode *Pred,
-                                       ExplodedNodeSet& Dst) {
+void GRExprEngine::VisitCondInit(VarDecl *VD, Stmt *S,
+                                 ExplodedNode *Pred, ExplodedNodeSet& Dst) {
   
-  VarDecl* VD = IS->getConditionVariable();
-  Expr* InitEx = VD->getInit();
-  
+  Expr* InitEx = VD->getInit();  
   ExplodedNodeSet Tmp;
   Visit(InitEx, Pred, Tmp);
 
@@ -2255,7 +2259,7 @@
                                             Builder->getCurrentBlockCount());
     }
       
-    EvalBind(Dst, IS, IS, N, state,
+    EvalBind(Dst, S, S, N, state,
              loc::MemRegionVal(state->getRegion(VD, LC)), InitVal, true);
   }
 }