DebugInfo: Gut DIDescriptor
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfUnit.cpp
index 46f3eb3201dc6fbadd56fe91b7561c0806571901..9154652987724c94b5c5330ad1d987a6bd99b7e1 100644 (file)
@@ -1405,9 +1405,10 @@ void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, DICompositeType CTy) {
   // Add subranges to array type.
   DIArray Elements = CTy->getElements();
   for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
-    DIDescriptor Element = Elements[i];
-    if (Element.getTag() == dwarf::DW_TAG_subrange_type)
-      constructSubrangeDIE(Buffer, cast<MDSubrange>(Element), IdxTy);
+    // FIXME: Should this really be such a loose cast?
+    if (auto *Element = dyn_cast_or_null<DebugNode>(Elements[i]))
+      if (Element->getTag() == dwarf::DW_TAG_subrange_type)
+        constructSubrangeDIE(Buffer, cast<MDSubrange>(Element), IdxTy);
   }
 }