]> granicus.if.org Git - clang/commitdiff
Convert incomplete array types before emitting debug info for them, fixes PR3134.
authorAnders Carlsson <andersca@mac.com>
Wed, 26 Nov 2008 17:40:42 +0000 (17:40 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 26 Nov 2008 17:40:42 +0000 (17:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60109 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGen/debug-info.c

index e862808d12ad332fafe86c8ca48e4dcfe4b82fb7..d93bccd2ff21ef3bbb1d26761183e0bd98f341d9 100644 (file)
@@ -515,9 +515,22 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
   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);
 }
index 4a47f6615cdfebc2a6ab322f3a93154c8cc0db86..f5a31631fbadcc6269824a3b4b9140907592e036 100644 (file)
@@ -19,4 +19,6 @@ struct s0 *f0(struct s0 *a0) {
   return a0->p;
 }
   
-  
+// PR3134
+char xpto[];
+