summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-11-01 21:06:40 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-11-01 21:06:40 +0000
commit5c9e8f5e528704e6533a44f86acd542c80dec31b (patch)
tree44e0a347dfd917d5c735564268f07bd73ebd7338 /lld/ELF/InputFiles.cpp
parent7fc4f5083809a1c139ac3650641709d32cb556aa (diff)
downloadbcm5719-llvm-5c9e8f5e528704e6533a44f86acd542c80dec31b.tar.gz
bcm5719-llvm-5c9e8f5e528704e6533a44f86acd542c80dec31b.zip
Replace GAlloc with a template function.
This patch replaces GAlloc<ELFT>::<sometype>.Allocate() with alloc<sometype<ELFT>>(). Patch by Rui! llvm-svn: 285748
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
-rw-r--r--lld/ELF/InputFiles.cpp27
1 files changed, 8 insertions, 19 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index dadf3bbebc4..041b41fd2d9 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -35,7 +35,6 @@ using namespace llvm::sys::fs;
using namespace lld;
using namespace lld::elf;
-std::vector<InputFile *> InputFile::Pool;
namespace {
// In ELF object file all section addresses are zero. If we have multiple
@@ -97,15 +96,6 @@ std::string DIHelper<ELFT>::getLineInfo(InputSectionBase<ELFT> *S,
: "";
}
-// Deletes all InputFile instances created so far.
-void InputFile::freePool() {
- // Files are freed in reverse order so that files created
- // from other files (e.g. object files extracted from archives)
- // are freed in the proper order.
- for (int I = Pool.size() - 1; I >= 0; --I)
- delete Pool[I];
-}
-
// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
std::string elf::getFilename(const InputFile *F) {
if (!F)
@@ -415,7 +405,7 @@ elf::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec) {
// If -r is given, we do not interpret or apply relocation
// but just copy relocation sections to output.
if (Config->Relocatable)
- return new (GAlloc<ELFT>::IAlloc.Allocate())
+ return new (alloc<InputSection<ELFT>>())
InputSection<ELFT>(this, &Sec, Name);
// Find the relocation target section and associate this
@@ -458,14 +448,13 @@ elf::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec) {
// .eh_frame_hdr section for runtime. So we handle them with a special
// class. For relocatable outputs, they are just passed through.
if (Name == ".eh_frame" && !Config->Relocatable)
- return new (GAlloc<ELFT>::EHAlloc.Allocate())
+ return new (alloc<EhInputSection<ELFT>>())
EhInputSection<ELFT>(this, &Sec, Name);
if (shouldMerge(Sec))
- return new (GAlloc<ELFT>::MAlloc.Allocate())
+ return new (alloc<MergeInputSection<ELFT>>())
MergeInputSection<ELFT>(this, &Sec, Name);
- return new (GAlloc<ELFT>::IAlloc.Allocate())
- InputSection<ELFT>(this, &Sec, Name);
+ return new (alloc<InputSection<ELFT>>()) InputSection<ELFT>(this, &Sec, Name);
}
template <class ELFT> void elf::ObjectFile<ELFT>::initializeSymbols() {
@@ -834,13 +823,13 @@ static InputFile *createELFFile(MemoryBufferRef MB) {
InputFile *Obj;
if (Size == ELFCLASS32 && Endian == ELFDATA2LSB)
- Obj = new T<ELF32LE>(MB);
+ Obj = new (alloc<T<ELF32LE>>()) T<ELF32LE>(MB);
else if (Size == ELFCLASS32 && Endian == ELFDATA2MSB)
- Obj = new T<ELF32BE>(MB);
+ Obj = new (alloc<T<ELF32BE>>()) T<ELF32BE>(MB);
else if (Size == ELFCLASS64 && Endian == ELFDATA2LSB)
- Obj = new T<ELF64LE>(MB);
+ Obj = new (alloc<T<ELF64LE>>()) T<ELF64LE>(MB);
else if (Size == ELFCLASS64 && Endian == ELFDATA2MSB)
- Obj = new T<ELF64BE>(MB);
+ Obj = new (alloc<T<ELF64BE>>()) T<ELF64BE>(MB);
else
fatal("invalid file class: " + MB.getBufferIdentifier());
OpenPOWER on IntegriCloud