summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-link/llvm-link.cpp
diff options
context:
space:
mode:
authorVivek Pandya <vivekvpandya@gmail.com>2017-09-15 20:10:09 +0000
committerVivek Pandya <vivekvpandya@gmail.com>2017-09-15 20:10:09 +0000
commitb5ab895e2a62486d29e3bc564cc3f2edde3ff719 (patch)
treecdbf913ec72b8076539da7d2a592d930b68c153b /llvm/tools/llvm-link/llvm-link.cpp
parent1dee3be51b77bb29bb7a5293b06f54f29d12d7d0 (diff)
downloadbcm5719-llvm-b5ab895e2a62486d29e3bc564cc3f2edde3ff719.tar.gz
bcm5719-llvm-b5ab895e2a62486d29e3bc564cc3f2edde3ff719.zip
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=32352
It enables OptimizationRemarkEmitter::allowExtraAnalysis and MachineOptimizationRemarkEmitter::allowExtraAnalysis to return true not only for -fsave-optimization-record but when specific remarks are requested with command line options. The diagnostic handler used to be callback now this patch adds a class DiagnosticHandler. It has virtual method to provide custom diagnostic handler and methods to control which particular remarks are enabled. However LLVM-C API users can still provide callback function for diagnostic handler. llvm-svn: 313390
Diffstat (limited to 'llvm/tools/llvm-link/llvm-link.cpp')
-rw-r--r--llvm/tools/llvm-link/llvm-link.cpp45
1 files changed, 25 insertions, 20 deletions
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index 568e5f8d2d5..805ea73b3f6 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -182,25 +182,30 @@ Module &ModuleLazyLoaderCache::operator()(const char *argv0,
}
} // anonymous namespace
-static void diagnosticHandler(const DiagnosticInfo &DI, void *C) {
- unsigned Severity = DI.getSeverity();
- switch (Severity) {
- case DS_Error:
- errs() << "ERROR: ";
- break;
- case DS_Warning:
- if (SuppressWarnings)
- return;
- errs() << "WARNING: ";
- break;
- case DS_Remark:
- case DS_Note:
- llvm_unreachable("Only expecting warnings and errors");
- }
+namespace {
+struct LLVMLinkDiagnosticHandler : public DiagnosticHandler {
+ bool handleDiagnostics(const DiagnosticInfo &DI) override {
+ unsigned Severity = DI.getSeverity();
+ switch (Severity) {
+ case DS_Error:
+ errs() << "ERROR: ";
+ break;
+ case DS_Warning:
+ if (SuppressWarnings)
+ return true;
+ errs() << "WARNING: ";
+ break;
+ case DS_Remark:
+ case DS_Note:
+ llvm_unreachable("Only expecting warnings and errors");
+ }
- DiagnosticPrinterRawOStream DP(errs());
- DI.print(DP);
- errs() << '\n';
+ DiagnosticPrinterRawOStream DP(errs());
+ DI.print(DP);
+ errs() << '\n';
+ return true;
+ }
+};
}
/// Import any functions requested via the -import option.
@@ -347,8 +352,8 @@ int main(int argc, char **argv) {
ExitOnErr.setBanner(std::string(argv[0]) + ": ");
LLVMContext Context;
- Context.setDiagnosticHandler(diagnosticHandler, nullptr, true);
-
+ Context.setDiagnosticHandler(
+ llvm::make_unique<LLVMLinkDiagnosticHandler>(), true);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
OpenPOWER on IntegriCloud