diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-12-14 23:17:03 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-12-14 23:17:03 +0000 |
commit | 7a1fc2d33e22333b6ebe8f1ef2f6c14ad82bd114 (patch) | |
tree | e1e664377457567029f570b7483288082199f350 /unittests/Linker | |
parent | 265bc7dab126aadfb12f7ea40f25ae0bf85cff33 (diff) |
Use diagnostic handler in the LLVMContext
This patch converts code that has access to a LLVMContext to not take a
diagnostic handler.
This has a few advantages
* It is easier to use a consistent diagnostic handler in a single program.
* Less clutter since we are not passing a handler around.
It does make it a bit awkward to implement some C APIs that return a
diagnostic string. I will propose new versions of these APIs and
deprecate the current ones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Linker')
-rw-r--r-- | unittests/Linker/LinkModulesTest.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/unittests/Linker/LinkModulesTest.cpp b/unittests/Linker/LinkModulesTest.cpp index e56a692125ec..ba8f4798172f 100644 --- a/unittests/Linker/LinkModulesTest.cpp +++ b/unittests/Linker/LinkModulesTest.cpp @@ -71,7 +71,9 @@ protected: BasicBlock *ExitBB; }; -static void expectNoDiags(const DiagnosticInfo &DI) { EXPECT_TRUE(false); } +static void expectNoDiags(const DiagnosticInfo &DI, void *C) { + EXPECT_TRUE(false); +} TEST_F(LinkModuleTest, BlockAddress) { IRBuilder<> Builder(EntryBB); @@ -95,7 +97,8 @@ TEST_F(LinkModuleTest, BlockAddress) { Builder.CreateRet(ConstantPointerNull::get(Type::getInt8PtrTy(Ctx))); Module *LinkedModule = new Module("MyModuleLinked", Ctx); - Linker::linkModules(*LinkedModule, *M, expectNoDiags); + Ctx.setDiagnosticHandler(expectNoDiags); + Linker::linkModules(*LinkedModule, *M); // Delete the original module. M.reset(); @@ -171,13 +174,15 @@ static Module *getInternal(LLVMContext &Ctx) { TEST_F(LinkModuleTest, EmptyModule) { std::unique_ptr<Module> InternalM(getInternal(Ctx)); std::unique_ptr<Module> EmptyM(new Module("EmptyModule1", Ctx)); - Linker::linkModules(*EmptyM, *InternalM, expectNoDiags); + Ctx.setDiagnosticHandler(expectNoDiags); + Linker::linkModules(*EmptyM, *InternalM); } TEST_F(LinkModuleTest, EmptyModule2) { std::unique_ptr<Module> InternalM(getInternal(Ctx)); std::unique_ptr<Module> EmptyM(new Module("EmptyModule1", Ctx)); - Linker::linkModules(*InternalM, *EmptyM, expectNoDiags); + Ctx.setDiagnosticHandler(expectNoDiags); + Linker::linkModules(*InternalM, *EmptyM); } TEST_F(LinkModuleTest, TypeMerge) { @@ -192,7 +197,8 @@ TEST_F(LinkModuleTest, TypeMerge) { "@t2 = weak global %t zeroinitializer\n"; std::unique_ptr<Module> M2 = parseAssemblyString(M2Str, Err, C); - Linker::linkModules(*M1, *M2, [](const llvm::DiagnosticInfo &) {}); + Ctx.setDiagnosticHandler(expectNoDiags); + Linker::linkModules(*M1, *M2); EXPECT_EQ(M1->getNamedGlobal("t1")->getType(), M1->getNamedGlobal("t2")->getType()); @@ -269,7 +275,8 @@ TEST_F(LinkModuleTest, MoveDistinctMDs) { // Link into destination module. auto Dst = llvm::make_unique<Module>("Linked", C); ASSERT_TRUE(Dst.get()); - Linker::linkModules(*Dst, *Src, [](const llvm::DiagnosticInfo &) {}); + Ctx.setDiagnosticHandler(expectNoDiags); + Linker::linkModules(*Dst, *Src); // Check that distinct metadata was moved, not cloned. Even !4, the uniqued // node, should effectively be moved, since its only operand hasn't changed. |