[PATCH] D57746: [clangd] Add CLI flag "-clang-tidy" to enable/disable running clang-tidy checks.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 6 01:10:54 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353284: [clangd] Add CLI flag "-clang-tidy" to enable/disable running clang-tidy checks. (authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57746/new/
https://reviews.llvm.org/D57746
Files:
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -203,10 +203,16 @@
static llvm::cl::opt<std::string> ClangTidyChecks(
"clang-tidy-checks",
- llvm::cl::desc("List of clang-tidy checks to run (this will override "
- ".clang-tidy files)"),
+ llvm::cl::desc(
+ "List of clang-tidy checks to run (this will override "
+ ".clang-tidy files). Only meaningful when -clang-tidy flag is on."),
llvm::cl::init(""));
+static llvm::cl::opt<bool> EnableClangTidy(
+ "clang-tidy",
+ llvm::cl::desc("Enable clang-tidy diagnostics."),
+ llvm::cl::init(false));
+
static llvm::cl::opt<bool> SuggestMissingIncludes(
"suggest-missing-includes",
llvm::cl::desc("Attempts to fix diagnostic errors caused by missing "
@@ -441,13 +447,16 @@
}
// Create an empty clang-tidy option.
- auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
- OverrideClangTidyOptions.Checks = ClangTidyChecks;
- tidy::FileOptionsProvider ClangTidyOptProvider(
- tidy::ClangTidyGlobalOptions(),
- /* Default */ tidy::ClangTidyOptions::getDefaults(),
- /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
- Opts.ClangTidyOptProvider = &ClangTidyOptProvider;
+ std::unique_ptr<tidy::ClangTidyOptionsProvider> ClangTidyOptProvider;
+ if (EnableClangTidy) {
+ auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
+ OverrideClangTidyOptions.Checks = ClangTidyChecks;
+ ClangTidyOptProvider = llvm::make_unique<tidy::FileOptionsProvider>(
+ tidy::ClangTidyGlobalOptions(),
+ /* Default */ tidy::ClangTidyOptions::getDefaults(),
+ /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
+ }
+ Opts.ClangTidyOptProvider = ClangTidyOptProvider.get();
Opts.SuggestMissingIncludes = SuggestMissingIncludes;
ClangdLSPServer LSPServer(
*TransportLayer, FSProvider, CCOpts, CompileCommandsDirPath,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57746.185506.patch
Type: text/x-patch
Size: 2144 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190206/2c05479f/attachment-0001.bin>
More information about the cfe-commits
mailing list