summaryrefslogtreecommitdiffstats
path: root/unittests/Linker
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-12-04 22:08:53 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-12-04 22:08:53 +0000
commitc55f4fb8055591bee9ed577794299c0dd3ff791e (patch)
tree4cabe5be0abb4bf7da910427bbdd5783a8e0061a /unittests/Linker
parentcc87069c319aed2f95394a76dccfcd6360c08b80 (diff)
Always pass a diagnostic handler to the linker.
Before this patch the diagnostic handler was optional. If it was not passed, the one in the LLVMContext was used. That is probably not a pattern we want to follow. If each area has an optional callback, there is a sea of callbacks and it is hard to follow which one is called. Doing this also found cases where the callback is a nice addition, like testing that no errors or warnings are reported. The other option is to always use the diagnostic handler in the LLVMContext. That has a few problems * To implement the C API we would have to set the diag handler and then set it back to the original value. * Code that creates the context might be far away from code that wants the diagnostics. I do have a patch that implements the second option and will send that as an RFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254777 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Linker')
-rw-r--r--unittests/Linker/LinkModulesTest.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/unittests/Linker/LinkModulesTest.cpp b/unittests/Linker/LinkModulesTest.cpp
index 4eba718e2663..e56a692125ec 100644
--- a/unittests/Linker/LinkModulesTest.cpp
+++ b/unittests/Linker/LinkModulesTest.cpp
@@ -71,6 +71,8 @@ protected:
BasicBlock *ExitBB;
};
+static void expectNoDiags(const DiagnosticInfo &DI) { EXPECT_TRUE(false); }
+
TEST_F(LinkModuleTest, BlockAddress) {
IRBuilder<> Builder(EntryBB);
@@ -93,7 +95,7 @@ TEST_F(LinkModuleTest, BlockAddress) {
Builder.CreateRet(ConstantPointerNull::get(Type::getInt8PtrTy(Ctx)));
Module *LinkedModule = new Module("MyModuleLinked", Ctx);
- Linker::linkModules(*LinkedModule, *M);
+ Linker::linkModules(*LinkedModule, *M, expectNoDiags);
// Delete the original module.
M.reset();
@@ -169,13 +171,13 @@ 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);
+ Linker::linkModules(*EmptyM, *InternalM, expectNoDiags);
}
TEST_F(LinkModuleTest, EmptyModule2) {
std::unique_ptr<Module> InternalM(getInternal(Ctx));
std::unique_ptr<Module> EmptyM(new Module("EmptyModule1", Ctx));
- Linker::linkModules(*InternalM, *EmptyM);
+ Linker::linkModules(*InternalM, *EmptyM, expectNoDiags);
}
TEST_F(LinkModuleTest, TypeMerge) {