summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2013-08-08 07:40:37 +0000
committerEric Christopher <echristo@gmail.com>2013-08-08 07:40:37 +0000
commit0df08e2ff91200a1fff3a1b6be0be9e592b22b41 (patch)
treeb571c73cb5920711c801a129c6c1cdaa3193f7f2 /llvm/lib/CodeGen
parentafb2c4114ea92b7f50c8f5f69fe3c85a2c7d773b (diff)
downloadbcm5719-llvm-0df08e2ff91200a1fff3a1b6be0be9e592b22b41.tar.gz
bcm5719-llvm-0df08e2ff91200a1fff3a1b6be0be9e592b22b41.zip
Make sure that if we're going to attempt to add a type to a DIE that
the type exists. Fix up cases where we weren't checking for optional types and add an assert to addType to make sure we catch this in the future. Fix up a testcase that was using the tag for DW_TAG_array_type when it meant DW_TAG_enumeration_type. llvm-svn: 187963
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 0c9bc23a9e4..2937b9019c2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -776,8 +776,7 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
/// addType - Add a new type attribute to the specified entity.
void CompileUnit::addType(DIE *Entity, DIType Ty, uint16_t Attribute) {
- if (!Ty.isType())
- return;
+ assert(Ty && "Trying to add a type that doesn't exist?");
// Check for pre-existence.
DIEEntry *Entry = getDIEEntry(Ty);
@@ -863,7 +862,8 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) {
// Map to main type, void will not have a type.
DIType FromTy = DTy.getTypeDerivedFrom();
- addType(&Buffer, FromTy);
+ if (FromTy)
+ addType(&Buffer, FromTy);
// Add name if not anonymous or intermediate type.
if (!Name.empty())
@@ -947,10 +947,11 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
}
break;
case dwarf::DW_TAG_subroutine_type: {
- // Add return type.
+ // Add return type. A void return won't have a type.
DIArray Elements = CTy.getTypeArray();
DIDescriptor RTy = Elements.getElement(0);
- addType(&Buffer, DIType(RTy));
+ if (RTy)
+ addType(&Buffer, DIType(RTy));
bool isPrototyped = true;
// Add arguments.
@@ -1137,7 +1138,11 @@ CompileUnit::getOrCreateTemplateValueParameterDIE(DITemplateValueParameter VP) {
return ParamDIE;
ParamDIE = new DIE(VP.getTag());
- addType(ParamDIE, VP.getType());
+
+ // Add the type if there is one, template template and template parameter
+ // packs will not have a type.
+ if (VP.getType())
+ addType(ParamDIE, VP.getType());
if (!VP.getName().empty())
addString(ParamDIE, dwarf::DW_AT_name, VP.getName());
if (Value *Val = VP.getValue()) {
@@ -1246,13 +1251,14 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
Language == dwarf::DW_LANG_ObjC))
addFlag(SPDie, dwarf::DW_AT_prototyped);
- // Add Return Type.
+ // Add Return Type. A void return type will not have a type.
DICompositeType SPTy = SP.getType();
assert(SPTy.getTag() == dwarf::DW_TAG_subroutine_type &&
"the type of a subprogram should be a subroutine");
DIArray Args = SPTy.getTypeArray();
- addType(SPDie, DIType(Args.getElement(0)));
+ if (Args.getElement(0))
+ addType(SPDie, DIType(Args.getElement(0)));
unsigned VK = SP.getVirtuality();
if (VK) {
@@ -1502,9 +1508,8 @@ void CompileUnit::constructArrayTypeDIE(DIE &Buffer,
if (CTy->isVector())
addFlag(&Buffer, dwarf::DW_AT_GNU_vector);
- // Emit derived type.
+ // Emit the element type.
addType(&Buffer, CTy->getTypeDerivedFrom());
- DIArray Elements = CTy->getTypeArray();
// Get an anonymous type for index type.
// FIXME: This type should be passed down from the front end
@@ -1522,6 +1527,7 @@ void CompileUnit::constructArrayTypeDIE(DIE &Buffer,
}
// Add subranges to array type.
+ DIArray Elements = CTy->getTypeArray();
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
DIDescriptor Element = Elements.getElement(i);
if (Element.getTag() == dwarf::DW_TAG_subrange_type)
OpenPOWER on IntegriCloud