@@ -80,8 +80,21 @@ OptionCategory CompileCommands("clangd compilation flags options");
80
80
OptionCategory Features (" clangd feature options" );
81
81
OptionCategory Misc (" clangd miscellaneous options" );
82
82
OptionCategory Protocol (" clangd protocol and logging options" );
83
+ OptionCategory Retired (" clangd flags no longer in use" );
83
84
const OptionCategory *ClangdCategories[] = {&Features, &Protocol,
84
- &CompileCommands, &Misc};
85
+ &CompileCommands, &Misc, &Retired};
86
+
87
+ template <typename T> class RetiredFlag {
88
+ opt<T> Option;
89
+
90
+ public:
91
+ RetiredFlag (llvm::StringRef Name)
92
+ : Option(Name, cat(Retired), desc(" Obsolete flag, ignored" ), Hidden,
93
+ llvm::cl::callback ([Name](const T &) {
94
+ llvm::errs ()
95
+ << " The flag `-" << Name << " ` is obsolete and ignored.\n " ;
96
+ })) {}
97
+ };
85
98
86
99
enum CompileArgsFrom { LSPCompileArgs, FilesystemCompileArgs };
87
100
opt<CompileArgsFrom> CompileArgsFrom{
@@ -267,15 +280,7 @@ opt<bool> IncludeIneligibleResults{
267
280
Hidden,
268
281
};
269
282
270
- opt<bool > EnableIndex{
271
- " index" ,
272
- cat (Features),
273
- desc (" Enable index-based features. By default, clangd maintains an index "
274
- " built from symbols in opened files. Global index support needs to "
275
- " enabled separatedly" ),
276
- init (true ),
277
- Hidden,
278
- };
283
+ RetiredFlag<bool > EnableIndex (" index" );
279
284
280
285
opt<int > LimitResults{
281
286
" limit-results" ,
@@ -285,13 +290,7 @@ opt<int> LimitResults{
285
290
init (100 ),
286
291
};
287
292
288
- opt<bool > SuggestMissingIncludes{
289
- " suggest-missing-includes" ,
290
- cat (Features),
291
- desc (" Attempts to fix diagnostic errors caused by missing "
292
- " includes using index" ),
293
- init (true ),
294
- };
293
+ RetiredFlag<bool > SuggestMissingIncludes (" suggest-missing-includes" );
295
294
296
295
list<std::string> TweakList{
297
296
" tweaks" ,
@@ -308,21 +307,8 @@ opt<bool> CrossFileRename{
308
307
init (true ),
309
308
};
310
309
311
- opt<bool > RecoveryAST{
312
- " recovery-ast" ,
313
- cat (Features),
314
- desc (" Preserve expressions in AST for broken code." ),
315
- init (false ),
316
- Hidden,
317
- };
318
-
319
- opt<bool > RecoveryASTType{
320
- " recovery-ast-type" ,
321
- cat (Features),
322
- desc (" Preserve the type for recovery AST." ),
323
- init (false ),
324
- Hidden,
325
- };
310
+ RetiredFlag<bool > RecoveryAST (" recovery-ast" );
311
+ RetiredFlag<bool > RecoveryASTType (" recovery-ast-type" );
326
312
327
313
opt<bool > FoldingRanges{
328
314
" folding-ranges" ,
@@ -464,6 +450,7 @@ opt<bool> PrettyPrint{
464
450
init (false ),
465
451
};
466
452
453
+ // FIXME: retire this flag in llvm 13 release cycle.
467
454
opt<bool > AsyncPreamble{
468
455
" async-preamble" ,
469
456
cat (Misc),
@@ -487,11 +474,13 @@ opt<bool> EnableConfig{
487
474
init (true ),
488
475
};
489
476
477
+ // FIXME: retire this flag in llvm 13 release cycle.
490
478
opt<bool > CollectMainFileRefs{
491
479
" collect-main-file-refs" ,
492
480
cat (Misc),
493
481
desc (" Store references to main-file-only symbols in the index" ),
494
482
init (ClangdServer::Options ().CollectMainFileRefs ),
483
+ Hidden,
495
484
};
496
485
497
486
#if defined(__GLIBC__) && CLANGD_MALLOC_TRIM
@@ -770,12 +759,12 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
770
759
}
771
760
if (!ResourceDir.empty ())
772
761
Opts.ResourceDir = ResourceDir;
773
- Opts.BuildDynamicSymbolIndex = EnableIndex ;
762
+ Opts.BuildDynamicSymbolIndex = true ;
774
763
Opts.CollectMainFileRefs = CollectMainFileRefs;
775
764
std::vector<std::unique_ptr<SymbolIndex>> IdxStack;
776
765
std::unique_ptr<SymbolIndex> StaticIdx;
777
766
std::future<void > AsyncIndexLoad; // Block exit while loading the index.
778
- if (EnableIndex && !IndexFile.empty ()) {
767
+ if (!IndexFile.empty ()) {
779
768
// Load the index asynchronously. Meanwhile SwapIndex returns no results.
780
769
SwapIndex *Placeholder;
781
770
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
872
861
Opts.ClangTidyProvider = ClangTidyOptProvider;
873
862
}
874
863
Opts.AsyncPreambleBuilds = AsyncPreamble;
875
- Opts.SuggestMissingIncludes = SuggestMissingIncludes;
876
864
Opts.QueryDriverGlobs = std::move (QueryDriverGlobs);
877
865
Opts.TweakFilter = [&](const Tweak &T) {
878
866
if (T.hidden () && !HiddenFeatures)
0 commit comments