From 87d6393262d22ec17e6b6f6ec1d332589a907d51 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 9 Dec 2016 13:12:30 +0000 Subject: [PATCH] Fix memory leak in unit test. The StringPool entries are destroyed with the allocator, the string pool itself is not. llvm-svn: 289207 --- unittests/DebugInfo/DWARF/DwarfGenerator.cpp | 2 +- unittests/DebugInfo/DWARF/DwarfGenerator.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unittests/DebugInfo/DWARF/DwarfGenerator.cpp b/unittests/DebugInfo/DWARF/DwarfGenerator.cpp index 05039875729..7510bc5415e 100644 --- a/unittests/DebugInfo/DWARF/DwarfGenerator.cpp +++ b/unittests/DebugInfo/DWARF/DwarfGenerator.cpp @@ -203,7 +203,7 @@ llvm::Error dwarfgen::Generator::init(Triple TheTriple, uint16_t V) { MC->setDwarfVersion(Version); Asm->setDwarfVersion(Version); - StringPool = new DwarfStringPool(Allocator, *Asm, StringRef()); + StringPool = llvm::make_unique(Allocator, *Asm, StringRef()); return Error::success(); } diff --git a/unittests/DebugInfo/DWARF/DwarfGenerator.h b/unittests/DebugInfo/DWARF/DwarfGenerator.h index f3d2413be04..966725b4fa4 100644 --- a/unittests/DebugInfo/DWARF/DwarfGenerator.h +++ b/unittests/DebugInfo/DWARF/DwarfGenerator.h @@ -170,9 +170,9 @@ class Generator { MCStreamer *MS; // Owned by AsmPrinter std::unique_ptr TM; std::unique_ptr Asm; - DwarfStringPool *StringPool; // Owned by Allocator - std::vector> CompileUnits; BumpPtrAllocator Allocator; + std::unique_ptr StringPool; // Entries owned by Allocator. + std::vector> CompileUnits; DIEAbbrevSet Abbreviations; SmallString<4096> FileBytes;