From: Daniel Sanders Date: Sat, 23 Feb 2019 03:25:37 +0000 (+0000) Subject: Try again to fix memory leak in r354692 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e4774ebc0b6cacab0b537de32453c8436a97bd1;p=llvm Try again to fix memory leak in r354692 The previous one didn't fix everything. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354719 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/CodeGen/TargetOptionsTest.cpp b/unittests/CodeGen/TargetOptionsTest.cpp index 70ef5e13c1e..6b4d3eda7ee 100644 --- a/unittests/CodeGen/TargetOptionsTest.cpp +++ b/unittests/CodeGen/TargetOptionsTest.cpp @@ -1,4 +1,5 @@ #include "llvm/Target/TargetOptions.h" +#include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/Support/TargetRegistry.h" @@ -43,7 +44,6 @@ std::unique_ptr createTargetMachine(bool EnableIPRA) { typedef std::function TargetOptionsTest; static void targetOptionsTest(bool EnableIPRA) { - LLVMContext Context; std::unique_ptr TM = createTargetMachine(EnableIPRA); // This test is designed for the X86 backend; stop if it is not available. if (!TM) @@ -51,10 +51,12 @@ static void targetOptionsTest(bool EnableIPRA) { legacy::PassManager PM; LLVMTargetMachine *LLVMTM = static_cast(TM.get()); - TargetPassConfig &TPC = *LLVMTM->createPassConfig(PM); + TargetPassConfig *TPC = LLVMTM->createPassConfig(PM); (void)TPC; ASSERT_TRUE(TM->Options.EnableIPRA == EnableIPRA); + + delete TPC; } } // End of anonymous namespace.