sammccall updated this revision to Diff 319776.
sammccall added a comment.

group retired flags


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95571/new/

https://reviews.llvm.org/D95571

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -154,8 +154,7 @@
 
 std::unique_ptr<SymbolIndex> TestTU::index() const {
   auto AST = build();
-  auto Idx = std::make_unique<FileIndex>(/*UseDex=*/true,
-                                         /*CollectMainFileRefs=*/true);
+  auto Idx = std::make_unique<FileIndex>();
   Idx->updatePreamble(testPath(Filename), /*Version=*/"null",
                       AST.getASTContext(), AST.getPreprocessorPtr(),
                       AST.getCanonicalIncludes());
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -190,7 +190,6 @@
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
   BackgroundIndex::Options Opts;
-  Opts.CollectMainFileRefs = true;
   BackgroundIndex Idx(
       FS, CDB, [&](llvm::StringRef) { return &MSS; }, Opts);
 
@@ -241,52 +240,25 @@
   FS.Files[testPath("root/A.cc")] =
       "#include \"A.h\"\nstatic void main_sym() { (void)header_sym; }";
 
-  // Check the behaviour with CollectMainFileRefs = false (the default
-  // at the SymbolCollector level).
-  {
-    llvm::StringMap<std::string> Storage;
-    size_t CacheHits = 0;
-    MemoryShardStorage MSS(Storage, CacheHits);
-    OverlayCDB CDB(/*Base=*/nullptr);
-    BackgroundIndex Idx(FS, CDB, [&](llvm::StringRef) { return &MSS; },
-                        /*Opts=*/{});
-
-    tooling::CompileCommand Cmd;
-    Cmd.Filename = testPath("root/A.cc");
-    Cmd.Directory = testPath("root");
-    Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
-    CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
-
-    ASSERT_TRUE(Idx.blockUntilIdleForTest());
-    EXPECT_THAT(
-        runFuzzyFind(Idx, ""),
-        UnorderedElementsAre(AllOf(Named("header_sym"), NumReferences(1U)),
-                             AllOf(Named("main_sym"), NumReferences(0U))));
-  }
-
-  // Check the behaviour with CollectMainFileRefs = true.
-  {
-    llvm::StringMap<std::string> Storage;
-    size_t CacheHits = 0;
-    MemoryShardStorage MSS(Storage, CacheHits);
-    OverlayCDB CDB(/*Base=*/nullptr);
-    BackgroundIndex::Options Opts;
-    Opts.CollectMainFileRefs = true;
-    BackgroundIndex Idx(
-        FS, CDB, [&](llvm::StringRef) { return &MSS; }, Opts);
+  llvm::StringMap<std::string> Storage;
+  size_t CacheHits = 0;
+  MemoryShardStorage MSS(Storage, CacheHits);
+  OverlayCDB CDB(/*Base=*/nullptr);
+  BackgroundIndex::Options Opts;
+  BackgroundIndex Idx(
+      FS, CDB, [&](llvm::StringRef) { return &MSS; }, Opts);
 
-    tooling::CompileCommand Cmd;
-    Cmd.Filename = testPath("root/A.cc");
-    Cmd.Directory = testPath("root");
-    Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
-    CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
+  tooling::CompileCommand Cmd;
+  Cmd.Filename = testPath("root/A.cc");
+  Cmd.Directory = testPath("root");
+  Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
+  CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 
-    ASSERT_TRUE(Idx.blockUntilIdleForTest());
-    EXPECT_THAT(
-        runFuzzyFind(Idx, ""),
-        UnorderedElementsAre(AllOf(Named("header_sym"), NumReferences(1U)),
-                             AllOf(Named("main_sym"), NumReferences(1U))));
-  }
+  ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  EXPECT_THAT(
+      runFuzzyFind(Idx, ""),
+      UnorderedElementsAre(AllOf(Named("header_sym"), NumReferences(1U)),
+                           AllOf(Named("main_sym"), NumReferences(1U))));
 }
 
 TEST_F(BackgroundIndexTest, ShardStorageTest) {
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===================================================================
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -281,6 +281,11 @@
 };
 
 RetiredFlag<bool> EnableIndex("index");
