Fix memory leak in unit test.
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 9 Dec 2016 13:12:30 +0000 (13:12 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 9 Dec 2016 13:12:30 +0000 (13:12 +0000)
The StringPool entries are destroyed with the allocator, the string pool
itself is not.

llvm-svn: 289207

llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h

index 0503987..7510bc5 100644 (file)
@@ -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<DwarfStringPool>(Allocator, *Asm, StringRef());
 
   return Error::success();
 }
index f3d2413..966725b 100644 (file)
@@ -170,9 +170,9 @@ class Generator {
   MCStreamer *MS;     // Owned by AsmPrinter
   std::unique_ptr<TargetMachine> TM;
   std::unique_ptr<AsmPrinter> Asm;
-  DwarfStringPool *StringPool; // Owned by Allocator
-  std::vector<std::unique_ptr<CompileUnit>> CompileUnits;
   BumpPtrAllocator Allocator;
+  std::unique_ptr<DwarfStringPool> StringPool; // Entries owned by Allocator.
+  std::vector<std::unique_ptr<CompileUnit>> CompileUnits;
   DIEAbbrevSet Abbreviations;
 
   SmallString<4096> FileBytes;