Make it easier to pass a custom diagnostic handler to the IR linker.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220732 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-10-27 23:02:10 +00:00
parent 68aeef61f4
commit 0660f174cf
3 changed files with 46 additions and 32 deletions

View File

@ -71,11 +71,12 @@ loadFile(const char *argv0, const std::string &FN, LLVMContext &Context) {
return Result;
}
static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) {
static void diagnosticHandler(const DiagnosticInfo &DI) {
unsigned Severity = DI.getSeverity();
switch (Severity) {
case DS_Error:
errs() << "ERROR: ";
break;
case DS_Warning:
if (SuppressWarnings)
return;
@ -88,6 +89,7 @@ static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) {
DiagnosticPrinterRawOStream DP(errs());
DI.print(DP);
errs() << '\n';
}
int main(int argc, char **argv) {
@ -100,9 +102,8 @@ int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
auto Composite = make_unique<Module>("llvm-link", Context);
Linker L(Composite.get());
Linker L(Composite.get(), diagnosticHandler);
Context.setDiagnosticHandler(diagnosticHandler);
for (unsigned i = 0; i < InputFilenames.size(); ++i) {
std::unique_ptr<Module> M = loadFile(argv[0], InputFilenames[i], Context);
if (!M.get()) {