diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp --- a/clang-tools-extra/clangd/ClangdUnit.cpp +++ b/clang-tools-extra/clangd/ClangdUnit.cpp @@ -304,6 +304,21 @@ this->CTContext = CTContext; } + void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, + const clang::Diagnostic &Info) override { + DiagnosticsEngine::Level Level = DiagLevel; + + // Check for warning-as-error. + if (CTContext && DiagLevel == DiagnosticsEngine::Warning) { + std::string CheckName = CTContext->getCheckName(Info.getID()); + if (!CheckName.empty() && CTContext->treatAsError(CheckName)) { + Level = DiagnosticsEngine::Error; + } + } + + StoreDiags::HandleDiagnostic(Level, Info); + } + private: tidy::ClangTidyContext *CTContext = nullptr; };