From 167a9c5cb44393c7bca7bddb47883b93f26284d2 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 16 Jun 2023 23:21:44 +0200 Subject: [PATCH] Fix DWARF debug information emitted for empty enum (#433) --- llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp | 7 +++++++ llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h | 1 + llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp index 6eeb797db57228..5ecf7fe2bbe548 100644 --- a/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp @@ -59,6 +59,13 @@ void Dump(MCObjectStreamer *Streamer, uint16_t DwarfVersion, unsigned TargetPoin dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, 0, 0, + EnumerationTypeNoChildren, + dwarf::DW_TAG_enumeration_type, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, + 0, 0, + Enumerator1, dwarf::DW_TAG_enumerator, dwarf::DW_CHILDREN_no, dwarf::DW_AT_name, dwarf::DW_FORM_strp, diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h index 448123c99a92d7..ce447ac64d1f90 100644 --- a/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h @@ -21,6 +21,7 @@ enum DwarfAbbrev : uint16_t CompileUnit = 0x1, BaseType, EnumerationType, + EnumerationTypeNoChildren, Enumerator1, Enumerator2, Enumerator4, diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp b/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp index ff4ab03e6c9bb1..ba0007c93a9cb5 100644 --- a/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp @@ -282,7 +282,7 @@ void DwarfEnumTypeInfo::DumpStrings(MCObjectStreamer *Streamer) { void DwarfEnumTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { // Abbrev Number - Streamer->emitULEB128IntValue(DwarfAbbrev::EnumerationType); + Streamer->emitULEB128IntValue(HasChildren() ? DwarfAbbrev::EnumerationType : DwarfAbbrev::EnumerationTypeNoChildren); // DW_AT_name EmitSectionOffset(Streamer, StrSymbol, 4);