[PATCH] D61841: [clangd] Respect WarningsAsErrors configuration for clang-tidy

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 14 21:25:54 PDT 2019


nridge updated this revision to Diff 199552.
nridge marked 2 inline comments as done.
nridge added a comment.

Address review comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61841/new/

https://reviews.llvm.org/D61841

Files:
  clang-tools-extra/clangd/ClangdUnit.cpp


Index: clang-tools-extra/clangd/ClangdUnit.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdUnit.cpp
+++ 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;
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61841.199552.patch
Type: text/x-patch
Size: 864 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190515/d753e922/attachment.bin>


More information about the cfe-commits mailing list