[llvm] r238161 - Call the destructors of the MCSections.

David Blaikie dblaikie at gmail.com
Tue May 26 14:28:54 PDT 2015


On Mon, May 25, 2015 at 5:32 PM, Rafael Espindola <
rafael.espindola at gmail.com> wrote:

> Author: rafael
> Date: Mon May 25 19:32:28 2015
> New Revision: 238161
>
> URL: http://llvm.org/viewvc/llvm-project?rev=238161&view=rev
> Log:
> Call the destructors of the MCSections.
>
> They now contain the fragments. If we don't call the destructors the
> fragments leak.
>
> Found by an asan bot.
>
> Modified:
>     llvm/trunk/lib/MC/MCContext.cpp
>
> Modified: llvm/trunk/lib/MC/MCContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=238161&r1=238160&r2=238161&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/MC/MCContext.cpp (original)
> +++ llvm/trunk/lib/MC/MCContext.cpp Mon May 25 19:32:28 2015
> @@ -10,6 +10,7 @@
>  #include "llvm/MC/MCContext.h"
>  #include "llvm/ADT/SmallString.h"
>  #include "llvm/ADT/Twine.h"
> +#include "llvm/MC/MCAssembler.h"
>  #include "llvm/MC/MCAsmInfo.h"
>  #include "llvm/MC/MCDwarf.h"
>  #include "llvm/MC/MCLabel.h"
> @@ -54,6 +55,13 @@ MCContext::MCContext(const MCAsmInfo *ma
>  }
>
>  MCContext::~MCContext() {
> +  // Call the destructors so the fragments are freed
> +  for (auto &I : ELFUniquingMap)
> +    I.second->~MCSectionELF();
>

I'm guessing these aren't actually deleted because they're allocated with a
BumpPtrAllocator or something?


> +  for (auto &I : COFFUniquingMap)
> +    I.second->~MCSectionCOFF();
> +  for (auto &I : MachOUniquingMap)
> +    I.second->~MCSectionMachO();
>
>    if (AutoReset)
>      reset();
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150526/f2a628da/attachment.html>


More information about the llvm-commits mailing list