diff options
author | David Blaikie <dblaikie@gmail.com> | 2015-11-18 00:34:10 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2015-11-18 00:34:10 +0000 |
commit | be1cec0cb76bf6c56145dc9c33761bbc46eee89d (patch) | |
tree | beb46bf18f90e6f5430e9833f841782fed1fa379 /tools | |
parent | 9f7d480d96ac557ce52b525968f63f9906485cd9 (diff) |
Generalize ownership/passing semantics to allow dsymutil to own abbreviations via unique_ptr
While still allowing CodeGen/AsmPrinter in llvm to own them using a bump
ptr allocator. (might be nice to replace the pointers there with
something that at least automatically calls their dtors, if that's
necessary/useful, rather than having it done explicitly (I think a typed
BumpPtrAllocator already does this, or maybe a unique_ptr with a custom
deleter, etc))
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253409 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/dsymutil/DwarfLinker.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
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()); |