Convert incomplete array types before emitting debug info for them, fixes PR3134.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60109 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index e862808..d93bccd 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -515,9 +515,22 @@
   uint64_t LineNo = SM.getLogicalLineNumber(Decl->getLocation());
 
   std::string Name = Decl->getNameAsString();
-  
+
+  QualType T = Decl->getType();
+  if (T->isIncompleteArrayType()) {
+    
+    // CodeGen turns int[] into int[1] so we'll do the same here.
+    llvm::APSInt ConstVal(32);
+    
+    ConstVal = 1;
+    QualType ET = M->getContext().getAsArrayType(T)->getElementType();
+    
+    T = M->getContext().getConstantArrayType(ET, ConstVal, 
+                                           ArrayType::Normal, 0);
+  }
+
   DebugFactory.CreateGlobalVariable(Unit, Name, Name, "", Unit, LineNo,
-                                    getOrCreateType(Decl->getType(), Unit),
+                                    getOrCreateType(T, Unit),
                                     Var->hasInternalLinkage(),
                                     true/*definition*/, Var);
 }