+RetiredFlag<bool> SuggestMissingIncludes("suggest-missing-includes");
+RetiredFlag<bool> RecoveryAST("recovery-ast");
+RetiredFlag<bool> RecoveryASTType("recovery-ast-type");
+RetiredFlag<bool> AsyncPreamble("async-preamble");
+RetiredFlag<bool> CollectMainFileRefs("collect-main-file-refs");
 
 opt<int> LimitResults{
     "limit-results",
@@ -290,7 +295,6 @@
     init(100),
 };
 
-RetiredFlag<bool> SuggestMissingIncludes("suggest-missing-includes");
 
 list<std::string> TweakList{
     "tweaks",
@@ -307,9 +311,6 @@
     init(true),
 };
 
-RetiredFlag<bool> RecoveryAST("recovery-ast");
-RetiredFlag<bool> RecoveryASTType("recovery-ast-type");
-
 opt<bool> FoldingRanges{
     "folding-ranges",
     cat(Features),
@@ -450,16 +451,6 @@
     init(false),
 };
 
-// FIXME: retire this flag in llvm 13 release cycle.
-opt<bool> AsyncPreamble{
-    "async-preamble",
-    cat(Misc),
-    desc("Reuse even stale preambles, and rebuild them in the background. This "
-         "improves latency at the cost of accuracy."),
-    init(ClangdServer::Options().AsyncPreambleBuilds),
-    Hidden,
-};
-
 opt<bool> EnableConfig{
     "enable-config",
     cat(Misc),
@@ -474,15 +465,6 @@
     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
 opt<bool> EnableMallocTrim{
     "malloc-trim",
@@ -760,7 +742,6 @@
   if (!ResourceDir.empty())
     Opts.ResourceDir = ResourceDir;
   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.
@@ -860,7 +841,6 @@
     ClangTidyOptProvider = combine(std::move(Providers));
     Opts.ClangTidyProvider = ClangTidyOptProvider;
   }
-  Opts.AsyncPreambleBuilds = AsyncPreamble;
   Opts.QueryDriverGlobs = std::move(QueryDriverGlobs);
   Opts.TweakFilter = [&](const Tweak &T) {
     if (T.hidden() && !HiddenFeatures)
Index: clang-tools-extra/clangd/index/FileIndex.h
===================================================================
--- clang-tools-extra/clangd/index/FileIndex.h
+++ clang-tools-extra/clangd/index/FileIndex.h
@@ -107,7 +107,7 @@
 /// FIXME: Expose an interface to remove files that are closed.
 class FileIndex : public MergedIndex {
 public:
-  FileIndex(bool UseDex = true, bool CollectMainFileRefs = false);
+  FileIndex();
 
   /// Update preamble symbols of file \p Path with all declarations in \p AST
   /// and macros in \p PP.
@@ -122,9 +122,6 @@
   void profile(MemoryTree &MT) const;
 
 private:
-  bool UseDex; // FIXME: this should be always on.
-  bool CollectMainFileRefs;
-
   // Contains information from each file's preamble only. Symbols and relations
   // are sharded per declaration file to deduplicate multiple symbols and reduce
   // memory usage.
@@ -158,7 +155,7 @@
 /// Retrieves symbols and refs of local top level decls in \p AST (i.e.
 /// `AST.getLocalTopLevelDecls()`).
 /// Exposed to assist in unit tests.
-SlabTuple indexMainDecls(ParsedAST &AST, bool CollectMainFileRefs = false);
+SlabTuple indexMainDecls(ParsedAST &AST);
 
 /// Index declarations from \p AST and macros from \p PP that are declared in
 /// included headers.
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===================================================================
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -217,11 +217,11 @@
   return std::move(IF);
 }
 
-SlabTuple indexMainDecls(ParsedAST &AST, bool CollectMainFileRefs) {
+SlabTuple indexMainDecls(ParsedAST &AST) {
   return indexSymbols(
       AST.getASTContext(), AST.getPreprocessorPtr(),
       AST.getLocalTopLevelDecls(), &AST.getMacros(), AST.getCanonicalIncludes(),
-      /*IsIndexMainAST=*/true, AST.version(), CollectMainFileRefs);
+      /*IsIndexMainAST=*/true, AST.version(), /*CollectMainFileRefs=*/true);
 }
 
 SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
@@ -410,9 +410,8 @@
   }
 }
 
