diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp index fe7377b080271..1f161580204cc 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -374,15 +374,11 @@ struct DWARFTypePrinter { } /// Recursively append the DIE type name when applicable. - void appendUnqualifiedName(const DWARFDie &D, - bool SkipFirstParamIfArtificial = false) { - if (!D.isValid() || D.isNULL()) - return; - + void appendUnqualifiedName(const DWARFDie &D) { // FIXME: We should have pretty printers per language. Currently we print // everything as if it was C++ and fall back to the TAG type name. DWARFDie Inner = appendUnqualifiedNameBefore(D); - appendUnqualifiedNameAfter(D, Inner, SkipFirstParamIfArtificial); + appendUnqualifiedNameAfter(D, Inner); } void appendSubroutineNameAfter(DWARFDie D, DWARFDie Inner, @@ -546,10 +542,12 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die, DINameKind::LinkageName)) OS << Space << "\"" << Name << '\"'; } else if (Attr == DW_AT_type) { - OS << Space << "\""; - DWARFTypePrinter(OS).appendQualifiedName( - Die.getAttributeValueAsReferencedDie(FormValue)); - OS << '"'; + DWARFDie D = Die.getAttributeValueAsReferencedDie(FormValue); + if (D && !D.isNULL()) { + OS << Space << "\""; + DWARFTypePrinter(OS).appendQualifiedName(D); + OS << '"'; + } } else if (Attr == DW_AT_APPLE_property_attribute) { if (Optional OptVal = FormValue.getAsUnsignedConstant()) dumpApplePropertyAttribute(OS, *OptVal); diff --git a/llvm/test/tools/llvm-dwarfdump/X86/verify_debug_info.s b/llvm/test/tools/llvm-dwarfdump/X86/verify_debug_info.s index 1536c455208b7..b3e5c77091ca3 100644 --- a/llvm/test/tools/llvm-dwarfdump/X86/verify_debug_info.s +++ b/llvm/test/tools/llvm-dwarfdump/X86/verify_debug_info.s @@ -20,7 +20,7 @@ # CHECK-NEXT: DW_AT_decl_file [DW_FORM_data1] (0x01) # CHECK-NEXT: DW_AT_decl_line [DW_FORM_data1] (1) # CHECK-NEXT: DW_AT_prototyped [DW_FORM_flag_present] (true) -# CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x0052 => {0x00000052} "") +# CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x0052 => {0x00000052}) # CHECK-NEXT: DW_AT_external [DW_FORM_flag_present] (true){{[[:space:]]}} # CHECK-NEXT: error: DIE has DW_AT_type with incompatible tag DW_TAG_null{{[[:space:]]}} # CHECK-NEXT: 0x0000002b: DW_TAG_subprogram [2] * @@ -31,7 +31,7 @@ # CHECK-NEXT: DW_AT_decl_file [DW_FORM_data1] (0x01) # CHECK-NEXT: DW_AT_decl_line [DW_FORM_data1] (1) # CHECK-NEXT: DW_AT_prototyped [DW_FORM_flag_present] (true) -# CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x0052 => {0x00000052} "") +# CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x0052 => {0x00000052}) # CHECK-NEXT: DW_AT_external [DW_FORM_flag_present] (true){{[[:space:]]}} # CHECK-NEXT: error: DIE has DW_AT_decl_file that references a file with index 1 and the compile unit has no line table{{[[:space:]]}} # CHECK-NEXT: 0x00000044: DW_TAG_variable [3]