[clang-tools-extra] r353284 - [clangd] Add CLI flag "-clang-tidy" to enable/disable running clang-tidy checks.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 6 01:10:47 PST 2019
Author: hokein
Date: Wed Feb 6 01:10:47 2019
New Revision: 353284
URL: http://llvm.org/viewvc/llvm-project?rev=353284&view=rev
Log:
[clangd] Add CLI flag "-clang-tidy" to enable/disable running clang-tidy checks.
Reviewers: sammccall
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57746
Modified:
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=353284&r1=353283&r2=353284&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Wed Feb 6 01:10:47 2019
@@ -203,10 +203,16 @@ static llvm::cl::opt<bool> EnableFunctio
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 @@ int main(int argc, char *argv[]) {
}
// 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,
More information about the cfe-commits
mailing list