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

Differential Revision: https://reviews.llvm.org/D80523
This commit is contained in:
Igor Kudrin 2020-06-02 12:16:51 +07:00
parent b596ecdd57
commit 5e296e3db7
3 changed files with 12 additions and 1 deletions

View File

@ -481,6 +481,7 @@ StringRef AtomTypeString(unsigned Atom);
StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind); StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind);
StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage); StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
StringRef IndexString(unsigned Idx); StringRef IndexString(unsigned Idx);
StringRef FormatString(DwarfFormat Format);
/// @} /// @}
/// \defgroup DwarfConstantsParsing Dwarf constants parsing functions /// \defgroup DwarfConstantsParsing Dwarf constants parsing functions

View File

@ -770,6 +770,16 @@ bool llvm::dwarf::isValidFormForVersion(Form F, unsigned Version,
return ExtensionsOk; 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<Attribute>::Type[];
constexpr char llvm::dwarf::EnumTraits<Form>::Type[]; constexpr char llvm::dwarf::EnumTraits<Form>::Type[];
constexpr char llvm::dwarf::EnumTraits<Index>::Type[]; constexpr char llvm::dwarf::EnumTraits<Index>::Type[];

View File

@ -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 // version field and the padding, a total of 4 bytes). Add them back in
// for reporting. // for reporting.
OS << "Contribution size = " << (Contribution->Size + (Version < 5 ? 0 : 4)) OS << "Contribution size = " << (Contribution->Size + (Version < 5 ? 0 : 4))
<< ", Format = " << (Format == DWARF32 ? "DWARF32" : "DWARF64") << ", Format = " << dwarf::FormatString(Format)
<< ", Version = " << Version << "\n"; << ", Version = " << Version << "\n";
Offset = Contribution->Base; Offset = Contribution->Base;