diff --git a/clang-tools-extra/clangd/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h --- a/clang-tools-extra/clangd/ClangdServer.h +++ b/clang-tools-extra/clangd/ClangdServer.h @@ -136,8 +136,6 @@ /*RebuildRatio=*/1, }; - bool SuggestMissingIncludes = false; - /// Clangd will execute compiler drivers matching one of these globs to /// fetch system include path. std::vector QueryDriverGlobs; @@ -376,10 +374,6 @@ // When set, provides clang-tidy options for a specific file. TidyProviderRef ClangTidyProvider; - // If this is true, suggest include insertion fixes for diagnostic errors that - // can be caused by missing includes (e.g. member access in incomplete type). - bool SuggestMissingIncludes = false; - // GUARDED_BY(CachedCompletionFuzzyFindRequestMutex) llvm::StringMap> CachedCompletionFuzzyFindRequestByFile; diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -146,7 +146,6 @@ Opts.CollectMainFileRefs) : nullptr), ClangTidyProvider(Opts.ClangTidyProvider), - SuggestMissingIncludes(Opts.SuggestMissingIncludes), 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 @@ -201,7 +200,6 @@ llvm::StringRef Version, WantDiagnostics WantDiags, bool ForceRebuild) { ParseOptions Opts; - Opts.SuggestMissingIncludes = SuggestMissingIncludes; // Compile command is set asynchronously during update, as it can be slow. ParseInputs Inputs; diff --git a/clang-tools-extra/clangd/Compiler.h b/clang-tools-extra/clangd/Compiler.h --- a/clang-tools-extra/clangd/Compiler.h +++ b/clang-tools-extra/clangd/Compiler.h @@ -37,7 +37,7 @@ // Options to run clang e.g. when parsing AST. struct ParseOptions { - bool SuggestMissingIncludes = false; + // (empty at present, formerly controlled recovery AST, include-fixer etc) }; /// Information required to run clang, e.g. to parse AST or do code completion. diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp --- a/clang-tools-extra/clangd/ParsedAST.cpp +++ b/clang-tools-extra/clangd/ParsedAST.cpp @@ -351,8 +351,7 @@ // (e.g. incomplete type) and attach include insertion fixes to diagnostics. llvm::Optional FixIncludes; auto BuildDir = VFS->getCurrentWorkingDirectory(); - if (Inputs.Opts.SuggestMissingIncludes && Inputs.Index && - !BuildDir.getError()) { + if (Inputs.Index && !BuildDir.getError()) { auto Style = getFormatStyleForFile(Filename, Inputs.Contents, *Inputs.TFS); auto Inserter = std::make_shared( Filename, Inputs.Contents, Style, BuildDir.get(), diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp --- a/clang-tools-extra/clangd/tool/ClangdMain.cpp +++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp @@ -80,8 +80,21 @@ OptionCategory Features("clangd feature options"); OptionCategory Misc("clangd miscellaneous options"); OptionCategory Protocol("clangd protocol and logging options"); +OptionCategory Retired("clangd flags no longer in use"); const OptionCategory *ClangdCategories[] = {&Features, &Protocol, - &CompileCommands, &Misc}; + &CompileCommands, &Misc, &Retired}; + +template class RetiredFlag { + opt Option; + +public: + RetiredFlag(llvm::StringRef Name) + : Option(Name, cat(Retired), desc("Obsolete flag, ignored"), Hidden, + llvm::cl::callback([Name](const T &) { + llvm::errs() + << "The flag `-" << Name << "` is obsolete and ignored.\n"; + })) {} +}; enum CompileArgsFrom { LSPCompileArgs, FilesystemCompileArgs }; opt CompileArgsFrom{ @@ -267,15 +280,7 @@ Hidden, }; -opt EnableIndex{ - "index", - cat(Features), - desc("Enable index-based features. By default, clangd maintains an index " - "built from symbols in opened files. Global index support needs to " - "enabled separatedly"), - init(true), - Hidden, -}; +RetiredFlag EnableIndex("index"); opt LimitResults{ "limit-results", @@ -285,13 +290,7 @@ init(100), }; -opt SuggestMissingIncludes{ - "suggest-missing-includes", - cat(Features), - desc("Attempts to fix diagnostic errors caused by missing " - "includes using index"), - init(true), -}; +RetiredFlag SuggestMissingIncludes("suggest-missing-includes"); list TweakList{ "tweaks", @@ -308,21 +307,8 @@ init(true), }; -opt RecoveryAST{ - "recovery-ast", - cat(Features), - desc("Preserve expressions in AST for broken code."), - init(false), - Hidden, -}; - -opt RecoveryASTType{ - "recovery-ast-type", - cat(Features), - desc("Preserve the type for recovery AST."), - init(false), - Hidden, -}; +RetiredFlag RecoveryAST("recovery-ast"); +RetiredFlag RecoveryASTType("recovery-ast-type"); opt FoldingRanges{ "folding-ranges", @@ -464,6 +450,7 @@ init(false), }; +// FIXME: retire this flag in llvm 13 release cycle. opt AsyncPreamble{ "async-preamble", cat(Misc), @@ -487,11 +474,13 @@ init(true), }; +// FIXME: retire this flag in llvm 13 release cycle. opt CollectMainFileRefs{ "collect-main-file-refs", cat(Misc), desc("Store references to main-file-only symbols in the index"), init(ClangdServer::Options().CollectMainFileRefs), + Hidden, }; #if defined(__GLIBC__) && CLANGD_MALLOC_TRIM @@ -770,12 +759,12 @@ } if (!ResourceDir.empty()) Opts.ResourceDir = ResourceDir; - Opts.BuildDynamicSymbolIndex = EnableIndex; + Opts.BuildDynamicSymbolIndex = true; Opts.CollectMainFileRefs = CollectMainFileRefs; std::vector> IdxStack; std::unique_ptr StaticIdx; std::future AsyncIndexLoad; // Block exit while loading the index. - if (EnableIndex && !IndexFile.empty()) { + if (!IndexFile.empty()) { // Load the index asynchronously. Meanwhile SwapIndex returns no results. SwapIndex *Placeholder; StaticIdx.reset(Placeholder = new SwapIndex(std::make_unique())); @@ -872,7 +861,6 @@ Opts.ClangTidyProvider = ClangTidyOptProvider; } Opts.AsyncPreambleBuilds = AsyncPreamble; - Opts.SuggestMissingIncludes = SuggestMissingIncludes; Opts.QueryDriverGlobs = std::move(QueryDriverGlobs); Opts.TweakFilter = [&](const Tweak &T) { if (T.hidden() && !HiddenFeatures) diff --git a/clang-tools-extra/clangd/unittests/TestTU.cpp b/clang-tools-extra/clangd/unittests/TestTU.cpp --- a/clang-tools-extra/clangd/unittests/TestTU.cpp +++ b/clang-tools-extra/clangd/unittests/TestTU.cpp @@ -62,8 +62,6 @@ if (ClangTidyProvider) Inputs.ClangTidyProvider = ClangTidyProvider; Inputs.Index = ExternalIndex; - if (Inputs.Index) - Inputs.Opts.SuggestMissingIncludes = true; return Inputs; }