llvm-project/lld/lib/Core
Pete Cooper 8ad55fb2d0 Use owning pointers instead of raw pointers for Atom's to fix leaks.
This is a re-commit of r264022 with a fix for MSVC.  The issue there was
that the code was running DefinedAtom::~Atom() for some value and instead
needed to cast to Atom before running ~Atom.  Original commit message follows.

Currently each File contains an BumpPtrAllocator in which Atom's are
allocated.  Some Atom's contain data structures like std::vector which
leak as we don't run ~Atom when they are BumpPtrAllocate'd.

Now each File actually owns its Atom's using an OwningAtomPtr.  This
is analygous to std::unique_ptr and may be replaced by it if possible.

An Atom can therefore only be owned by a single File, so the Resolver now
moves them from one File to another.  The MachOLinkingContext owns the File's
and so clears all the Atom's in ~MachOLinkingContext, then delete's all the
File's.  This makes sure all Atom's have been destructed before any of the
BumpPtrAllocator's in which they run have gone away.

Should hopefully fix the remaining leaks.  Will keep an eye on the bots to
make sure.

llvm-svn: 264067
2016-03-22 17:15:50 +00:00
..
CMakeLists.txt Set CMake ADDITIONAL_HEADER_DIRS on libraries with headers in /include. NFC. 2016-01-07 00:14:09 +00:00
DefinedAtom.cpp Delete more ELF bits from the old linker. 2016-02-28 16:03:37 +00:00
Error.cpp Remove dead code. This error type is for the old linker script reader. 2016-02-28 02:51:02 +00:00
File.cpp Use owning pointers instead of raw pointers for Atom's to fix leaks. 2016-03-22 17:15:50 +00:00
LinkingContext.cpp Use C++11 initializers for data members. 2016-03-02 01:49:27 +00:00
Reader.cpp Delete more ELF bits from the old linker. 2016-02-28 16:03:37 +00:00
Resolver.cpp Use owning pointers instead of raw pointers for Atom's to fix leaks. 2016-03-22 17:15:50 +00:00
SymbolTable.cpp Remove dead code for ELF. 2016-02-28 21:59:02 +00:00
Writer.cpp Replace the `createImplicitFiles` method return type with `void` 2015-04-06 20:43:35 +00:00