[PATCH] D93436: [clangd] Print .clang-tidy configuration parsing errors using [ev]?log.
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 16 17:37:19 PST 2020
njames93 created this revision.
njames93 added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93436
Files:
clang-tools-extra/clangd/TidyProvider.cpp
Index: clang-tools-extra/clangd/TidyProvider.cpp
===================================================================
--- clang-tools-extra/clangd/TidyProvider.cpp
+++ 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 @@
[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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93436.312349.patch
Type: text/x-patch
Size: 1835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201217/532347c3/attachment-0001.bin>
More information about the cfe-commits
mailing list