-FileIndex::FileIndex(bool UseDex, bool CollectMainFileRefs)
-    : MergedIndex(&MainFileIndex, &PreambleIndex), UseDex(UseDex),
-      CollectMainFileRefs(CollectMainFileRefs),
+FileIndex::FileIndex()
+    : MergedIndex(&MainFileIndex, &PreambleIndex),
       PreambleIndex(std::make_unique<MemIndex>()),
       MainFileIndex(std::make_unique<MemIndex>()) {}
 
@@ -436,9 +435,8 @@
         /*CountReferences=*/false);
   }
   size_t IndexVersion = 0;
-  auto NewIndex =
-      PreambleSymbols.buildIndex(UseDex ? IndexType::Heavy : IndexType::Light,
-                                 DuplicateHandling::PickOne, &IndexVersion);
+  auto NewIndex = PreambleSymbols.buildIndex(
+      IndexType::Heavy, DuplicateHandling::PickOne, &IndexVersion);
   {
     std::lock_guard<std::mutex> Lock(UpdateIndexMu);
     if (IndexVersion <= PreambleIndexVersion) {
@@ -455,7 +453,7 @@
 }
 
 void FileIndex::updateMain(PathRef Path, ParsedAST &AST) {
-  auto Contents = indexMainDecls(AST, CollectMainFileRefs);
+  auto Contents = indexMainDecls(AST);
   MainFileSymbols.update(
       Path, std::make_unique<SymbolSlab>(std::move(std::get<0>(Contents))),
       std::make_unique<RefSlab>(std::move(std::get<1>(Contents))),
Index: clang-tools-extra/clangd/index/Background.h
===================================================================
--- clang-tools-extra/clangd/index/Background.h
+++ clang-tools-extra/clangd/index/Background.h
@@ -143,8 +143,6 @@
     // file. Called with the empty string for other tasks.
     // (When called, the context from BackgroundIndex construction is active).
     std::function<Context(PathRef)> ContextProvider = nullptr;
-    // Whether to collect references to main-file-only symbols.
-    bool CollectMainFileRefs = false;
   };
 
   /// Creates a new background index and starts its threads.
@@ -198,7 +196,6 @@
   const ThreadsafeFS &TFS;
   const GlobalCompilationDatabase &CDB;
   std::function<Context(PathRef)> ContextProvider;
-  bool CollectMainFileRefs;
 
   llvm::Error index(tooling::CompileCommand);
 
Index: clang-tools-extra/clangd/index/Background.cpp
===================================================================
--- clang-tools-extra/clangd/index/Background.cpp
+++ clang-tools-extra/clangd/index/Background.cpp
@@ -97,7 +97,6 @@
     BackgroundIndexStorage::Factory IndexStorageFactory, Options Opts)
     : SwapIndex(std::make_unique<MemIndex>()), TFS(TFS), CDB(CDB),
       ContextProvider(std::move(Opts.ContextProvider)),
-      CollectMainFileRefs(Opts.CollectMainFileRefs),
       Rebuilder(this, &IndexedSymbols, Opts.ThreadPoolSize),
       IndexStorageFactory(std::move(IndexStorageFactory)),
       Queue(std::move(Opts.OnProgress)),
@@ -304,7 +303,7 @@
       return false; // Skip files that haven't changed, without errors.
     return true;
   };
