diff options
author | Anders Carlsson <andersca@mac.com> | 2008-11-26 17:40:42 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-11-26 17:40:42 +0000 |
commit | f7a9a923590ea2541fc7b8a5c3003b0bb5c21764 (patch) | |
tree | 84e515e7559b41715e25f67992a8b8c8ce5a99b0 /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | d1ba7908cf79deea840cb2fee082f0dfdcfa0c27 (diff) | |
download | bcm5719-llvm-f7a9a923590ea2541fc7b8a5c3003b0bb5c21764.tar.gz bcm5719-llvm-f7a9a923590ea2541fc7b8a5c3003b0bb5c21764.zip |
Convert incomplete array types before emitting debug info for them, fixes PR3134.
llvm-svn: 60109
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index e862808d12a..d93bccd2ff2 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/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); } |