[ELF] Simplify adding default atoms
authorSimon Atanasyan <simon@atanasyan.com>
Tue, 7 Apr 2015 20:11:38 +0000 (20:11 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Tue, 7 Apr 2015 20:11:38 +0000 (20:11 +0000)
commit64e36b67e2808134e28aeb30fcfe2f7efb117dbd
tree496bb08c0b663f6270f6a852167f079a39ff3edc
parentf1853c65d99e72c212a8ca048e609876168cb0ff
[ELF] Simplify adding default atoms

Now 'writer' creates an instance of `RuntimeFile` in the constructor, then
populates the file in the virtual function `addDefaultAtoms`, then pass
owning of this file to the caller of virtual function `createImplicitFiles`.

First, we do not need to keep an instance of `RuntimeFile` so long. It is
enough to create the file, right after that populate it and pass the owning.

Second, relationship between `createImplicitFiles` and `addDefaultAtoms`
is complicated. The `createImplicitFiles` might call `addDefaultAtoms`,
overridden version of `addDefaultAtoms` might call base class `addDefaultAtoms`,
and overridden version of `createImplicitFiles` might call base class
`createImplicitFiles` as well as `addDefaultAtoms`.

The patch solves both problems above. It creates and populates runtime files
right in the createImplicitFiles(), removes `addDefaultAtoms` at all and
does not keep references to runtime files in class fields.

llvm-svn: 234347
12 files changed:
lld/lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h
lld/lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.h
lld/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h
lld/lib/ReaderWriter/ELF/DynamicLibraryWriter.h
lld/lib/ReaderWriter/ELF/ExecutableWriter.h
lld/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h
lld/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h
lld/lib/ReaderWriter/ELF/OutputELFWriter.h
lld/lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h
lld/lib/ReaderWriter/ELF/X86/X86ExecutableWriter.h
lld/lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h
lld/lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h