This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d654df5b982: [clangd] Rename FSProvider to TFS in case of
ThreadsafeFS (authored by kadircet).
Changed prior to commit:
https://reviews.llvm.org/D82024?vs=271988&id=271996#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82024/new/
https://reviews.llvm.org/D82024
Files:
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/Compiler.cpp
clang-tools-extra/clangd/Compiler.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/Background.h
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/ClangdTests.cpp
clang-tools-extra/clangd/unittests/FileIndexTests.cpp
clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
clang-tools-extra/clangd/unittests/HeadersTests.cpp
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
clang-tools-extra/clangd/unittests/PreambleTests.cpp
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp
clang-tools-extra/clangd/unittests/TestTU.h
Index: clang-tools-extra/clangd/unittests/TestTU.h
===================================================================
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -70,7 +70,7 @@
// Suppress this behavior by adding an 'error-ok' comment to the code.
ParsedAST build() const;
std::shared_ptr<const PreambleData> preamble() const;
- ParseInputs inputs(MockFS &FSProvider) const;
+ ParseInputs inputs(MockFS &FS) const;
SymbolSlab headerSymbols() const;
RefSlab headerRefs() const;
std::unique_ptr<SymbolIndex> index() const;
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -20,7 +20,7 @@
namespace clang {
namespace clangd {
-ParseInputs TestTU::inputs(MockFS &FSProvider) const {
+ParseInputs TestTU::inputs(MockFS &FS) const {
std::string FullFilename = testPath(Filename),
FullHeaderName = testPath(HeaderFilename),
ImportThunk = testPath("import_thunk.h");
@@ -29,10 +29,10 @@
// guard without messing up offsets). In this case, use an intermediate file.
std::string ThunkContents = "#import \"" + FullHeaderName + "\"\n";
- FSProvider.Files = AdditionalFiles;
- FSProvider.Files[FullFilename] = Code;
- FSProvider.Files[FullHeaderName] = HeaderCode;
- FSProvider.Files[ImportThunk] = ThunkContents;
+ FS.Files = AdditionalFiles;
+ FS.Files[FullFilename] = Code;
+ FS.Files[FullHeaderName] = HeaderCode;
+ FS.Files[ImportThunk] = ThunkContents;
ParseInputs Inputs;
auto &Argv = Inputs.CompileCommand.CommandLine;
@@ -54,7 +54,7 @@
Inputs.CompileCommand.Filename = FullFilename;
Inputs.CompileCommand.Directory = testRoot();
Inputs.Contents = Code;
- Inputs.FSProvider = &FSProvider;
+ Inputs.TFS = &FS;
Inputs.Opts = ParseOptions();
Inputs.Opts.BuildRecoveryAST = true;
Inputs.Opts.PreserveRecoveryASTType = true;
@@ -67,8 +67,8 @@
}
std::shared_ptr<const PreambleData> TestTU::preamble() const {
- MockFS FSProvider;
- auto Inputs = inputs(FSProvider);
+ MockFS FS;
+ auto Inputs = inputs(FS);
IgnoreDiagnostics Diags;
auto CI = buildCompilerInvocation(Inputs, Diags);
assert(CI && "Failed to build compilation invocation.");
@@ -78,8 +78,8 @@
}
ParsedAST TestTU::build() const {
- MockFS FSProvider;
- auto Inputs = inputs(FSProvider);
+ MockFS FS;
+ auto Inputs = inputs(FS);
StoreDiags Diags;
auto CI = buildCompilerInvocation(Inputs, Diags);
assert(CI && "Failed to build compilation invocation.");
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -74,7 +74,7 @@
ParseInputs getInputs(PathRef File, std::string Contents) {
ParseInputs Inputs;
Inputs.CompileCommand = *CDB.getCompileCommand(File);
- Inputs.FSProvider = &FSProvider;
+ Inputs.TFS = &FS;
Inputs.Contents = std::move(Contents);
Inputs.Opts = ParseOptions();
return Inputs;
@@ -150,7 +150,7 @@
std::move(CB));
}
- MockFS FSProvider;
+ MockFS FS;
MockCompilationDatabase CDB;
};
@@ -161,10 +161,10 @@
TUScheduler S(CDB, optsForTest());
auto Added = testPath("added.cpp");
- FSProvider.Files[Added] = "x";
+ FS.Files[Added] = "x";
auto Missing = testPath("missing.cpp");
- FSProvider.Files[Missing] = "";
+ FS.Files[Missing] = "";
S.update(Added, getInputs(Added, "x"), WantDiagnostics::No);
@@ -425,7 +425,7 @@
for (int I = 0; I < FilesCount; ++I) {
std::string Name = "foo" + std::to_string(I) + ".cpp";
Files.push_back(testPath(Name));
- this->FSProvider.Files[Files.back()] = "";
+ this->FS.Files[Files.back()] = "";
}
StringRef Contents1 = R"cpp(int a;)cpp";
@@ -616,8 +616,8 @@
auto Foo = testPath("foo.cpp");
auto Header = testPath("foo.h");
- FSProvider.Files[Header] = "void foo()";
- FSProvider.Timestamps[Header] = time_t(0);
+ FS.Files[Header] = "void foo()";
+ FS.Timestamps[Header] = time_t(0);
auto WithPreamble = R"cpp(
#include "foo.h"
int main() {}
@@ -685,8 +685,8 @@
auto Source = testPath("foo.cpp");
auto Header = testPath("foo.h");
- FSProvider.Files[Header] = "int a;";
- FSProvider.Timestamps[Header] = time_t(0);
+ FS.Files[Header] = "int a;";
+ FS.Timestamps[Header] = time_t(0);
std::string SourceContents = R"cpp(
#include "foo.h"
@@ -714,7 +714,7 @@
ASSERT_EQ(S.fileStats().lookup(Source).PreambleBuilds, 1u);
// Update to a header should cause a rebuild, though.
- FSProvider.Timestamps[Header] = time_t(1);
+ FS.Timestamps[Header] = time_t(1);
ASSERT_TRUE(DoUpdate(SourceContents));
ASSERT_FALSE(DoUpdate(SourceContents));
ASSERT_EQ(S.fileStats().lookup(Source).ASTBuilds, 2u);
@@ -742,8 +742,8 @@
CDB.ExtraClangFlags.push_back("-I" + testPath("a"));
CDB.ExtraClangFlags.push_back("-I" + testPath("b"));
// Force both directories to exist so they don't get pruned.
- FSProvider.Files.try_emplace("a/__unused__");
- FSProvider.Files.try_emplace("b/__unused__");
+ FS.Files.try_emplace("a/__unused__");
+ FS.Files.try_emplace("b/__unused__");
TUScheduler S(CDB, optsForTest(), captureDiags());
auto Source = testPath("foo.cpp");
@@ -771,8 +771,8 @@
});
S.blockUntilIdle(timeoutSeconds(10));
- FSProvider.Files[HeaderB] = "int b;";
- FSProvider.Timestamps[HeaderB] = time_t(1);
+ FS.Files[HeaderB] = "int b;";
+ FS.Timestamps[HeaderB] = time_t(1);
// The addition of the missing header file triggers a rebuild, no errors.
updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
@@ -784,8 +784,8 @@
// Ensure previous assertions are done before we touch the FS again.
ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
// Add the high-priority header file, which should reintroduce the error.
- FSProvider.Files[HeaderA] = "int a;";
- FSProvider.Timestamps[HeaderA] = time_t(1);
+ FS.Files[HeaderA] = "int a;";
+ FS.Timestamps[HeaderA] = time_t(1);
// This isn't detected: we don't stat a/foo.h to validate the preamble.
updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -70,11 +70,11 @@
// We don't run PP directly over the patch cotents to test production
// behaviour.
auto Bounds = Lexer::ComputePreamble(ModifiedContents, *CI->getLangOpts());
- auto Clang = prepareCompilerInstance(
- std::move(CI), &BaselinePreamble->Preamble,
- llvm::MemoryBuffer::getMemBufferCopy(
- ModifiedContents.slice(0, Bounds.Size).str()),
- PI.FSProvider->view(PI.CompileCommand.Directory), Diags);
+ auto Clang =
+ prepareCompilerInstance(std::move(CI), &BaselinePreamble->Preamble,
+ llvm::MemoryBuffer::getMemBufferCopy(
+ ModifiedContents.slice(0, Bounds.Size).str()),
+ PI.TFS->view(PI.CompileCommand.Directory), Diags);
PreprocessOnlyAction Action;
if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
ADD_FAILURE() << "failed begin source file";
@@ -518,12 +518,12 @@
Annotations Modified(Case.Modified);
TU.Code = Modified.code().str();
- MockFS FSProvider;
- auto PP = PreamblePatch::create(testPath(TU.Filename),
- TU.inputs(FSProvider), *BaselinePreamble);
+ MockFS FS;
+ auto PP = PreamblePatch::create(testPath(TU.Filename), TU.inputs(FS),
+ *BaselinePreamble);
IgnoreDiagnostics Diags;
- auto CI = buildCompilerInvocation(TU.inputs(FSProvider), Diags);
+ auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
ASSERT_TRUE(CI);
const auto ExpectedBounds =
Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -249,11 +249,11 @@
}
TEST(ParsedASTTest, CanBuildInvocationWithUnknownArgs) {
- MockFS FSProvider;
- FSProvider.Files = {{testPath("foo.cpp"), "void test() {}"}};
+ MockFS FS;
+ FS.Files = {{testPath("foo.cpp"), "void test() {}"}};
// Unknown flags should not prevent a build of compiler invocation.
ParseInputs Inputs;
- Inputs.FSProvider = &FSProvider;
+ Inputs.TFS = &FS;
Inputs.CompileCommand.CommandLine = {"clang", "-fsome-unknown-flag",
testPath("foo.cpp")};
IgnoreDiagnostics IgnoreDiags;
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -48,12 +48,12 @@
ParseInputs PI;
PI.CompileCommand = *Cmd;
- PI.FSProvider = &FS;
+ PI.TFS = &FS;
auto CI = buildCompilerInvocation(PI, IgnoreDiags);
EXPECT_TRUE(static_cast<bool>(CI));
// The diagnostic options must be set before creating a CompilerInstance.
CI->getDiagnosticOpts().IgnoreWarnings = true;
- auto VFS = PI.FSProvider->view(Cmd->Directory);
+ auto VFS = PI.TFS->view(Cmd->Directory);
auto Clang = prepareCompilerInstance(
std::move(CI), /*Preamble=*/nullptr,
llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile),
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -51,14 +51,14 @@
class WorkspaceSymbolsTest : public ::testing::Test {
public:
- WorkspaceSymbolsTest() : Server(CDB, FSProvider, optsForTests()) {
+ WorkspaceSymbolsTest() : Server(CDB, FS, optsForTests()) {
// Make sure the test root directory is created.
- FSProvider.Files[testPath("unused")] = "";
+ FS.Files[testPath("unused")] = "";
CDB.ExtraClangFlags = {"-xc++"};
}
protected:
- MockFS FSProvider;
+ MockFS FS;
MockCompilationDatabase CDB;
ClangdServer Server;
int Limit = 0;
@@ -307,10 +307,10 @@
namespace {
class DocumentSymbolsTest : public ::testing::Test {
public:
- DocumentSymbolsTest() : Server(CDB, FSProvider, optsForTests()) {}
+ DocumentSymbolsTest() : Server(CDB, FS, optsForTests()) {}
protected:
- MockFS FSProvider;
+ MockFS FS;
MockCompilationDatabase CDB;
ClangdServer Server;
Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -272,14 +272,14 @@
PI.CompileCommand.Filename = FooCpp;
PI.CompileCommand.CommandLine = {"clang", "-xc++", FooCpp};
- MockFS FSProvider;
- FSProvider.Files[FooCpp] = "";
- FSProvider.Files[FooH] = R"cpp(
+ MockFS FS;
+ FS.Files[FooCpp] = "";
+ FS.Files[FooH] = R"cpp(
namespace ns_in_header {
int func_in_header();
}
)cpp";
- PI.FSProvider = &FSProvider;
+ PI.TFS = &FS;
PI.Contents = R"cpp(
#include "foo.h"
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -272,7 +272,7 @@
TEST_F(ClangdVFSTest, PropagatesContexts) {
static Key<int> Secret;
- struct FSProvider : public ThreadsafeFS {
+ struct ContextReadingFS : public ThreadsafeFS {
IntrusiveRefCntPtr<llvm::vfs::FileSystem>
view(llvm::NoneType) const override {
Got = Context::current().getExisting(Secret);
@@ -924,17 +924,17 @@
// Check that running code completion doesn't stat() a bunch of files from the
// preamble again. (They should be using the preamble's stat-cache)
TEST(ClangdTests, PreambleVFSStatCache) {
- class ListenStatsFSProvider : public ThreadsafeFS {
+ class StatRecordingFS : public ThreadsafeFS {
public:
- ListenStatsFSProvider(llvm::StringMap<unsigned> &CountStats)
+ StatRecordingFS(llvm::StringMap<unsigned> &CountStats)
: CountStats(CountStats) {}
IntrusiveRefCntPtr<llvm::vfs::FileSystem>
view(llvm::NoneType) const override {
- class ListenStatVFS : public llvm::vfs::ProxyFileSystem {
+ class StatRecordingVFS : public llvm::vfs::ProxyFileSystem {
public:
- ListenStatVFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
- llvm::StringMap<unsigned> &CountStats)
+ StatRecordingVFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
+ llvm::StringMap<unsigned> &CountStats)
: ProxyFileSystem(std::move(FS)), CountStats(CountStats) {}
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
@@ -951,8 +951,8 @@
llvm::StringMap<unsigned> &CountStats;
};
- return IntrusiveRefCntPtr<ListenStatVFS>(
- new ListenStatVFS(buildTestFS(Files), CountStats));
+ return IntrusiveRefCntPtr<StatRecordingVFS>(
+ new StatRecordingVFS(buildTestFS(Files), CountStats));
}
// If relative paths are used, they are resolved with testPath().
@@ -961,7 +961,7 @@
};
llvm::StringMap<unsigned> CountStats;
- ListenStatsFSProvider FS(CountStats);
+ StatRecordingFS FS(CountStats);
ErrorCheckingCallbacks DiagConsumer;
MockCompilationDatabase CDB;
ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer);
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===================================================================
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -676,7 +676,7 @@
CCOpts.AllScopes = AllScopesCompletion;
CCOpts.RunParser = CodeCompletionParse;
- RealThreadsafeFS FSProvider;
+ RealThreadsafeFS TFS;
// Initialize and run ClangdLSPServer.
// Change stdin to binary to not lose \r\n on windows.
llvm::sys::ChangeStdinToBinary();
@@ -719,8 +719,7 @@
ClangTidyOptProvider = std::make_unique<tidy::FileOptionsProvider>(
tidy::ClangTidyGlobalOptions(),
/* Default */ EmptyDefaults,
- /* Override */ OverrideClangTidyOptions,
- FSProvider.view(/*CWD=*/llvm::None));
+ /* Override */ OverrideClangTidyOptions, TFS.view(/*CWD=*/llvm::None));
Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
llvm::StringRef File) {
// This function must be thread-safe and tidy option providers are not.
@@ -771,7 +770,7 @@
Opts.AsyncPreambleBuilds = AsyncPreamble;
ClangdLSPServer LSPServer(
- *TransportLayer, FSProvider, CCOpts, RenameOpts, CompileCommandsDirPath,
+ *TransportLayer, TFS, CCOpts, RenameOpts, CompileCommandsDirPath,
/*UseDirBasedCDB=*/CompileArgsFrom == FilesystemCompileArgs,
OffsetEncodingFromFlag, Opts);
llvm::set_thread_name("clangd.main");
Index: clang-tools-extra/clangd/index/Background.h
===================================================================
--- clang-tools-extra/clangd/index/Background.h
+++ clang-tools-extra/clangd/index/Background.h
@@ -178,7 +178,7 @@
bool HadErrors);
// configuration
- const ThreadsafeFS &FSProvider;
+ const ThreadsafeFS &TFS;
const GlobalCompilationDatabase &CDB;
Context BackgroundContext;
Index: clang-tools-extra/clangd/index/Background.cpp
===================================================================
--- clang-tools-extra/clangd/index/Background.cpp
+++ clang-tools-extra/clangd/index/Background.cpp
@@ -90,11 +90,11 @@
} // namespace
BackgroundIndex::BackgroundIndex(
- Context BackgroundContext, const ThreadsafeFS &FSProvider,
+ Context BackgroundContext, const ThreadsafeFS &TFS,
const GlobalCompilationDatabase &CDB,
BackgroundIndexStorage::Factory IndexStorageFactory, size_t ThreadPoolSize,
std::function<void(BackgroundQueue::Stats)> OnProgress)
- : SwapIndex(std::make_unique<MemIndex>()), FSProvider(FSProvider), CDB(CDB),
+ : SwapIndex(std::make_unique<MemIndex>()), TFS(TFS), CDB(CDB),
BackgroundContext(std::move(BackgroundContext)),
Rebuilder(this, &IndexedSymbols, ThreadPoolSize),
IndexStorageFactory(std::move(IndexStorageFactory)),
@@ -244,7 +244,7 @@
SPAN_ATTACH(Tracer, "file", Cmd.Filename);
auto AbsolutePath = getAbsolutePath(Cmd);
- auto FS = FSProvider.view(Cmd.Directory);
+ auto FS = TFS.view(Cmd.Directory);
auto Buf = FS->getBufferForFile(AbsolutePath);
if (!Buf)
return llvm::errorCodeToError(Buf.getError());
@@ -259,7 +259,7 @@
vlog("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
ParseInputs Inputs;
- Inputs.FSProvider = &FSProvider;
+ Inputs.TFS = &TFS;
Inputs.CompileCommand = std::move(Cmd);
IgnoreDiagnostics IgnoreDiags;
auto CI = buildCompilerInvocation(Inputs, IgnoreDiags);
@@ -381,7 +381,7 @@
Rebuilder.loadedShard(LoadedShards);
Rebuilder.doneLoading();
- auto FS = FSProvider.view(/*CWD=*/llvm::None);
+ auto FS = TFS.view(/*CWD=*/llvm::None);
llvm::DenseSet<PathRef> TUsToIndex;
// We'll accept data from stale shards, but ensure the files get reindexed
// soon.
Index: clang-tools-extra/clangd/SourceCode.h
===================================================================
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -168,7 +168,7 @@
/// though the latter may have been overridden in main()!
format::FormatStyle getFormatStyleForFile(llvm::StringRef File,
llvm::StringRef Content,
- const ThreadsafeFS &FSProvider);
+ const ThreadsafeFS &TFS);
/// Cleanup and format the given replacements.
llvm::Expected<tooling::Replacements>
Index: clang-tools-extra/clangd/SourceCode.cpp
===================================================================
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -577,10 +577,10 @@
format::FormatStyle getFormatStyleForFile(llvm::StringRef File,
llvm::StringRef Content,
- const ThreadsafeFS &FSProvider) {
+ const ThreadsafeFS &TFS) {
auto Style = format::getStyle(format::DefaultFormatStyle, File,
format::DefaultFallbackStyle, Content,
- FSProvider.view(/*CWD=*/llvm::None).get());
+ TFS.view(/*CWD=*/llvm::None).get());
if (!Style) {
log("getStyle() failed for file {0}: {1}. Fallback is LLVM style.", File,
Style.takeError());
Index: clang-tools-extra/clangd/Preamble.cpp
===================================================================
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -252,7 +252,7 @@
// Build and run Preprocessor over the preamble.
ParseInputs PI;
PI.Contents = Contents.str();
- PI.FSProvider = FSProvider.get();
+ PI.TFS = FSProvider.get();
PI.CompileCommand = Cmd;
IgnoringDiagConsumer IgnoreDiags;
auto CI = buildCompilerInvocation(PI, IgnoreDiags);
@@ -358,7 +358,7 @@
CI.getPreprocessorOpts().WriteCommentListToPCH = false;
CppFilePreambleCallbacks SerializedDeclsCollector(FileName, PreambleCallback);
- auto VFS = Inputs.FSProvider->view(Inputs.CompileCommand.Directory);
+ auto VFS = Inputs.TFS->view(Inputs.CompileCommand.Directory);
llvm::SmallString<32> AbsFileName(FileName);
VFS->makeAbsolute(AbsFileName);
auto StatCache = std::make_unique<PreambleFileStatusCache>(AbsFileName);
@@ -395,7 +395,7 @@
llvm::MemoryBuffer::getMemBuffer(Inputs.Contents, FileName);
auto Bounds =
ComputePreambleBounds(*CI.getLangOpts(), ContentsBuffer.get(), 0);
- auto VFS = Inputs.FSProvider->view(Inputs.CompileCommand.Directory);
+ auto VFS = Inputs.TFS->view(Inputs.CompileCommand.Directory);
return compileCommandsAreEqual(Inputs.CompileCommand,
Preamble.CompileCommand) &&
Preamble.Preamble.CanReuse(CI, ContentsBuffer.get(), Bounds,
@@ -423,7 +423,7 @@
SPAN_ATTACH(Tracer, "File", FileName);
assert(llvm::sys::path::is_absolute(FileName) && "relative FileName!");
auto VFS = Baseline.StatCache->getConsumingFS(
- Modified.FSProvider->view(/*CWD=*/llvm::None));
+ Modified.TFS->view(/*CWD=*/llvm::None));
// First scan preprocessor directives in Baseline and Modified. These will be
// used to figure out newly added directives in Modified. Scanning can fail,
// the code just bails out and creates an empty patch in such cases, as:
Index: clang-tools-extra/clangd/ParsedAST.cpp
===================================================================
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -249,7 +249,7 @@
trace::Span Tracer("BuildAST");
SPAN_ATTACH(Tracer, "File", Filename);
- auto VFS = Inputs.FSProvider->view(Inputs.CompileCommand.Directory);
+ auto VFS = Inputs.TFS->view(Inputs.CompileCommand.Directory);
if (Preamble && Preamble->StatCache)
VFS = Preamble->StatCache->getConsumingFS(std::move(VFS));
@@ -355,8 +355,7 @@
auto BuildDir = VFS->getCurrentWorkingDirectory();
if (Inputs.Opts.SuggestMissingIncludes && Inputs.Index &&
!BuildDir.getError()) {
- auto Style =
- getFormatStyleForFile(Filename, Inputs.Contents, *Inputs.FSProvider);
+ auto Style = getFormatStyleForFile(Filename, Inputs.Contents, *Inputs.TFS);
auto Inserter = std::make_shared<IncludeInserter>(
Filename, Inputs.Contents, Style, BuildDir.get(),
&Clang->getPreprocessor().getHeaderSearchInfo());
Index: clang-tools-extra/clangd/Compiler.h
===================================================================
--- clang-tools-extra/clangd/Compiler.h
+++ clang-tools-extra/clangd/Compiler.h
@@ -46,7 +46,7 @@
/// Information required to run clang, e.g. to parse AST or do code completion.
struct ParseInputs {
tooling::CompileCommand CompileCommand;
- const ThreadsafeFS *FSProvider;
+ const ThreadsafeFS *TFS;
std::string Contents;
// Version identifier for Contents, provided by the client and opaque to us.
std::string Version = "null";
Index: clang-tools-extra/clangd/Compiler.cpp
===================================================================
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -48,7 +48,7 @@
for (const auto &S : Inputs.CompileCommand.CommandLine)
ArgStrs.push_back(S.c_str());
- auto VFS = Inputs.FSProvider->view(Inputs.CompileCommand.Directory);
+ auto VFS = Inputs.TFS->view(Inputs.CompileCommand.Directory);
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> CommandLineDiagsEngine =
CompilerInstance::createDiagnostics(new DiagnosticOptions, &D, false);
std::unique_ptr<CompilerInvocation> CI = createInvocationFromCommandLine(
Index: clang-tools-extra/clangd/CodeComplete.cpp
===================================================================
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1113,8 +1113,7 @@
// NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise
// the remapped buffers do not get freed.
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
- Input.ParseInput.FSProvider->view(
- Input.ParseInput.CompileCommand.Directory);
+ Input.ParseInput.TFS->view(Input.ParseInput.CompileCommand.Directory);
if (Input.Preamble.StatCache)
VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
auto Clang = prepareCompilerInstance(
@@ -1292,7 +1291,7 @@
IsUsingDeclaration = Recorder->CCContext.isUsingDeclaration();
auto Style = getFormatStyleForFile(SemaCCInput.FileName,
SemaCCInput.ParseInput.Contents,
- *SemaCCInput.ParseInput.FSProvider);
+ *SemaCCInput.ParseInput.TFS);
const auto NextToken = Lexer::findNextToken(
Recorder->CCSema->getPreprocessor().getCodeCompletionLoc(),
Recorder->CCSema->getSourceManager(), Recorder->CCSema->LangOpts);
@@ -1364,7 +1363,7 @@
}
CodeCompleteResult runWithoutSema(llvm::StringRef Content, size_t Offset,
- const ThreadsafeFS &FSProvider) && {
+ const ThreadsafeFS &TFS) && {
trace::Span Tracer("CodeCompleteWithoutSema");
// Fill in fields normally set by runWithSema()
HeuristicPrefix = guessCompletionPrefix(Content, Offset);
@@ -1380,7 +1379,7 @@
ProxSources[FileName].Cost = 0;
FileProximity.emplace(ProxSources);
- auto Style = getFormatStyleForFile(FileName, Content, FSProvider);
+ auto Style = getFormatStyleForFile(FileName, Content, TFS);
// This will only insert verbatim headers.
Inserter.emplace(FileName, Content, Style,
/*BuildDir=*/"", /*HeaderSearchInfo=*/nullptr);
@@ -1781,7 +1780,7 @@
SpecFuzzyFind, Opts);
return (!Preamble || Opts.RunParser == CodeCompleteOptions::NeverParse)
? std::move(Flow).runWithoutSema(ParseInput.Contents, *Offset,
- *ParseInput.FSProvider)
+ *ParseInput.TFS)
: std::move(Flow).run({FileName, *Offset, *Preamble,
// We want to serve code completions with
// low latency, so don't bother patching.
Index: clang-tools-extra/clangd/ClangdServer.h
===================================================================
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -171,9 +171,8 @@
/// added file (i.e., when processing a first call to addDocument) and reuses
/// those arguments for subsequent reparses. However, ClangdServer will check
/// if compilation arguments changed on calls to forceReparse().
- ClangdServer(const GlobalCompilationDatabase &CDB,
- const ThreadsafeFS &FSProvider, const Options &Opts,
- Callbacks *Callbacks = nullptr);
+ ClangdServer(const GlobalCompilationDatabase &CDB, const ThreadsafeFS &TFS,
+ const Options &Opts, Callbacks *Callbacks = nullptr);
/// Add a \p File to the list of tracked C++ files or update the contents if
/// \p File is already tracked. Also schedules parsing of the AST for it on a
@@ -330,7 +329,7 @@
formatCode(llvm::StringRef Code, PathRef File,
ArrayRef<tooling::Range> Ranges);
- const ThreadsafeFS &FSProvider;
+ const ThreadsafeFS &TFS;
Path ResourceDir;
// The index used to look up symbols. This could be:
Index: clang-tools-extra/clangd/ClangdServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -130,9 +130,9 @@
}
ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
- const ThreadsafeFS &FSProvider, const Options &Opts,
+ const ThreadsafeFS &TFS, const Options &Opts,
Callbacks *Callbacks)
- : FSProvider(FSProvider),
+ : TFS(TFS),
DynamicIdx(Opts.BuildDynamicSymbolIndex
? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
: nullptr),
@@ -163,7 +163,7 @@
AddIndex(Opts.StaticIndex);
if (Opts.BackgroundIndex) {
BackgroundIdx = std::make_unique<BackgroundIndex>(
- Context::current().clone(), FSProvider, CDB,
+ Context::current().clone(), TFS, CDB,
BackgroundIndexStorage::createDiskBackedStorageFactory(
[&CDB](llvm::StringRef File) { return CDB.getProjectInfo(File); }),
std::max(Opts.AsyncThreadsCount, 1u),
@@ -185,12 +185,12 @@
// FIXME: call tidy options builder on the worker thread, it can do IO.
if (GetClangTidyOptions)
Opts.ClangTidyOpts =
- GetClangTidyOptions(*FSProvider.view(/*CWD=*/llvm::None), File);
+ GetClangTidyOptions(*TFS.view(/*CWD=*/llvm::None), File);
Opts.SuggestMissingIncludes = SuggestMissingIncludes;
// Compile command is set asynchronously during update, as it can be slow.
ParseInputs Inputs;
- Inputs.FSProvider = &FSProvider;
+ Inputs.TFS = &TFS;
Inputs.Contents = std::string(Contents);
Inputs.Version = Version.str();
Inputs.ForceRebuild = ForceRebuild;
@@ -237,7 +237,7 @@
}
}
}
- ParseInputs ParseInput{IP->Command, &FSProvider, IP->Contents.str()};
+ ParseInputs ParseInput{IP->Command, &TFS, IP->Contents.str()};
ParseInput.Index = Index;
ParseInput.Opts.BuildRecoveryAST = BuildRecoveryAST;
ParseInput.Opts.PreserveRecoveryASTType = PreserveRecoveryASTType;
@@ -284,7 +284,7 @@
return CB(llvm::createStringError(llvm::inconvertibleErrorCode(),
"Failed to parse includes"));
- ParseInputs ParseInput{IP->Command, &FSProvider, IP->Contents.str()};
+ ParseInputs ParseInput{IP->Command, &TFS, IP->Contents.str()};
ParseInput.Index = Index;
ParseInput.Opts.BuildRecoveryAST = BuildRecoveryAST;
ParseInput.Opts.PreserveRecoveryASTType = PreserveRecoveryASTType;
@@ -321,7 +321,7 @@
return CursorPos.takeError();
auto Style = format::getStyle(format::DefaultFormatStyle, File,
format::DefaultFallbackStyle, Code,
- FSProvider.view(/*CWD=*/llvm::None).get());
+ TFS.view(/*CWD=*/llvm::None).get());
if (!Style)
return Style.takeError();
@@ -398,7 +398,7 @@
if (Opts.WantFormat) {
auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
- *InpAST->Inputs.FSProvider);
+ *InpAST->Inputs.TFS);
llvm::Error Err = llvm::Error::success();
for (auto &E : *Edits)
Err =
@@ -499,7 +499,7 @@
for (auto &It : (*Effect)->ApplyEdits) {
Edit &E = It.second;
format::FormatStyle Style =
- getFormatStyleForFile(File, E.InitialCode, FSProvider);
+ getFormatStyleForFile(File, E.InitialCode, TFS);
if (llvm::Error Err = reformatEdit(E, Style))
elog("Failed to format {0}: {1}", It.first(), std::move(Err));
}
@@ -550,7 +550,7 @@
// 2) if 1) fails, we use the AST&Index approach, it is slower but supports
// different code layout.
if (auto CorrespondingFile = getCorrespondingHeaderOrSource(
- std::string(Path), FSProvider.view(llvm::None)))
+ std::string(Path), TFS.view(llvm::None)))
return CB(std::move(CorrespondingFile));
auto Action = [Path = Path.str(), CB = std::move(CB),
this](llvm::Expected<InputsAndAST> InpAST) mutable {
@@ -565,7 +565,7 @@
ClangdServer::formatCode(llvm::StringRef Code, PathRef File,
llvm::ArrayRef<tooling::Range> Ranges) {
// Call clang-format.
- format::FormatStyle Style = getFormatStyleForFile(File, Code, FSProvider);
+ format::FormatStyle Style = getFormatStyleForFile(File, Code, TFS);
tooling::Replacements IncludeReplaces =
format::sortIncludes(Style, Code, Ranges, File);
auto Changed = tooling::applyAllReplacements(Code, IncludeReplaces);
@@ -598,7 +598,7 @@
if (!InpAST)
return CB(InpAST.takeError());
format::FormatStyle Style = getFormatStyleForFile(
- File, InpAST->Inputs.Contents, *InpAST->Inputs.FSProvider);
+ File, InpAST->Inputs.Contents, *InpAST->Inputs.TFS);
CB(clangd::getHover(InpAST->AST, Pos, std::move(Style), Index));
};
Index: clang-tools-extra/clangd/ClangdLSPServer.h
===================================================================
--- clang-tools-extra/clangd/ClangdLSPServer.h
+++ clang-tools-extra/clangd/ClangdLSPServer.h
@@ -41,7 +41,7 @@
/// for compile_commands.json in all parent directories of each file.
/// If UseDirBasedCDB is false, compile commands are not read from disk.
// FIXME: Clean up signature around CDBs.
- ClangdLSPServer(Transport &Transp, const ThreadsafeFS &FSProvider,
+ ClangdLSPServer(Transport &Transp, const ThreadsafeFS &TFS,
const clangd::CodeCompleteOptions &CCOpts,
const clangd::RenameOptions &RenameOpts,
llvm::Optional<Path> CompileCommandsDir, bool UseDirBasedCDB,
@@ -207,7 +207,7 @@
notify("$/progress", Params);
}
- const ThreadsafeFS &FSProvider;
+ const ThreadsafeFS &TFS;
/// Options used for code completion
clangd::CodeCompleteOptions CCOpts;
/// Options used for rename.
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -524,7 +524,7 @@
if (NegotiatedOffsetEncoding)
WithOffsetEncoding.emplace(kCurrentOffsetEncoding,
*NegotiatedOffsetEncoding);
- Server.emplace(*CDB, FSProvider, ClangdServerOpts,
+ Server.emplace(*CDB, TFS, ClangdServerOpts,
static_cast<ClangdServer::Callbacks *>(this));
}
applyConfiguration(Params.initializationOptions.ConfigSettings);
@@ -1340,16 +1340,15 @@
}
ClangdLSPServer::ClangdLSPServer(
- class Transport &Transp, const ThreadsafeFS &FSProvider,
+ class Transport &Transp, const ThreadsafeFS &TFS,
const clangd::CodeCompleteOptions &CCOpts,
const clangd::RenameOptions &RenameOpts,
llvm::Optional<Path> CompileCommandsDir, bool UseDirBasedCDB,
llvm::Optional<OffsetEncoding> ForcedOffsetEncoding,
const ClangdServer::Options &Opts)
: BackgroundContext(Context::current().clone()), Transp(Transp),
- MsgHandler(new MessageHandler(*this)), FSProvider(FSProvider),
- CCOpts(CCOpts), RenameOpts(RenameOpts),
- SupportedSymbolKinds(defaultSymbolKinds()),
+ MsgHandler(new MessageHandler(*this)), TFS(TFS), CCOpts(CCOpts),
+ RenameOpts(RenameOpts), SupportedSymbolKinds(defaultSymbolKinds()),
SupportedCompletionItemKinds(defaultCompletionItemKinds()),
UseDirBasedCDB(UseDirBasedCDB),
CompileCommandsDir(std::move(CompileCommandsDir)), ClangdServerOpts(Opts),
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits