[clang-tools-extra] 2ab5fd2 - [clangd] Retire some flags for uncontroversial, stable features.
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 20 02:49:10 PST 2021
Author: Sam McCall
Date: 2021-01-20T11:47:12+01:00
New Revision: 2ab5fd2c8567ac89d7e7639563babdfc78dbcf78
URL: https://github.com/llvm/llvm-project/commit/2ab5fd2c8567ac89d7e7639563babdfc78dbcf78
DIFF: https://github.com/llvm/llvm-project/commit/2ab5fd2c8567ac89d7e7639563babdfc78dbcf78.diff
LOG: [clangd] Retire some flags for uncontroversial, stable features.
And mark a couple to be retired afther the next release branch.
Differential Revision: https://reviews.llvm.org/D94727
Added:
Modified:
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Compiler.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp
index 123d755f267e..32e08e688f44 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -146,7 +146,6 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
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 @@ void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
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/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h
index 832f8b04a11d..926de39b507a 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -136,8 +136,6 @@ class ClangdServer {
/*RebuildRatio=*/1,
};
- bool SuggestMissingIncludes = false;
-
/// Clangd will execute compiler drivers matching one of these globs to
/// fetch system include path.
std::vector<std::string> QueryDriverGlobs;
@@ -376,10 +374,6 @@ class ClangdServer {
// 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<llvm::Optional<FuzzyFindRequest>>
CachedCompletionFuzzyFindRequestByFile;
diff --git a/clang-tools-extra/clangd/Compiler.h b/clang-tools-extra/clangd/Compiler.h
index c46fb764d317..13fd4da33e3c 100644
--- a/clang-tools-extra/clangd/Compiler.h
+++ b/clang-tools-extra/clangd/Compiler.h
@@ -37,7 +37,7 @@ class IgnoreDiagnostics : public DiagnosticConsumer {
// 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
index 228db29b2be3..a8c4eea54540 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -351,8 +351,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
// (e.g. incomplete type) and attach include insertion fixes to diagnostics.
llvm::Optional<IncludeFixer> 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<IncludeInserter>(
Filename, Inputs.Contents, Style, BuildDir.get(),
diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 5cbf8aa0df90..fe69079bfe67 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -80,8 +80,21 @@ OptionCategory CompileCommands("clangd compilation flags options");
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 <typename T> class RetiredFlag {
+ opt<T> 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> CompileArgsFrom{
@@ -267,15 +280,7 @@ opt<bool> IncludeIneligibleResults{
Hidden,
};
-opt<bool> 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<bool> EnableIndex("index");
opt<int> LimitResults{
"limit-results",
@@ -285,13 +290,7 @@ opt<int> LimitResults{
init(100),
};
-opt<bool> SuggestMissingIncludes{
- "suggest-missing-includes",
- cat(Features),
- desc("Attempts to fix diagnostic errors caused by missing "
- "includes using index"),
- init(true),
-};
+RetiredFlag<bool> SuggestMissingIncludes("suggest-missing-includes");
list<std::string> TweakList{
"tweaks",
@@ -308,21 +307,8 @@ opt<bool> CrossFileRename{
init(true),
};
-opt<bool> RecoveryAST{
- "recovery-ast",
- cat(Features),
- desc("Preserve expressions in AST for broken code."),
- init(false),
- Hidden,
-};
-
-opt<bool> RecoveryASTType{
- "recovery-ast-type",
- cat(Features),
- desc("Preserve the type for recovery AST."),
- init(false),
- Hidden,
-};
+RetiredFlag<bool> RecoveryAST("recovery-ast");
+RetiredFlag<bool> RecoveryASTType("recovery-ast-type");
opt<bool> FoldingRanges{
"folding-ranges",
@@ -464,6 +450,7 @@ opt<bool> PrettyPrint{
init(false),
};
+// FIXME: retire this flag in llvm 13 release cycle.
opt<bool> AsyncPreamble{
"async-preamble",
cat(Misc),
@@ -487,11 +474,13 @@ opt<bool> EnableConfig{
init(true),
};
+// FIXME: retire this flag in llvm 13 release cycle.
opt<bool> 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 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
}
if (!ResourceDir.empty())
Opts.ResourceDir = ResourceDir;
- Opts.BuildDynamicSymbolIndex = EnableIndex;
+ Opts.BuildDynamicSymbolIndex = true;
Opts.CollectMainFileRefs = CollectMainFileRefs;
std::vector<std::unique_ptr<SymbolIndex>> IdxStack;
std::unique_ptr<SymbolIndex> StaticIdx;
std::future<void> 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<MemIndex>()));
@@ -872,7 +861,6 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
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
index 3b1130444671..a956b6b73b19 100644
--- a/clang-tools-extra/clangd/unittests/TestTU.cpp
+++ b/clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -62,8 +62,6 @@ ParseInputs TestTU::inputs(MockFS &FS) const {
if (ClangTidyProvider)
Inputs.ClangTidyProvider = ClangTidyProvider;
Inputs.Index = ExternalIndex;
- if (Inputs.Index)
- Inputs.Opts.SuggestMissingIncludes = true;
return Inputs;
}
More information about the cfe-commits
mailing list