[llvm] [clang] DiagnosticHandler: refactor error checking (PR #75889)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 18 19:34:21 PST 2023


================
@@ -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;
----------------
MaskRay wrote:

This unfortunately exposes the detail of DiagnosticHandler, but the alternative (set HasErrors in `DiagnosticHandler::handleDiagnostics`) isn't better and a new client may forget to call the base.

https://github.com/llvm/llvm-project/pull/75889


More information about the llvm-commits mailing list