Handle the case in VisitInitListExprs where there are no initializers in the compound literal.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58468 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index c8d4722..9995a39 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -1637,23 +1637,30 @@
 
 void GRExprEngine::VisitInitListExpr(InitListExpr* E, NodeTy* Pred, 
                                      NodeSet& Dst) {
+
   const GRState* state = GetState(Pred);
-
   QualType T = E->getType();
-
   unsigned NumInitElements = E->getNumInits();  
 
   if (T->isArrayType() || T->isStructureType()) {
 
-
-    llvm::SmallVector<InitListWLItem, 10> WorkList;
-    WorkList.reserve(NumInitElements);
-  
-    WorkList.push_back(InitListWLItem(Pred, getBasicVals().getEmptySValList(),
-                              E->rbegin()));
+    llvm::ImmutableList<SVal> StartVals = getBasicVals().getEmptySValList();
     
+    // Handle base case where the initializer has no elements.
+    // e.g: static int* myArray[] = {};
+    if (NumInitElements == 0) {
+      SVal V = NonLoc::MakeCompoundVal(T, StartVals, getBasicVals());
+      MakeNode(Dst, E, Pred, BindExpr(state, E, V));
+      return;
+    }      
+    
+    // Create a worklist to process the initializers.
+    llvm::SmallVector<InitListWLItem, 10> WorkList;
+    WorkList.reserve(NumInitElements);  
+    WorkList.push_back(InitListWLItem(Pred, StartVals, E->rbegin()));    
     InitListExpr::reverse_iterator ItrEnd = E->rend();
     
+    // Process the worklist until it is empty.
     while (!WorkList.empty()) {
       InitListWLItem X = WorkList.back();
       WorkList.pop_back();