summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp42
1 files changed, 12 insertions, 30 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index 2bde3d6d034..3b9662067c3 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -15,6 +15,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DJB.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/raw_ostream.h"
#include <cstddef>
@@ -24,35 +25,19 @@
using namespace llvm;
namespace {
-struct DwarfConstant {
- StringRef (*StringFn)(unsigned);
- StringRef Type;
+struct Atom {
unsigned Value;
};
-static raw_ostream &operator<<(raw_ostream &OS, const DwarfConstant &C) {
- StringRef Str = C.StringFn(C.Value);
+static raw_ostream &operator<<(raw_ostream &OS, const Atom &A) {
+ StringRef Str = dwarf::AtomTypeString(A.Value);
if (!Str.empty())
return OS << Str;
- return OS << "DW_" << C.Type << "_Unknown_0x" << format("%x", C.Value);
+ return OS << "DW_ATOM_unknown_" << format("%x", A.Value);
}
} // namespace
-static DwarfConstant formatTag(unsigned Tag) {
- return {dwarf::TagString, "TAG", Tag};
-}
-
-static DwarfConstant formatForm(unsigned Form) {
- return {dwarf::FormEncodingString, "FORM", Form};
-}
-
-static DwarfConstant formatIndex(unsigned Idx) {
- return {dwarf::IndexString, "IDX", Idx};
-}
-
-static DwarfConstant formatAtom(unsigned Atom) {
- return {dwarf::AtomTypeString, "ATOM", Atom};
-}
+static Atom formatAtom(unsigned Atom) { return {Atom}; }
DWARFAcceleratorTable::~DWARFAcceleratorTable() = default;
@@ -226,7 +211,7 @@ LLVM_DUMP_METHOD void AppleAcceleratorTable::dump(raw_ostream &OS) const {
for (const auto &Atom : HdrData.Atoms) {
DictScope AtomScope(W, ("Atom " + Twine(i++)).str());
W.startLine() << "Type: " << formatAtom(Atom.first) << '\n';
- W.startLine() << "Form: " << formatForm(Atom.second) << '\n';
+ W.startLine() << "Form: " << formatv("{0}", Atom.second) << '\n';
AtomForms.push_back(DWARFFormValue(Atom.second));
}
}
@@ -415,12 +400,10 @@ llvm::Error DWARFDebugNames::Header::extract(const DWARFDataExtractor &AS,
void DWARFDebugNames::Abbrev::dump(ScopedPrinter &W) const {
DictScope AbbrevScope(W, ("Abbreviation 0x" + Twine::utohexstr(Code)).str());
- W.startLine() << "Tag: " << formatTag(Tag) << '\n';
+ W.startLine() << formatv("Tag: {0}\n", Tag);
- for (const auto &Attr : Attributes) {
- W.startLine() << formatIndex(Attr.Index) << ": " << formatForm(Attr.Form)
- << '\n';
- }
+ for (const auto &Attr : Attributes)
+ W.startLine() << formatv("{0}: {1}\n", Attr.Index, Attr.Form);
}
static constexpr DWARFDebugNames::AttributeEncoding sentinelAttrEnc() {
@@ -583,11 +566,10 @@ Optional<uint64_t> DWARFDebugNames::Entry::getDIESectionOffset() const {
void DWARFDebugNames::Entry::dump(ScopedPrinter &W) const {
W.printHex("Abbrev", Abbr->Code);
- W.startLine() << "Tag: " << formatTag(Abbr->Tag) << "\n";
-
+ W.startLine() << formatv("Tag: {0}\n", Abbr->Tag);
assert(Abbr->Attributes.size() == Values.size());
for (const auto &Tuple : zip_first(Abbr->Attributes, Values)) {
- W.startLine() << formatIndex(std::get<0>(Tuple).Index) << ": ";
+ W.startLine() << formatv("{0}: ", std::get<0>(Tuple).Index);
std::get<1>(Tuple).dump(W.getOStream());
W.getOStream() << '\n';
}
OpenPOWER on IntegriCloud