diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -185,7 +185,7 @@ // FIXME: call tidy options builder on the worker thread, it can do IO. if (GetClangTidyOptions) Opts.ClangTidyOpts = - GetClangTidyOptions(*TFS.view(/*CWD=*/llvm::None), File); + GetClangTidyOptions(*TFS.viewWithDefaultCWD(), File); Opts.SuggestMissingIncludes = SuggestMissingIncludes; // Compile command is set asynchronously during update, as it can be slow. @@ -321,7 +321,7 @@ return CursorPos.takeError(); auto Style = format::getStyle(format::DefaultFormatStyle, File, format::DefaultFallbackStyle, Code, - TFS.view(/*CWD=*/llvm::None).get()); + TFS.viewWithDefaultCWD().get()); if (!Style) return Style.takeError(); @@ -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), TFS.view(llvm::None))) + std::string(Path), TFS.viewWithDefaultCWD())) return CB(std::move(CorrespondingFile)); auto Action = [Path = Path.str(), CB = std::move(CB), this](llvm::Expected InpAST) mutable { diff --git a/clang-tools-extra/clangd/Preamble.cpp b/clang-tools-extra/clangd/Preamble.cpp --- a/clang-tools-extra/clangd/Preamble.cpp +++ b/clang-tools-extra/clangd/Preamble.cpp @@ -231,7 +231,7 @@ class EmptyFS : public ThreadsafeFS { public: llvm::IntrusiveRefCntPtr - view(llvm::NoneType) const override { + viewWithDefaultCWD() const override { return new llvm::vfs::InMemoryFileSystem; } }; @@ -259,7 +259,7 @@ std::move(CI), nullptr, std::move(PreambleContents), // Provide an empty FS to prevent preprocessor from performing IO. This // also implies missing resolved paths for includes. - FS.view(llvm::None), IgnoreDiags); + FS.viewWithDefaultCWD(), IgnoreDiags); if (Clang->getFrontendOpts().Inputs.empty()) return llvm::createStringError(llvm::inconvertibleErrorCode(), "compiler instance had no inputs"); diff --git a/clang-tools-extra/clangd/SourceCode.cpp b/clang-tools-extra/clangd/SourceCode.cpp --- a/clang-tools-extra/clangd/SourceCode.cpp +++ b/clang-tools-extra/clangd/SourceCode.cpp @@ -580,7 +580,7 @@ const ThreadsafeFS &TFS) { auto Style = format::getStyle(format::DefaultFormatStyle, File, format::DefaultFallbackStyle, Content, - TFS.view(/*CWD=*/llvm::None).get()); + TFS.viewWithDefaultCWD().get()); if (!Style) { log("getStyle() failed for file {0}: {1}. Fallback is LLVM style.", File, Style.takeError()); diff --git a/clang-tools-extra/clangd/index/Background.cpp b/clang-tools-extra/clangd/index/Background.cpp --- a/clang-tools-extra/clangd/index/Background.cpp +++ b/clang-tools-extra/clangd/index/Background.cpp @@ -380,7 +380,7 @@ Rebuilder.loadedShard(LoadedShards); Rebuilder.doneLoading(); - auto FS = TFS.view(/*CWD=*/llvm::None); + auto FS = TFS.viewWithDefaultCWD(); llvm::DenseSet TUsToIndex; // We'll accept data from stale shards, but ensure the files get reindexed // soon. diff --git a/clang-tools-extra/clangd/support/ThreadsafeFS.h b/clang-tools-extra/clangd/support/ThreadsafeFS.h --- a/clang-tools-extra/clangd/support/ThreadsafeFS.h +++ b/clang-tools-extra/clangd/support/ThreadsafeFS.h @@ -31,19 +31,19 @@ /// Obtain a vfs::FileSystem with an arbitrary initial working directory. virtual llvm::IntrusiveRefCntPtr - view(llvm::NoneType CWD) const = 0; + viewWithDefaultCWD() const = 0; /// Obtain a vfs::FileSystem with a specified working directory. /// If the working directory can't be set (e.g. doesn't exist), logs and /// returns the FS anyway. - virtual llvm::IntrusiveRefCntPtr + llvm::IntrusiveRefCntPtr view(PathRef CWD) const; }; class RealThreadsafeFS : public ThreadsafeFS { public: llvm::IntrusiveRefCntPtr - view(llvm::NoneType) const override; + viewWithDefaultCWD() const override; }; } // namespace clangd diff --git a/clang-tools-extra/clangd/support/ThreadsafeFS.cpp b/clang-tools-extra/clangd/support/ThreadsafeFS.cpp --- a/clang-tools-extra/clangd/support/ThreadsafeFS.cpp +++ b/clang-tools-extra/clangd/support/ThreadsafeFS.cpp @@ -76,14 +76,14 @@ llvm::IntrusiveRefCntPtr ThreadsafeFS::view(PathRef CWD) const { - auto FS = view(llvm::None); + auto FS = viewWithDefaultCWD(); if (auto EC = FS->setCurrentWorkingDirectory(CWD)) elog("VFS: failed to set CWD to {0}: {1}", CWD, EC.message()); return FS; } llvm::IntrusiveRefCntPtr -RealThreadsafeFS::view(llvm::NoneType) const { +RealThreadsafeFS::viewWithDefaultCWD() const { // Avoid using memory-mapped files. // FIXME: Try to use a similar approach in Sema instead of relying on // propagation of the 'isVolatile' flag through all layers. diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp --- a/clang-tools-extra/clangd/tool/ClangdMain.cpp +++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp @@ -719,7 +719,7 @@ ClangTidyOptProvider = std::make_unique( tidy::ClangTidyGlobalOptions(), /* Default */ EmptyDefaults, - /* Override */ OverrideClangTidyOptions, TFS.view(/*CWD=*/llvm::None)); + /* Override */ OverrideClangTidyOptions, TFS.viewWithDefaultCWD()); Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &, llvm::StringRef File) { // This function must be thread-safe and tidy option providers are not. diff --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp b/clang-tools-extra/clangd/unittests/ClangdTests.cpp --- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp +++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp @@ -274,7 +274,7 @@ static Key Secret; struct ContextReadingFS : public ThreadsafeFS { IntrusiveRefCntPtr - view(llvm::NoneType) const override { + viewWithDefaultCWD() const override { Got = Context::current().getExisting(Secret); return buildTestFS({}); } @@ -930,7 +930,7 @@ : CountStats(CountStats) {} IntrusiveRefCntPtr - view(llvm::NoneType) const override { + viewWithDefaultCWD() const override { class StatRecordingVFS : public llvm::vfs::ProxyFileSystem { public: StatRecordingVFS(IntrusiveRefCntPtr FS, diff --git a/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp b/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp --- a/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp +++ b/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp @@ -30,11 +30,11 @@ FS.Files[FooH]; FS.Files[Invalid]; Optional PathResult = - getCorrespondingHeaderOrSource(FooCpp, FS.view(llvm::None)); + getCorrespondingHeaderOrSource(FooCpp, FS.viewWithDefaultCWD()); EXPECT_TRUE(PathResult.hasValue()); ASSERT_EQ(PathResult.getValue(), FooH); - PathResult = getCorrespondingHeaderOrSource(FooH, FS.view(llvm::None)); + PathResult = getCorrespondingHeaderOrSource(FooH, FS.viewWithDefaultCWD()); EXPECT_TRUE(PathResult.hasValue()); ASSERT_EQ(PathResult.getValue(), FooCpp); @@ -45,7 +45,7 @@ FS.Files[FooC]; FS.Files[FooHH]; - PathResult = getCorrespondingHeaderOrSource(FooC, FS.view(llvm::None)); + PathResult = getCorrespondingHeaderOrSource(FooC, FS.viewWithDefaultCWD()); EXPECT_TRUE(PathResult.hasValue()); ASSERT_EQ(PathResult.getValue(), FooHH); @@ -54,7 +54,7 @@ auto Foo2HH = testPath("foo2.HH"); FS.Files[Foo2C]; FS.Files[Foo2HH]; - PathResult = getCorrespondingHeaderOrSource(Foo2C, FS.view(llvm::None)); + PathResult = getCorrespondingHeaderOrSource(Foo2C, FS.viewWithDefaultCWD()); EXPECT_TRUE(PathResult.hasValue()); ASSERT_EQ(PathResult.getValue(), Foo2HH); @@ -64,13 +64,13 @@ FS.Files[Foo3C]; FS.Files[Foo3HXX]; - PathResult = getCorrespondingHeaderOrSource(Foo3C, FS.view(llvm::None)); + PathResult = getCorrespondingHeaderOrSource(Foo3C, FS.viewWithDefaultCWD()); EXPECT_TRUE(PathResult.hasValue()); ASSERT_EQ(PathResult.getValue(), Foo3HXX); // Test if asking for a corresponding file that doesn't exist returns an empty // string. - PathResult = getCorrespondingHeaderOrSource(Invalid, FS.view(llvm::None)); + PathResult = getCorrespondingHeaderOrSource(Invalid, FS.viewWithDefaultCWD()); EXPECT_FALSE(PathResult.hasValue()); } diff --git a/clang-tools-extra/clangd/unittests/TestFS.h b/clang-tools-extra/clangd/unittests/TestFS.h --- a/clang-tools-extra/clangd/unittests/TestFS.h +++ b/clang-tools-extra/clangd/unittests/TestFS.h @@ -34,7 +34,7 @@ class MockFS : public ThreadsafeFS { public: IntrusiveRefCntPtr - view(llvm::NoneType) const override { + viewWithDefaultCWD() const override { return buildTestFS(Files, Timestamps); }