From: Anders Carlsson Date: Wed, 26 Nov 2008 17:40:42 +0000 (+0000) Subject: Convert incomplete array types before emitting debug info for them, fixes PR3134. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4d6e8dd587f6ae0080b0d3acc9ac6a6a02b1ac3b;p=clang 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 e862808d12..d93bccd2ff 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -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); } diff --git a/test/CodeGen/debug-info.c b/test/CodeGen/debug-info.c index 4a47f6615c..f5a31631fb 100644 --- a/test/CodeGen/debug-info.c +++ b/test/CodeGen/debug-info.c @@ -19,4 +19,6 @@ struct s0 *f0(struct s0 *a0) { return a0->p; } - +// PR3134 +char xpto[]; +