[clang-tools-extra] acd736e - [clangd] Propagate context into stdlib indexing thread (#87611)

via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 18 08:05:09 PDT 2024


Author: kadir çetinkaya
Date: 2024-04-18T17:05:05+02:00
New Revision: acd736e3e1e7b8a20e28ed17fb59595ce1e670bb

URL: https://github.com/llvm/llvm-project/commit/acd736e3e1e7b8a20e28ed17fb59595ce1e670bb
DIFF: https://github.com/llvm/llvm-project/commit/acd736e3e1e7b8a20e28ed17fb59595ce1e670bb.diff

LOG: [clangd] Propagate context into stdlib indexing thread (#87611)

Some FS implementations rely on snapshots available in the context.

Added: 
    

Modified: 
    clang-tools-extra/clangd/ClangdServer.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp
index 5790273d625ef1..1c4c2a79b5c051 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -30,6 +30,7 @@
 #include "refactor/Rename.h"
 #include "refactor/Tweak.h"
 #include "support/Cancellation.h"
+#include "support/Context.h"
 #include "support/Logger.h"
 #include "support/MemoryTree.h"
 #include "support/ThreadsafeFS.h"
@@ -112,7 +113,12 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
                  // Index outlives TUScheduler (declared first)
                  FIndex(FIndex),
                  // shared_ptr extends lifetime
-                 Stdlib(Stdlib)]() mutable {
+                 Stdlib(Stdlib),
+                 // We have some FS implementations that rely on information in
+                 // the context.
+                 Ctx(Context::current().clone())]() mutable {
+      // Make sure we install the context into current thread.
+      WithContext C(std::move(Ctx));
       clang::noteBottomOfStack();
       IndexFileIn IF;
       IF.Symbols = indexStandardLibrary(std::move(CI), Loc, *TFS);


        


More information about the cfe-commits mailing list