From eac71e23fdf56fd8a908d15c30d846ba50145489 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 26 May 2015 01:52:19 +0000 Subject: [PATCH] Move MCSection destruction to MCContext::reset. Fixes the leaks when running llc. Also found by an asan bot. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238167 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCContext.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index 0a453cdb46b..1f2f034a3ac 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -55,14 +55,6 @@ MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri, } MCContext::~MCContext() { - // Call the destructors so the fragments are freed - for (auto &I : ELFUniquingMap) - I.second->~MCSectionELF(); - for (auto &I : COFFUniquingMap) - I.second->~MCSectionCOFF(); - for (auto &I : MachOUniquingMap) - I.second->~MCSectionMachO(); - if (AutoReset) reset(); @@ -78,6 +70,14 @@ MCContext::~MCContext() { //===----------------------------------------------------------------------===// void MCContext::reset() { + // Call the destructors so the fragments are freed + for (auto &I : ELFUniquingMap) + I.second->~MCSectionELF(); + for (auto &I : COFFUniquingMap) + I.second->~MCSectionCOFF(); + for (auto &I : MachOUniquingMap) + I.second->~MCSectionMachO(); + UsedNames.clear(); Symbols.clear(); Allocator.Reset(); -- 2.34.1