[CodeGen] IncompleteArray Support 

Added code to support ArrayType that is not ConstantArray.

https://reviews.llvm.org/D49952
rdar://42476155

llvm-svn: 339207
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 6876647..651b05a 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1968,6 +1968,16 @@
       Elts.push_back(C);
     }
 
+    // This means that the array type is probably "IncompleteType" or some
+    // type that is not ConstantArray.
+    if (CAT == nullptr && CommonElementType == nullptr && !NumInitElts) {
+      const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
+      CommonElementType = CGM.getTypes().ConvertType(AT->getElementType());
+      llvm::ArrayType *AType = llvm::ArrayType::get(CommonElementType,
+                                                    NumElements);
+      return llvm::ConstantAggregateZero::get(AType);
+    }
+
     return EmitArrayConstant(CGM, CAT, CommonElementType, NumElements, Elts,
                              Filler);
   }