[clang-tools-extra] [clangd] Propagate context into stdlib indexing thread (PR #87611)
kadir çetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 16 01:07:06 PDT 2024
https://github.com/kadircet updated https://github.com/llvm/llvm-project/pull/87611
>From a5cc9640c05ad06bff6ec28c958669df4b7e8214 Mon Sep 17 00:00:00 2001
From: Kadir Cetinkaya <kadircet at google.com>
Date: Thu, 4 Apr 2024 10:57:44 +0200
Subject: [PATCH] [clangd] Propagate context into stdlib indexing thread
Some FS implementations rely on snapshots available in the context.
---
clang-tools-extra/clangd/ClangdServer.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
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