[clang-tools-extra] r344118 - [clangd] Make FSProvider const-correct. NFC
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 10 00:46:15 PDT 2018
Author: sammccall
Date: Wed Oct 10 00:46:15 2018
New Revision: 344118
URL: http://llvm.org/viewvc/llvm-project?rev=344118&view=rev
Log:
[clangd] Make FSProvider const-correct. NFC
Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/FSProvider.h
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
clang-tools-extra/trunk/unittests/clangd/TestFS.h
Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=344118&r1=344117&r2=344118&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Oct 10 00:46:15 2018
@@ -97,8 +97,8 @@ ClangdServer::Options ClangdServer::opts
return Opts;
}
-ClangdServer::ClangdServer(GlobalCompilationDatabase &CDB,
- FileSystemProvider &FSProvider,
+ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
+ const FileSystemProvider &FSProvider,
DiagnosticsConsumer &DiagConsumer,
const Options &Opts)
: CDB(CDB), DiagConsumer(DiagConsumer), FSProvider(FSProvider),
Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=344118&r1=344117&r2=344118&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Oct 10 00:46:15 2018
@@ -109,7 +109,8 @@ public:
/// \p DiagConsumer. Note that a callback to \p DiagConsumer happens on a
/// worker thread. Therefore, instances of \p DiagConsumer must properly
/// synchronize access to shared state.
- ClangdServer(GlobalCompilationDatabase &CDB, FileSystemProvider &FSProvider,
+ ClangdServer(const GlobalCompilationDatabase &CDB,
+ const FileSystemProvider &FSProvider,
DiagnosticsConsumer &DiagConsumer, const Options &Opts);
/// Set the root path of the workspace.
@@ -227,9 +228,9 @@ private:
tooling::CompileCommand getCompileCommand(PathRef File);
- GlobalCompilationDatabase &CDB;
+ const GlobalCompilationDatabase &CDB;
DiagnosticsConsumer &DiagConsumer;
- FileSystemProvider &FSProvider;
+ const FileSystemProvider &FSProvider;
/// Used to synchronize diagnostic responses for added and removed files.
llvm::StringMap<DocVersion> InternalVersion;
Modified: clang-tools-extra/trunk/clangd/FSProvider.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FSProvider.h?rev=344118&r1=344117&r2=344118&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/FSProvider.h (original)
+++ clang-tools-extra/trunk/clangd/FSProvider.h Wed Oct 10 00:46:15 2018
@@ -25,13 +25,13 @@ public:
/// Context::current() will be the context passed to the clang entrypoint,
/// such as addDocument(), and will also be propagated to result callbacks.
/// Embedders may use this to isolate filesystem accesses.
- virtual IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() = 0;
+ virtual IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() const = 0;
};
class RealFileSystemProvider : public FileSystemProvider {
public:
// FIXME: returns the single real FS instance, which is not threadsafe.
- IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() override {
+ IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() const override {
return vfs::getRealFileSystem();
}
};
Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=344118&r1=344117&r2=344118&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Wed Oct 10 00:46:15 2018
@@ -264,11 +264,11 @@ int b = a;
TEST_F(ClangdVFSTest, PropagatesContexts) {
static Key<int> Secret;
struct FSProvider : public FileSystemProvider {
- IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() override {
+ IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() const override {
Got = Context::current().getExisting(Secret);
return buildTestFS({});
}
- int Got;
+ mutable int Got;
} FS;
struct DiagConsumer : public DiagnosticsConsumer {
void onDiagnosticsReady(PathRef File,
@@ -973,7 +973,7 @@ TEST(ClangdTests, PreambleVFSStatCache)
ListenStatsFSProvider(llvm::StringMap<unsigned> &CountStats)
: CountStats(CountStats) {}
- IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() override {
+ IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() const override {
class ListenStatVFS : public vfs::ProxyFileSystem {
public:
ListenStatVFS(IntrusiveRefCntPtr<vfs::FileSystem> FS,
Modified: clang-tools-extra/trunk/unittests/clangd/TestFS.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TestFS.h?rev=344118&r1=344117&r2=344118&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/TestFS.h (original)
+++ clang-tools-extra/trunk/unittests/clangd/TestFS.h Wed Oct 10 00:46:15 2018
@@ -29,7 +29,7 @@ buildTestFS(llvm::StringMap<std::string>
// A VFS provider that returns TestFSes containing a provided set of files.
class MockFSProvider : public FileSystemProvider {
public:
- IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() override {
+ IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() const override {
return buildTestFS(Files);
}
More information about the cfe-commits
mailing list