Index: include/clang/Basic/VirtualFileSystem.h =================================================================== --- include/clang/Basic/VirtualFileSystem.h +++ include/clang/Basic/VirtualFileSystem.h @@ -335,6 +335,41 @@ const_iterator overlays_end() const { return FSList.rend(); } }; +/// By default, this delegates all calls to the underlying file system. This +/// is useful when derived file systems want to override some calls and still +/// proxy other calls. +class ProxyFileSystem : public FileSystem { +public: + ProxyFileSystem(IntrusiveRefCntPtr FS) : FS(std::move(FS)) {} + + virtual llvm::ErrorOr status(const Twine &Path) override { + return FS->status(Path); + } + virtual llvm::ErrorOr> + openFileForRead(const Twine &Path) override { + return FS->openFileForRead(Path); + } + virtual directory_iterator dir_begin(const Twine &Dir, + std::error_code &EC) override { + return FS->dir_begin(Dir, EC); + } + virtual llvm::ErrorOr + getCurrentWorkingDirectory() const override { + return FS->getCurrentWorkingDirectory(); + } + virtual std::error_code + setCurrentWorkingDirectory(const Twine &Path) override { + return FS->setCurrentWorkingDirectory(Path); + } + virtual std::error_code getRealPath(const Twine &Path, + SmallVectorImpl &Output) const override { + return FS->getRealPath(Path, Output); + } + +private: + IntrusiveRefCntPtr FS; +}; + namespace detail { class InMemoryDirectory;