diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h index 3f3622149dfe3..1caf4d9291e35 100644 --- a/llvm/include/llvm/BinaryFormat/Dwarf.h +++ b/llvm/include/llvm/BinaryFormat/Dwarf.h @@ -481,6 +481,7 @@ StringRef AtomTypeString(unsigned Atom); StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind); StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage); StringRef IndexString(unsigned Idx); +StringRef FormatString(DwarfFormat Format); /// @} /// \defgroup DwarfConstantsParsing Dwarf constants parsing functions diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp index 30c7e9c311b0c..08ecd77966c3f 100644 --- a/llvm/lib/BinaryFormat/Dwarf.cpp +++ b/llvm/lib/BinaryFormat/Dwarf.cpp @@ -770,6 +770,16 @@ bool llvm::dwarf::isValidFormForVersion(Form F, unsigned Version, return ExtensionsOk; } +StringRef llvm::dwarf::FormatString(DwarfFormat Format) { + switch (Format) { + case DWARF32: + return "DWARF32"; + case DWARF64: + return "DWARF64"; + } + return StringRef(); +} + constexpr char llvm::dwarf::EnumTraits::Type[]; constexpr char llvm::dwarf::EnumTraits
::Type[]; constexpr char llvm::dwarf::EnumTraits::Type[]; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index b6e0d9342cf96..9447ea8a54c42 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -190,7 +190,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts, // version field and the padding, a total of 4 bytes). Add them back in // for reporting. OS << "Contribution size = " << (Contribution->Size + (Version < 5 ? 0 : 4)) - << ", Format = " << (Format == DWARF32 ? "DWARF32" : "DWARF64") + << ", Format = " << dwarf::FormatString(Format) << ", Version = " << Version << "\n"; Offset = Contribution->Base;