aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2023-12-19 21:51:26 -0800
committerGitHub <noreply@github.com>2023-12-19 21:51:26 -0800
commit207cbbd71009090768c63004b967eddfab0f1d2e (patch)
tree4de085034aa32ae9534f913c378111cc62caf96b /llvm/lib/IR
parent47413bb2760e63a3302871ea770d6c0f5a742036 (diff)
downloadllvm-207cbbd71009090768c63004b967eddfab0f1d2e.zip
llvm-207cbbd71009090768c63004b967eddfab0f1d2e.tar.gz
llvm-207cbbd71009090768c63004b967eddfab0f1d2e.tar.bz2
DiagnosticHandler: refactor error checking (#75889)
In LLVMContext::diagnose, set `HasErrors` for `DS_Error` so that all derived `DiagnosticHandler` have correct `HasErrors` information. An alternative is to set `HasErrors` in `DiagnosticHandler::handleDiagnostics`, but all derived `handleDiagnostics` would have to call the base function.
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/LLVMContext.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp
index 8ddf515..57077e7 100644
--- a/llvm/lib/IR/LLVMContext.cpp
+++ b/llvm/lib/IR/LLVMContext.cpp
@@ -256,10 +256,13 @@ void LLVMContext::diagnose(const DiagnosticInfo &DI) {
RS->emit(*OptDiagBase);
// If there is a report handler, use it.
- if (pImpl->DiagHandler &&
- (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) &&
- pImpl->DiagHandler->handleDiagnostics(DI))
- return;
+ if (pImpl->DiagHandler) {
+ if (DI.getSeverity() == DS_Error)
+ pImpl->DiagHandler->HasErrors = true;
+ if ((!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) &&
+ pImpl->DiagHandler->handleDiagnostics(DI))
+ return;
+ }
if (!isDiagnosticEnabled(DI))
return;