Index: clang-tools-extra/trunk/clangd/ClangdServer.h =================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.h +++ clang-tools-extra/trunk/clangd/ClangdServer.h @@ -175,10 +175,14 @@ /// will be scheduled and a draft for \p File will not be updated. /// If \p OverridenContents is None, contents of the current draft for \p File /// will be used. - /// This method should only be called for currently tracked files. + /// If \p UsedFS is non-null, it will be overwritten by vfs::FileSystem used + /// for completion. + /// This method should only be called for currently tracked + /// files. Tagged> codeComplete(PathRef File, Position Pos, - llvm::Optional OverridenContents = llvm::None); + llvm::Optional OverridenContents = llvm::None, + IntrusiveRefCntPtr *UsedFS = nullptr); /// Get definition of symbol at a specified \p Line and \p Column in \p File. Tagged> findDefinitions(PathRef File, Position Pos); Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.cpp +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp @@ -192,7 +192,8 @@ Tagged> ClangdServer::codeComplete(PathRef File, Position Pos, - llvm::Optional OverridenContents) { + llvm::Optional OverridenContents, + IntrusiveRefCntPtr *UsedFS) { std::string DraftStorage; if (!OverridenContents) { auto FileContents = DraftMgr.getDraft(File); @@ -203,8 +204,11 @@ OverridenContents = DraftStorage; } - std::vector Result; auto TaggedFS = FSProvider.getTaggedFileSystem(File); + if (UsedFS) + *UsedFS = TaggedFS.Value; + + std::vector Result; Units.runOnUnitWithoutReparse(File, *OverridenContents, ResourceDir, CDB, PCHs, TaggedFS.Value, [&](ClangdUnit &Unit) { Result = Unit.codeComplete(