diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-11-01 22:53:18 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-11-01 22:53:18 +0000 |
| commit | d52adb3917397a70b2e0e3d98e719d1b4f263690 (patch) | |
| tree | 0a50da8da348e5173be9c5b33586f82a0e1ede57 /lld/ELF/InputFiles.cpp | |
| parent | 05c03845e7655656ec0f4d3338b722db74120998 (diff) | |
| download | bcm5719-llvm-d52adb3917397a70b2e0e3d98e719d1b4f263690.tar.gz bcm5719-llvm-d52adb3917397a70b2e0e3d98e719d1b4f263690.zip | |
Provide a convenient function to allocate and initialize objects.
You can now write make<T>(Args) instead of new (alloc<T>()) T(Args).
llvm-svn: 285760
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
| -rw-r--r-- | lld/ELF/InputFiles.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index ec8958b898d..6900f8f325d 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -407,8 +407,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 (alloc<InputSection<ELFT>>()) - InputSection<ELFT>(this, &Sec, Name); + return make<InputSection<ELFT>>(this, &Sec, Name); // Find the relocation target section and associate this // section with it. @@ -450,13 +449,11 @@ 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 (alloc<EhInputSection<ELFT>>()) - EhInputSection<ELFT>(this, &Sec, Name); + return make<EhInputSection<ELFT>>(this, &Sec, Name); if (shouldMerge(Sec)) - return new (alloc<MergeInputSection<ELFT>>()) - MergeInputSection<ELFT>(this, &Sec, Name); - return new (alloc<InputSection<ELFT>>()) InputSection<ELFT>(this, &Sec, Name); + return make<MergeInputSection<ELFT>>(this, &Sec, Name); + return make<InputSection<ELFT>>(this, &Sec, Name); } template <class ELFT> void elf::ObjectFile<ELFT>::initializeSymbols() { @@ -825,13 +822,13 @@ static InputFile *createELFFile(MemoryBufferRef MB) { InputFile *Obj; if (Size == ELFCLASS32 && Endian == ELFDATA2LSB) - Obj = new (alloc<T<ELF32LE>>()) T<ELF32LE>(MB); + Obj = make<T<ELF32LE>>(MB); else if (Size == ELFCLASS32 && Endian == ELFDATA2MSB) - Obj = new (alloc<T<ELF32BE>>()) T<ELF32BE>(MB); + Obj = make<T<ELF32BE>>(MB); else if (Size == ELFCLASS64 && Endian == ELFDATA2LSB) - Obj = new (alloc<T<ELF64LE>>()) T<ELF64LE>(MB); + Obj = make<T<ELF64LE>>(MB); else if (Size == ELFCLASS64 && Endian == ELFDATA2MSB) - Obj = new (alloc<T<ELF64BE>>()) T<ELF64BE>(MB); + Obj = make<T<ELF64BE>>(MB); else fatal("invalid file class: " + MB.getBufferIdentifier()); |

