From 13085edf46866b2e036bebb7ef94b9fe53569265 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Tue, 29 Apr 2014 15:52:27 +0000 Subject: [PATCH] LinkModulesTest.cpp: Use test-specific Ctx instead of getGlobalContext(). The global context might not be free'd. [vg_leak] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207535 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Linker/LinkModulesTest.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/unittests/Linker/LinkModulesTest.cpp b/unittests/Linker/LinkModulesTest.cpp index 7b40b9f6721..ab383b464ca 100644 --- a/unittests/Linker/LinkModulesTest.cpp +++ b/unittests/Linker/LinkModulesTest.cpp @@ -22,7 +22,6 @@ namespace { class LinkModuleTest : public testing::Test { protected: virtual void SetUp() { - LLVMContext &Ctx = getGlobalContext(); M.reset(new Module("MyModule", Ctx)); FunctionType *FTy = FunctionType::get(Type::getInt8PtrTy(Ctx), Type::getInt32Ty(Ctx), @@ -62,6 +61,7 @@ protected: M.reset(); } + LLVMContext Ctx; std::unique_ptr M; Function *F; GlobalVariable *GV; @@ -72,7 +72,6 @@ protected: }; TEST_F(LinkModuleTest, BlockAddress) { - LLVMContext &Ctx = getGlobalContext(); IRBuilder<> Builder(EntryBB); std::vector GEPIndices; @@ -93,7 +92,7 @@ TEST_F(LinkModuleTest, BlockAddress) { Builder.SetInsertPoint(ExitBB); Builder.CreateRet(ConstantPointerNull::get(Type::getInt8PtrTy(Ctx))); - Module *LinkedModule = new Module("MyModuleLinked", getGlobalContext()); + Module *LinkedModule = new Module("MyModuleLinked", Ctx); Linker::LinkModules(LinkedModule, M.get(), Linker::PreserveSource, 0); // Delete the original module. @@ -129,7 +128,6 @@ TEST_F(LinkModuleTest, BlockAddress) { } TEST_F(LinkModuleTest, EmptyModule) { - LLVMContext &Ctx = getGlobalContext(); Module *InternalM = new Module("InternalModule", Ctx); FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx), Type::getInt8PtrTy(Ctx), -- 2.34.1