[cfe-commits] r60109 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp test/CodeGen/debug-info.c
Anders Carlsson
andersca at mac.com
Wed Nov 26 09:40:43 PST 2008
Author: andersca
Date: Wed Nov 26 11:40:42 2008
New Revision: 60109
URL: http://llvm.org/viewvc/llvm-project?rev=60109&view=rev
Log:
Convert incomplete array types before emitting debug info for them, fixes PR3134.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGen/debug-info.c
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=60109&r1=60108&r2=60109&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Nov 26 11:40:42 2008
@@ -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);
}
Modified: cfe/trunk/test/CodeGen/debug-info.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info.c?rev=60109&r1=60108&r2=60109&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/debug-info.c (original)
+++ cfe/trunk/test/CodeGen/debug-info.c Wed Nov 26 11:40:42 2008
@@ -19,4 +19,6 @@
return a0->p;
}
-
+// PR3134
+char xpto[];
+
More information about the cfe-commits
mailing list