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 | 9d2bfc48741a5c0c3a3eb455959a627afcc3b722 (patch) | |
tree | fe5cca4dadc85dbb69e9636da588d269ba63b92c /llvm/tools/llvm-link/llvm-link.cpp | |
parent | 2cb8a51c1f771437a0207c4c71e2d6273a4a3550 (diff) | |
download | bcm5719-llvm-9d2bfc48741a5c0c3a3eb455959a627afcc3b722.tar.gz bcm5719-llvm-9d2bfc48741a5c0c3a3eb455959a627afcc3b722.zip |
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.
llvm-svn: 255571
Diffstat (limited to 'llvm/tools/llvm-link/llvm-link.cpp')
-rw-r--r-- | llvm/tools/llvm-link/llvm-link.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp index 6f90f4056f7..8030f4c9037 100644 --- a/llvm/tools/llvm-link/llvm-link.cpp +++ b/llvm/tools/llvm-link/llvm-link.cpp @@ -141,6 +141,10 @@ static void diagnosticHandler(const DiagnosticInfo &DI) { errs() << '\n'; } +static void diagnosticHandlerWithContext(const DiagnosticInfo &DI, void *C) { + diagnosticHandler(DI); +} + /// Import any functions requested via the -import option. static bool importFunctions(const char *argv0, LLVMContext &Context, Linker &L) { @@ -265,11 +269,13 @@ int main(int argc, char **argv) { PrettyStackTraceProgram X(argc, argv); LLVMContext &Context = getGlobalContext(); + Context.setDiagnosticHandler(diagnosticHandlerWithContext, nullptr, true); + llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. cl::ParseCommandLineOptions(argc, argv, "llvm linker\n"); auto Composite = make_unique<Module>("llvm-link", Context); - Linker L(*Composite, diagnosticHandler); + Linker L(*Composite); unsigned Flags = Linker::Flags::None; if (Internalize) |