[llvm] 5e296e3 - [DebugInfo] Extract a helper function to return the DWARF format name, NFC [1/10]

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 2 03:57:04 PDT 2020


Author: Igor Kudrin
Date: 2020-06-02T17:55:30+07:00
New Revision: 5e296e3db710ea34c535f9f6a4dd3973ba8d3f74

URL: https://github.com/llvm/llvm-project/commit/5e296e3db710ea34c535f9f6a4dd3973ba8d3f74
DIFF: https://github.com/llvm/llvm-project/commit/5e296e3db710ea34c535f9f6a4dd3973ba8d3f74.diff

LOG: [DebugInfo] Extract a helper function to return the DWARF format name, NFC [1/10]

Differential Revision: https://reviews.llvm.org/D80523

Added: 
    

Modified: 
    llvm/include/llvm/BinaryFormat/Dwarf.h
    llvm/lib/BinaryFormat/Dwarf.cpp
    llvm/lib/DebugInfo/DWARF/DWARFContext.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h
index 3f3622149dfe..1caf4d9291e3 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 30c7e9c311b0..08ecd77966c3 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<Attribute>::Type[];
 constexpr char llvm::dwarf::EnumTraits<Form>::Type[];
 constexpr char llvm::dwarf::EnumTraits<Index>::Type[];

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index b6e0d9342cf9..9447ea8a54c4 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;


        


More information about the llvm-commits mailing list