Index: clang-tools-extra/trunk/clangd/ClangdServer.h =================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.h +++ clang-tools-extra/trunk/clangd/ClangdServer.h @@ -140,6 +140,9 @@ /// Enable semantic highlighting features. bool SemanticHighlighting = false; + + /// Returns true if the StringRef is a tweak that should be enabled + std::function TweakFilter = [](llvm::StringRef TweakToSearch) {return true;}; }; // Sensible default options for use in tests. // Features like indexing must be enabled if desired. @@ -313,7 +316,9 @@ // can be caused by missing includes (e.g. member access in incomplete type). bool SuggestMissingIncludes = false; bool EnableHiddenFeatures = false; - + + std::function TweakFilter; + // GUARDED_BY(CachedCompletionFuzzyFindRequestMutex) llvm::StringMap> CachedCompletionFuzzyFindRequestByFile; Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.cpp +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp @@ -102,6 +102,7 @@ GetClangTidyOptions(Opts.GetClangTidyOptions), SuggestMissingIncludes(Opts.SuggestMissingIncludes), EnableHiddenFeatures(Opts.HiddenFeatures), + TweakFilter(Opts.TweakFilter), WorkspaceRoot(Opts.WorkspaceRoot), // Pass a callback into `WorkScheduler` to extract symbols from a newly // parsed file and rebuild the file index synchronously each time an AST @@ -333,7 +334,7 @@ return CB(Selection.takeError()); std::vector Res; for (auto &T : prepareTweaks(*Selection)) { - if (T->hidden() && !EnableHiddenFeatures) + if (!TweakFilter(T->id()) || (T->hidden() && !EnableHiddenFeatures)) continue; Res.push_back({T->id(), T->title(), T->intent()}); } Index: clang-tools-extra/trunk/clangd/test/fixits-duplication.test =================================================================== --- clang-tools-extra/trunk/clangd/test/fixits-duplication.test +++ clang-tools-extra/trunk/clangd/test/fixits-duplication.test @@ -1,4 +1,4 @@ -# RUN: clangd -lit-test -clang-tidy-checks=modernize-use-nullptr,hicpp-use-nullptr < %s | FileCheck -strict-whitespace %s +# RUN: clangd -lit-test -clang-tidy-checks=modernize-use-nullptr,hicpp-use-nullptr -tweaks="" < %s | FileCheck -strict-whitespace %s {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{}}}},"trace":"off"}} --- {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.cpp","languageId":"cpp","version":1,"text":"void foo() { char* p = 0; }"}}} 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 @@ -278,6 +278,12 @@ "/usr/bin/**/clang-*,/path/to/repo/**/g++-*"), llvm::cl::CommaSeparated); +static llvm::cl::list TweakList( + "tweaks", + llvm::cl::desc( + "Specify a list of Tweaks to enable (only for clangd developers)."), + llvm::cl::Hidden, llvm::cl::CommaSeparated); + namespace { /// \brief Supports a test URI scheme with relaxed constraints for lit tests. @@ -533,6 +539,11 @@ } Opts.SuggestMissingIncludes = SuggestMissingIncludes; Opts.QueryDriverGlobs = std::move(QueryDriverGlobs); + if (TweakList.getNumOccurrences()) + Opts.TweakFilter = [&](llvm::StringRef TweakToSearch) { + // return true if any tweak matches the TweakToSearch + return llvm::find(TweakList, TweakToSearch) != TweakList.end(); + }; llvm::Optional OffsetEncodingFromFlag; if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding) OffsetEncodingFromFlag = ForceOffsetEncoding;