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 | 6196aa06c9d5a6c6446f4dc1d6154852fdd42bca (patch) | |
| tree | 4e805c30e4ea00ef1bcd06aca19c868de3c6691d /llvm/tools | |
| parent | a21af73c41443b76ad9f13ab56f13d269f60bfc4 (diff) | |
| download | bcm5719-llvm-6196aa06c9d5a6c6446f4dc1d6154852fdd42bca.tar.gz bcm5719-llvm-6196aa06c9d5a6c6446f4dc1d6154852fdd42bca.zip  | |
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))
llvm-svn: 253409
Diffstat (limited to 'llvm/tools')
| -rw-r--r-- | llvm/tools/dsymutil/DwarfLinker.cpp | 16 | 
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp index 33be88c09c2..7ac6f8ed5e3 100644 --- a/llvm/tools/dsymutil/DwarfLinker.cpp +++ b/llvm/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());  | 

