[lld] r264097 - Fix operator= on OwningAtomPtr to call destructor when needed.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 14:08:40 PDT 2016

Author: pete
Date: Tue Mar 22 16:08:39 2016
New Revision: 264097

URL: http://llvm.org/viewvc/llvm-project?rev=264097&view=rev
Fix operator= on OwningAtomPtr to call destructor when needed.

If the LHS of 'a = b' already had an atom in it then we wouldn't
call the destructor.  This happens when we use something like
std::remove_if which is done in the CompactUnwindPass.  Should fix
the leaks on the mach-o/unwind-info-simple-x86_64.yaml test case.

Lang and I are going to take a look at removing OwningAtomPtr in
favour of a std::unique_ptr but just trying to get the bots green
so we have a good baseline first.


Modified: lld/trunk/include/lld/Core/Atom.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Atom.h?rev=264097&r1=264096&r2=264097&view=diff
--- lld/trunk/include/lld/Core/Atom.h (original)
+++ lld/trunk/include/lld/Core/Atom.h Tue Mar 22 16:08:39 2016
@@ -100,6 +100,8 @@ public:
   void operator=(OwningAtomPtr&& ptr) {
+    if (atom)
+      runDestructor(atom);
     atom = ptr.atom;
     ptr.atom = nullptr;

More information about the llvm-commits mailing list