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
This commit is contained in:
Rafael Espindola 2015-05-26 01:52:19 +00:00
parent 1826cd69f3
commit eac71e23fd

View File

@ -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();