diff options
| author | Vivek Pandya <vivekvpandya@gmail.com> | 2017-09-15 19:30:59 +0000 |
|---|---|---|
| committer | Vivek Pandya <vivekvpandya@gmail.com> | 2017-09-15 19:30:59 +0000 |
| commit | 00d887447b05bd41ec77a897978bace2af287154 (patch) | |
| tree | 7cbf2055a7483fff1223c6c911d64c2a0a9c704b /llvm/lib/IR/LLVMContext.cpp | |
| parent | aff1c4df2573db4c21143c990db268d85350fd54 (diff) | |
| download | bcm5719-llvm-00d887447b05bd41ec77a897978bace2af287154.tar.gz bcm5719-llvm-00d887447b05bd41ec77a897978bace2af287154.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: 313382
Diffstat (limited to 'llvm/lib/IR/LLVMContext.cpp')
| -rw-r--r-- | llvm/lib/IR/LLVMContext.cpp | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp index c58459d6d5f..6569695c996 100644 --- a/llvm/lib/IR/LLVMContext.cpp +++ b/llvm/lib/IR/LLVMContext.cpp @@ -129,11 +129,17 @@ void *LLVMContext::getInlineAsmDiagnosticContext() const { return pImpl->InlineAsmDiagContext; } -void LLVMContext::setDiagnosticHandler(DiagnosticHandlerTy DiagnosticHandler, - void *DiagnosticContext, - bool RespectFilters) { - pImpl->DiagnosticHandler = DiagnosticHandler; - pImpl->DiagnosticContext = DiagnosticContext; +void LLVMContext::setDiagnosticHandlerCallBack( + DiagnosticHandler::DiagnosticHandlerTy DiagnosticHandler, + void *DiagnosticContext, bool RespectFilters) { + pImpl->DiagHandler->DiagHandlerCallback = DiagnosticHandler; + pImpl->DiagHandler->DiagnosticContext = DiagnosticContext; + pImpl->RespectDiagnosticFilters = RespectFilters; +} + +void LLVMContext::setDiagnosticHandler(std::unique_ptr<DiagnosticHandler> &&DH, + bool RespectFilters) { + pImpl->DiagHandler = std::move(DH); pImpl->RespectDiagnosticFilters = RespectFilters; } @@ -159,12 +165,13 @@ void LLVMContext::setDiagnosticsOutputFile(std::unique_ptr<yaml::Output> F) { pImpl->DiagnosticsOutputFile = std::move(F); } -LLVMContext::DiagnosticHandlerTy LLVMContext::getDiagnosticHandler() const { - return pImpl->DiagnosticHandler; +DiagnosticHandler::DiagnosticHandlerTy +LLVMContext::getDiagnosticHandlerCallBack() const { + return pImpl->DiagHandler->DiagHandlerCallback; } void *LLVMContext::getDiagnosticContext() const { - return pImpl->DiagnosticContext; + return pImpl->DiagHandler->DiagnosticContext; } void LLVMContext::setYieldCallback(YieldCallbackTy Callback, void *OpaqueHandle) @@ -215,11 +222,10 @@ LLVMContext::getDiagnosticMessagePrefix(DiagnosticSeverity Severity) { void LLVMContext::diagnose(const DiagnosticInfo &DI) { // If there is a report handler, use it. - if (pImpl->DiagnosticHandler) { - if (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) - pImpl->DiagnosticHandler(DI, pImpl->DiagnosticContext); + if (pImpl->DiagHandler && + (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) && + pImpl->DiagHandler->handleDiagnostics(DI)) return; - } if (!isDiagnosticEnabled(DI)) return; @@ -315,3 +321,11 @@ void LLVMContext::setDiscardValueNames(bool Discard) { OptBisect &LLVMContext::getOptBisect() { return pImpl->getOptBisect(); } + +const DiagnosticHandler *LLVMContext::getDiagHandlerPtr() const { + return pImpl->DiagHandler.get(); +} + +std::unique_ptr<DiagnosticHandler> LLVMContext::getDiagnosticHandler() { + return std::move(pImpl->DiagHandler); +} |