-  IndexOpts.CollectMainFileRefs = CollectMainFileRefs;
+  IndexOpts.CollectMainFileRefs = true;
 
   IndexFileIn Index;
   auto Action = createStaticIndexingAction(
Index: clang-tools-extra/clangd/TUScheduler.h
===================================================================
--- clang-tools-extra/clangd/TUScheduler.h
+++ clang-tools-extra/clangd/TUScheduler.h
@@ -196,10 +196,6 @@
     /// Determines when to keep idle ASTs in memory for future use.
     ASTRetentionPolicy RetentionPolicy;
 
-    /// Whether to run PreamblePeer asynchronously.
-    /// No-op if AsyncThreadsCount is 0.
-    bool AsyncPreambleBuilds = true;
-
     /// Used to create a context that wraps each single operation.
     /// Typically to inject per-file configuration.
     /// If the path is empty, context sholud be "generic".
Index: clang-tools-extra/clangd/ClangdServer.h
===================================================================
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -98,22 +98,14 @@
 
     /// Cached preambles are potentially large. If false, store them on disk.
     bool StorePreamblesInMemory = true;
-    /// Reuse even stale preambles, and rebuild them in the background.
-    /// This improves latency at the cost of accuracy.
-    bool AsyncPreambleBuilds = true;
 
     /// If true, ClangdServer builds a dynamic in-memory index for symbols in
     /// opened files and uses the index to augment code completion results.
     bool BuildDynamicSymbolIndex = false;
-    /// Use a heavier and faster in-memory index implementation.
-    bool HeavyweightDynamicSymbolIndex = true;
     /// If true, ClangdServer automatically indexes files in the current project
     /// on background threads. The index is stored in the project root.
     bool BackgroundIndex = false;
 
-    /// Store refs to main-file symbols in the index.
-    bool CollectMainFileRefs = true;
-
     /// If set, use this index to augment code completion results.
     SymbolIndex *StaticIndex = nullptr;
 
Index: clang-tools-extra/clangd/ClangdServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -122,7 +122,6 @@
   Opts.StorePreamblesInMemory = true;
   Opts.AsyncThreadsCount = 4; // Consistent!
   Opts.TheiaSemanticHighlighting = true;
-  Opts.AsyncPreambleBuilds = true;
   return Opts;
 }
 
@@ -132,7 +131,6 @@
   Opts.RetentionPolicy = RetentionPolicy;
   Opts.StorePreamblesInMemory = StorePreamblesInMemory;
   Opts.UpdateDebounce = UpdateDebounce;
-  Opts.AsyncPreambleBuilds = AsyncPreambleBuilds;
   Opts.ContextProvider = ContextProvider;
   return Opts;
 }
@@ -141,10 +139,7 @@
                            const ThreadsafeFS &TFS, const Options &Opts,
                            Callbacks *Callbacks)
     : CDB(CDB), TFS(TFS),
-      DynamicIdx(Opts.BuildDynamicSymbolIndex
-                     ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex,
-                                     Opts.CollectMainFileRefs)
-                     : nullptr),
+      DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex() : nullptr),
       ClangTidyProvider(Opts.ClangTidyProvider),
       WorkspaceRoot(Opts.WorkspaceRoot),
       // Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -175,7 +170,6 @@
         Callbacks->onBackgroundIndexProgress(S);
     };
     BGOpts.ContextProvider = Opts.ContextProvider;
-    BGOpts.CollectMainFileRefs = Opts.CollectMainFileRefs;
     BackgroundIdx = std::make_unique<BackgroundIndex>(
         TFS, CDB,
         BackgroundIndexStorage::createDiskBackedStorageFactory(
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to