Author: Nathan James Date: 2020-12-18T02:07:27Z New Revision: 2808f597f872e68a8bd69d5b53f5d583665b4c4f
URL: https://github.com/llvm/llvm-project/commit/2808f597f872e68a8bd69d5b53f5d583665b4c4f DIFF: https://github.com/llvm/llvm-project/commit/2808f597f872e68a8bd69d5b53f5d583665b4c4f.diff LOG: [clangd] Print .clang-tidy configuration parsing errors using [ev]?log. Currently warnings when parsing .clang-tidy are printed directly to errs. This is less than ideal as there is no synchronisation printing to errs, leading to potential races. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D93436 Added: Modified: clang-tools-extra/clangd/TidyProvider.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp index c6ee09ae16d2..c12dab7e2e5e 100644 --- a/clang-tools-extra/clangd/TidyProvider.cpp +++ b/clang-tools-extra/clangd/TidyProvider.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Process.h" +#include "llvm/Support/SourceMgr.h" #include "llvm/Support/VirtualFileSystem.h" #include <memory> @@ -44,8 +45,25 @@ class DotClangTidyCache : private FileCache { [this](llvm::Optional<llvm::StringRef> Data) { Value.reset(); if (Data && !Data->empty()) { - if (auto Parsed = tidy::parseConfiguration( - llvm::MemoryBufferRef(*Data, path()))) + tidy::DiagCallback Diagnostics = [](const llvm::SMDiagnostic &D) { + switch (D.getKind()) { + case llvm::SourceMgr::DK_Error: + elog("tidy-config error at {0}:{1}:{2}: {3}", D.getFilename(), + D.getLineNo(), D.getColumnNo(), D.getMessage()); + break; + case llvm::SourceMgr::DK_Warning: + log("tidy-config warning at {0}:{1}:{2}: {3}", D.getFilename(), + D.getLineNo(), D.getColumnNo(), D.getMessage()); + break; + case llvm::SourceMgr::DK_Note: + case llvm::SourceMgr::DK_Remark: + vlog("tidy-config note at {0}:{1}:{2}: {3}", D.getFilename(), + D.getLineNo(), D.getColumnNo(), D.getMessage()); + break; + } + }; + if (auto Parsed = tidy::parseConfigurationWithDiags( + llvm::MemoryBufferRef(*Data, path()), Diagnostics)) Value = std::make_shared<const tidy::ClangTidyOptions>( std::move(*Parsed)); else _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits