summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/CodeGen/AsmPrinter.h11
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp17
-rw-r--r--tools/dsymutil/DwarfLinker.cpp16
3 files changed, 21 insertions, 23 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h
index 13755ffaa42..f5e778b2f26 100644
--- a/include/llvm/CodeGen/AsmPrinter.h
+++ b/include/llvm/CodeGen/AsmPrinter.h
@@ -453,7 +453,16 @@ public:
void emitCFIInstruction(const MCCFIInstruction &Inst) const;
/// \brief Emit Dwarf abbreviation table.
- void emitDwarfAbbrevs(const std::vector<DIEAbbrev *>& Abbrevs) const;
+ template <typename T> void emitDwarfAbbrevs(const T &Abbrevs) const {
+ // For each abbreviation.
+ for (const auto &Abbrev : Abbrevs)
+ emitDwarfAbbrev(*Abbrev);
+
+ // Mark end of abbreviations.
+ EmitULEB128(0, "EOM(3)");
+ }
+
+ void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const;
/// \brief Recursively emit Dwarf DIE tree.
void emitDwarfDIE(const DIE &Die) const;
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
index 9ede04c4c1b..504c5d283cb 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
@@ -281,17 +281,10 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const {
}
}
-void
-AsmPrinter::emitDwarfAbbrevs(const std::vector<DIEAbbrev *>& Abbrevs) const {
- // For each abbreviation.
- for (const DIEAbbrev *Abbrev : Abbrevs) {
- // Emit the abbreviations code (base 1 index.)
- EmitULEB128(Abbrev->getNumber(), "Abbreviation Code");
-
- // Emit the abbreviations data.
- Abbrev->Emit(this);
- }
+void AsmPrinter::emitDwarfAbbrev(const DIEAbbrev &Abbrev) const {
+ // Emit the abbreviations code (base 1 index.)
+ EmitULEB128(Abbrev.getNumber(), "Abbreviation Code");
- // Mark end of abbreviations.
- EmitULEB128(0, "EOM(3)");
+ // Emit the abbreviations data.
+ Abbrev.Emit(this);
}
diff --git a/tools/dsymutil/DwarfLinker.cpp b/tools/dsymutil/DwarfLinker.cpp
index 33be88c09c2..7ac6f8ed5e3 100644
--- a/tools/dsymutil/DwarfLinker.cpp
+++ b/tools/dsymutil/DwarfLinker.cpp
@@ -519,7 +519,7 @@ public:
/// \brief Emit the abbreviation table \p Abbrevs to the
/// debug_abbrev section.
- void emitAbbrevs(const std::vector<DIEAbbrev *> &Abbrevs);
+ void emitAbbrevs(const std::vector<std::unique_ptr<DIEAbbrev>> &Abbrevs);
/// \brief Emit the string table described by \p Pool.
void emitStrings(const NonRelocatableStringpool &Pool);
@@ -683,7 +683,8 @@ void DwarfStreamer::emitCompileUnitHeader(CompileUnit &Unit) {
/// \brief Emit the \p Abbrevs array as the shared abbreviation table
/// for the linked Dwarf file.
-void DwarfStreamer::emitAbbrevs(const std::vector<DIEAbbrev *> &Abbrevs) {
+void DwarfStreamer::emitAbbrevs(
+ const std::vector<std::unique_ptr<DIEAbbrev>> &Abbrevs) {
MS->SwitchSection(MOFI->getDwarfAbbrevSection());
Asm->emitDwarfAbbrevs(Abbrevs);
}
@@ -1111,11 +1112,6 @@ public:
: OutputFilename(OutputFilename), Options(Options),
BinHolder(Options.Verbose), LastCIEOffset(0) {}
- ~DwarfLinker() {
- for (auto *Abbrev : Abbreviations)
- delete Abbrev;
- }
-
/// \brief Link the contents of the DebugMap.
bool link(const DebugMap &);
@@ -1379,7 +1375,7 @@ private:
/// \brief Storage for the unique Abbreviations.
/// This is passed to AsmPrinter::emitDwarfAbbrevs(), thus it cannot
/// be changed to a vecot of unique_ptrs.
- std::vector<DIEAbbrev *> Abbreviations;
+ std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
/// \brief Compute and emit debug_ranges section for \p Unit, and
/// patch the attributes referencing it.
@@ -2282,10 +2278,10 @@ void DwarfLinker::AssignAbbrev(DIEAbbrev &Abbrev) {
} else {
// Add to abbreviation list.
Abbreviations.push_back(
- new DIEAbbrev(Abbrev.getTag(), Abbrev.hasChildren()));
+ llvm::make_unique<DIEAbbrev>(Abbrev.getTag(), Abbrev.hasChildren()));
for (const auto &Attr : Abbrev.getData())
Abbreviations.back()->AddAttribute(Attr.getAttribute(), Attr.getForm());
- AbbreviationsSet.InsertNode(Abbreviations.back(), InsertToken);
+ AbbreviationsSet.InsertNode(Abbreviations.back().get(), InsertToken);
// Assign the unique abbreviation number.
Abbrev.setNumber(Abbreviations.size());
Abbreviations.back()->setNumber(Abbreviations.size());