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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187963 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp
index a6f1c34..fc93249 100644
--- a/lib/IR/DebugInfo.cpp
+++ b/lib/IR/DebugInfo.cpp
@@ -483,6 +483,12 @@
if (!fieldIsMDNode(DbgNode, 12))
return false;
+ // If this is an array type verify that we have a DIType in the derived type
+ // field as that's the type of our element.
+ if (getTag() == dwarf::DW_TAG_array_type)
+ if (!DIType(getTypeDerivedFrom()))
+ return false;
+
return DbgNode->getNumOperands() >= 10 && DbgNode->getNumOperands() <= 14;
}