From 5e296e3db710ea34c535f9f6a4dd3973ba8d3f74 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 2 Jun 2020 12:16:51 +0700 Subject: [PATCH] [DebugInfo] Extract a helper function to return the DWARF format name, NFC [1/10] Differential Revision: https://reviews.llvm.org/D80523 --- llvm/include/llvm/BinaryFormat/Dwarf.h | 1 + llvm/lib/BinaryFormat/Dwarf.cpp | 10 ++++++++++ llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h index 3f36221..1caf4d9 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 30c7e9c..08ecd77 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 b6e0d93..9447ea8 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; -- 2.7.4