[PATCH] D92000: [clangd] Collect main file refs by default

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 25 17:34:17 PST 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc6cb47b640ff: [clangd] Collect main file refs by default (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92000

Files:
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp


Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -188,8 +188,10 @@
   size_t CacheHits = 0;
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
-  BackgroundIndex Idx(FS, CDB, [&](llvm::StringRef) { return &MSS; },
-                      /*Opts=*/{});
+  BackgroundIndex::Options Opts;
+  Opts.CollectMainFileRefs = true;
+  BackgroundIndex Idx(
+      FS, CDB, [&](llvm::StringRef) { return &MSS; }, Opts);
 
   tooling::CompileCommand Cmd;
   Cmd.Filename = testPath("root/A.cc");
@@ -201,7 +203,7 @@
   EXPECT_THAT(runFuzzyFind(Idx, ""),
               UnorderedElementsAre(AllOf(Named("common"), NumReferences(1U)),
                                    AllOf(Named("A_CC"), NumReferences(0U)),
-                                   AllOf(Named("g"), NumReferences(0U)),
+                                   AllOf(Named("g"), NumReferences(1U)),
                                    AllOf(Named("f_b"), Declared(),
                                          Not(Defined()), NumReferences(0U))));
 
@@ -214,7 +216,7 @@
   EXPECT_THAT(runFuzzyFind(Idx, ""),
               UnorderedElementsAre(AllOf(Named("common"), NumReferences(5U)),
                                    AllOf(Named("A_CC"), NumReferences(0U)),
-                                   AllOf(Named("g"), NumReferences(0U)),
+                                   AllOf(Named("g"), NumReferences(1U)),
                                    AllOf(Named("f_b"), Declared(), Defined(),
                                          NumReferences(1U))));
 
@@ -238,7 +240,8 @@
   FS.Files[testPath("root/A.cc")] =
       "#include \"A.h\"\nstatic void main_sym() { (void)header_sym; }";
 
-  // Check the behaviour with CollectMainFileRefs = false (the default).
+  // Check the behaviour with CollectMainFileRefs = false (the default
+  // at the SymbolCollector level).
   {
     llvm::StringMap<std::string> Storage;
     size_t CacheHits = 0;
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===================================================================
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -494,7 +494,7 @@
     "collect-main-file-refs",
     cat(Misc),
     desc("Store references to main-file-only symbols in the index"),
-    init(false),
+    init(ClangdServer::Options().CollectMainFileRefs),
 };
 
 #if CLANGD_ENABLE_REMOTE
Index: clang-tools-extra/clangd/ClangdServer.h
===================================================================
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -106,7 +106,7 @@
     bool BackgroundIndex = false;
 
     /// Store refs to main-file symbols in the index.
-    bool CollectMainFileRefs = false;
+    bool CollectMainFileRefs = true;
 
     /// If set, use this index to augment code completion results.
     SymbolIndex *StaticIndex = nullptr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92000.307732.patch
Type: text/x-patch
Size: 3105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201126/2243f7a1/attachment-0001.bin>


More information about the cfe-commits mailing list