This revision was automatically updated to reflect the committed changes. Closed by commit rG72568984b804: [clangd] Suppress GCC -Woverloaded-virtual by renaming ThreadsafeFS extension… (authored by sammccall).
Changed prior to commit: https://reviews.llvm.org/D82793?vs=274181&id=274451#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82793/new/ https://reviews.llvm.org/D82793 Files: clang-tools-extra/clangd/Preamble.cpp clang-tools-extra/clangd/support/ThreadsafeFS.cpp clang-tools-extra/clangd/support/ThreadsafeFS.h clang-tools-extra/clangd/unittests/ClangdTests.cpp clang-tools-extra/clangd/unittests/TestFS.h
Index: clang-tools-extra/clangd/unittests/TestFS.h =================================================================== --- clang-tools-extra/clangd/unittests/TestFS.h +++ clang-tools-extra/clangd/unittests/TestFS.h @@ -33,8 +33,7 @@ // A VFS provider that returns TestFSes containing a provided set of files. class MockFS : public ThreadsafeFS { public: - IntrusiveRefCntPtr<llvm::vfs::FileSystem> - view(llvm::NoneType) const override { + IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const override { return buildTestFS(Files, Timestamps); } Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ClangdTests.cpp +++ clang-tools-extra/clangd/unittests/ClangdTests.cpp @@ -273,12 +273,13 @@ TEST_F(ClangdVFSTest, PropagatesContexts) { static Key<int> Secret; struct ContextReadingFS : public ThreadsafeFS { - IntrusiveRefCntPtr<llvm::vfs::FileSystem> - view(llvm::NoneType) const override { + mutable int Got; + + private: + IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const override { Got = Context::current().getExisting(Secret); return buildTestFS({}); } - mutable int Got; } FS; struct Callbacks : public ClangdServer::Callbacks { void onDiagnosticsReady(PathRef File, llvm::StringRef Version, @@ -925,12 +926,17 @@ // preamble again. (They should be using the preamble's stat-cache) TEST(ClangdTests, PreambleVFSStatCache) { class StatRecordingFS : public ThreadsafeFS { + llvm::StringMap<unsigned> &CountStats; + public: + // If relative paths are used, they are resolved with testPath(). + llvm::StringMap<std::string> Files; + StatRecordingFS(llvm::StringMap<unsigned> &CountStats) : CountStats(CountStats) {} - IntrusiveRefCntPtr<llvm::vfs::FileSystem> - view(llvm::NoneType) const override { + private: + IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const override { class StatRecordingVFS : public llvm::vfs::ProxyFileSystem { public: StatRecordingVFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS, @@ -954,10 +960,6 @@ return IntrusiveRefCntPtr<StatRecordingVFS>( new StatRecordingVFS(buildTestFS(Files), CountStats)); } - - // If relative paths are used, they are resolved with testPath(). - llvm::StringMap<std::string> Files; - llvm::StringMap<unsigned> &CountStats; }; llvm::StringMap<unsigned> CountStats; Index: clang-tools-extra/clangd/support/ThreadsafeFS.h =================================================================== --- clang-tools-extra/clangd/support/ThreadsafeFS.h +++ clang-tools-extra/clangd/support/ThreadsafeFS.h @@ -30,20 +30,25 @@ virtual ~ThreadsafeFS() = default; /// Obtain a vfs::FileSystem with an arbitrary initial working directory. - virtual llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> - view(llvm::NoneType CWD) const = 0; + llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> + view(llvm::NoneType CWD) const { + return viewImpl(); + } /// 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::vfs::FileSystem> - view(PathRef CWD) const; + llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> view(PathRef CWD) const; + +private: + /// Overridden by implementations to provide a vfs::FileSystem. + /// This is distinct from view(NoneType) to avoid GCC's -Woverloaded-virtual. + virtual llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const = 0; }; class RealThreadsafeFS : public ThreadsafeFS { -public: - llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> - view(llvm::NoneType) const override; +private: + llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const override; }; } // namespace clangd Index: clang-tools-extra/clangd/support/ThreadsafeFS.cpp =================================================================== --- clang-tools-extra/clangd/support/ThreadsafeFS.cpp +++ clang-tools-extra/clangd/support/ThreadsafeFS.cpp @@ -83,7 +83,7 @@ } llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> -RealThreadsafeFS::view(llvm::NoneType) const { +RealThreadsafeFS::viewImpl() 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. Index: clang-tools-extra/clangd/Preamble.cpp =================================================================== --- clang-tools-extra/clangd/Preamble.cpp +++ clang-tools-extra/clangd/Preamble.cpp @@ -229,9 +229,8 @@ llvm::Expected<ScannedPreamble> scanPreamble(llvm::StringRef Contents, const tooling::CompileCommand &Cmd) { class EmptyFS : public ThreadsafeFS { - public: - llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> - view(llvm::NoneType) const override { + private: + llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const override { return new llvm::vfs::InMemoryFileSystem; } };
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits