From 95642b95bd4268260816370de8fea3e86e285f11 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 1 Nov 2016 23:09:07 +0000 Subject: [PATCH] Remove Out::Pool and use make() instead. llvm-svn: 285763 --- lld/ELF/LinkerScript.cpp | 3 +-- lld/ELF/OutputSections.cpp | 14 +++++++------- lld/ELF/OutputSections.h | 7 ------- lld/ELF/Writer.cpp | 1 - 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 6e7b7756c825..b51cf80ca004 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -543,8 +543,7 @@ template void LinkerScript::adjustSectionsBeforeSorting() { continue; } - auto *OutSec = new OutputSection(Cmd->Name, Type, Flags); - Out::Pool.emplace_back(OutSec); + auto *OutSec = make>(Cmd->Name, Type, Flags); OutputSections->push_back(OutSec); } } diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 9be3b3b9f4ae..131aff520e84 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -10,8 +10,9 @@ #include "OutputSections.h" #include "Config.h" #include "EhFrame.h" -#include "LinkerScript.h" #include "GdbIndex.h" +#include "LinkerScript.h" +#include "Memory.h" #include "Strings.h" #include "SymbolTable.h" #include "Target.h" @@ -1881,24 +1882,23 @@ OutputSectionFactory::create(const SectionKey &Key, uint32_t Type = C->Type; switch (C->kind()) { case InputSectionBase::Regular: - Sec = new OutputSection(Key.Name, Type, Flags); + Sec = make>(Key.Name, Type, Flags); break; case InputSectionBase::EHFrame: return {Out::EhFrame, false}; case InputSectionBase::Merge: - Sec = new MergeOutputSection(Key.Name, Type, Flags, Key.Alignment); + Sec = make>(Key.Name, Type, Flags, Key.Alignment); break; case InputSectionBase::MipsReginfo: - Sec = new MipsReginfoOutputSection(); + Sec = make>(); break; case InputSectionBase::MipsOptions: - Sec = new MipsOptionsOutputSection(); + Sec = make>(); break; case InputSectionBase::MipsAbiFlags: - Sec = new MipsAbiFlagsOutputSection(); + Sec = make>(); break; } - Out::Pool.emplace_back(Sec); return {Sec, true}; } diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index 2e039d09861e..36cbf4e3a0a8 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -773,9 +773,6 @@ template struct Out { static OutputSectionBase *PreinitArray; static OutputSectionBase *InitArray; static OutputSectionBase *FiniArray; - - // This pool owns dynamically-allocated output sections. - static std::vector>> Pool; }; template struct SectionKey { @@ -842,10 +839,6 @@ template OutputSectionBase *Out::ProgramHeaders; template OutputSectionBase *Out::PreinitArray; template OutputSectionBase *Out::InitArray; template OutputSectionBase *Out::FiniArray; - -template -std::vector>> Out::Pool; - } // namespace elf } // namespace lld diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 2c0057a8e942..2f9dc419c489 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -247,7 +247,6 @@ template void elf::writeResult() { In::Sections = {BuildId.get()}; Writer().run(); - Out::Pool.clear(); } template static std::vector getCommonSymbols() {