[llvm] 11e0b79 - llvm-dwarfdump: Don't print even an empty string when a type is unprintable
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 19 17:04:43 PDT 2021
Author: David Blaikie
Date: 2021-09-19T17:03:10-07:00
New Revision: 11e0b79b056a5f1ba1feb81872aee67709f34834
URL: https://github.com/llvm/llvm-project/commit/11e0b79b056a5f1ba1feb81872aee67709f34834
DIFF: https://github.com/llvm/llvm-project/commit/11e0b79b056a5f1ba1feb81872aee67709f34834.diff
LOG: llvm-dwarfdump: Don't print even an empty string when a type is unprintable
Added:
Modified:
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/test/tools/llvm-dwarfdump/X86/verify_debug_info.s
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index fe7377b08027..1f161580204c 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<uint64_t> 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 1536c455208b..b3e5c77091ca 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]
More information about the llvm-commits
mailing list