Always pass a diagnostic handler to the linker.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 4 Dec 2015 22:08:53 +0000 (22:08 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 4 Dec 2015 22:08:53 +0000 (22:08 +0000)
commitc55f4fb8055591bee9ed577794299c0dd3ff791e
tree4cabe5be0abb4bf7da910427bbdd5783a8e0061a
parentcc87069c319aed2f95394a76dccfcd6360c08b80
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
include/llvm/Linker/Linker.h
lib/LTO/LTOCodeGenerator.cpp
lib/Linker/LinkModules.cpp
tools/bugpoint/BugDriver.cpp
tools/bugpoint/Miscompilation.cpp
tools/gold/gold-plugin.cpp
unittests/Linker/LinkModulesTest.cpp