diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-12-04 22:08:53 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-12-04 22:08:53 +0000 |
commit | f49a38fc0887baac3a21ecebf8d13b7e416ac2c6 (patch) | |
tree | 7dfeace7a0801214395aeac03256f92c28c19dce /llvm/tools/bugpoint/BugDriver.cpp | |
parent | 8213072a453bcb012b31d231dae4f44a589ddd52 (diff) | |
download | bcm5719-llvm-f49a38fc0887baac3a21ecebf8d13b7e416ac2c6.tar.gz bcm5719-llvm-f49a38fc0887baac3a21ecebf8d13b7e416ac2c6.zip |
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.
llvm-svn: 254777
Diffstat (limited to 'llvm/tools/bugpoint/BugDriver.cpp')
-rw-r--r-- | llvm/tools/bugpoint/BugDriver.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/tools/bugpoint/BugDriver.cpp b/llvm/tools/bugpoint/BugDriver.cpp index 39887d5d59d..9edc242d470 100644 --- a/llvm/tools/bugpoint/BugDriver.cpp +++ b/llvm/tools/bugpoint/BugDriver.cpp @@ -15,6 +15,7 @@ #include "BugDriver.h" #include "ToolRunner.h" +#include "llvm/IR/DiagnosticPrinter.h" #include "llvm/IR/Module.h" #include "llvm/IR/Verifier.h" #include "llvm/IRReader/IRReader.h" @@ -112,6 +113,12 @@ std::unique_ptr<Module> llvm::parseInputFile(StringRef Filename, return Result; } +static void diagnosticHandler(const DiagnosticInfo &DI) { + DiagnosticPrinterRawOStream DP(errs()); + DI.print(DP); + errs() << '\n'; +} + // This method takes the specified list of LLVM input files, attempts to load // them, either as assembly or bitcode, then link them together. It returns // true on failure (if, for example, an input bitcode file could not be @@ -132,7 +139,7 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) { if (!M.get()) return true; outs() << "Linking in input file: '" << Filenames[i] << "'\n"; - if (Linker::linkModules(*Program, *M)) + if (Linker::linkModules(*Program, *M, diagnosticHandler)) return true; } |