diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2022-03-03 10:30:43 -0800 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2022-03-03 11:02:11 -0800 |
commit | 59eb70527741594fe3c92d0a1b6704ed45111437 (patch) | |
tree | aff6c02296f2a2a0f7543a0a4d26a6dd1ef334f5 /lldb/source/Host/common/FileSystem.cpp | |
parent | f7698991157e23d619c22be5dd2b9230f94717b3 (diff) | |
download | llvm-59eb70527741594fe3c92d0a1b6704ed45111437.zip llvm-59eb70527741594fe3c92d0a1b6704ed45111437.tar.gz llvm-59eb70527741594fe3c92d0a1b6704ed45111437.tar.bz2 |
[lldb] Remove FileSystem::Initialize from VFS mapping
This patch removes the ability to instantiate the LLDB FileSystem class
based on a VFS overlay. This also removes the "hack" where we cast the
VFS to a RedirectingFileSystem to obtain the external path. You can
still instantiate a FileSystem with a VFS, but with the caveat that
operations that rely on the external path won't work.
Differential revision: https://reviews.llvm.org/D120923
Diffstat (limited to 'lldb/source/Host/common/FileSystem.cpp')
-rw-r--r-- | lldb/source/Host/common/FileSystem.cpp | 54 |
1 files changed, 4 insertions, 50 deletions
diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp index 26a98fa..4a8cc3a 100644 --- a/lldb/source/Host/common/FileSystem.cpp +++ b/lldb/source/Host/common/FileSystem.cpp @@ -54,22 +54,6 @@ void FileSystem::Initialize(std::shared_ptr<FileCollectorBase> collector) { InstanceImpl().emplace(collector); } -llvm::Error FileSystem::Initialize(const FileSpec &mapping) { - lldbassert(!InstanceImpl() && "Already initialized."); - - llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> buffer = - llvm::vfs::getRealFileSystem()->getBufferForFile(mapping.GetPath()); - - if (!buffer) - return llvm::errorCodeToError(buffer.getError()); - - InstanceImpl().emplace(llvm::vfs::getVFSFromYAML(std::move(buffer.get()), - nullptr, mapping.GetPath()), - true); - - return llvm::Error::success(); -} - void FileSystem::Initialize(IntrusiveRefCntPtr<vfs::FileSystem> fs) { lldbassert(!InstanceImpl() && "Already initialized."); InstanceImpl().emplace(fs); @@ -300,21 +284,16 @@ FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size, Collect(path); const bool is_volatile = !IsLocal(path); - const ErrorOr<std::string> external_path = GetExternalPath(path); - - if (!external_path) - return nullptr; - std::unique_ptr<llvm::WritableMemoryBuffer> buffer; if (size == 0) { auto buffer_or_error = - llvm::WritableMemoryBuffer::getFile(*external_path, is_volatile); + llvm::WritableMemoryBuffer::getFile(path, is_volatile); if (!buffer_or_error) return nullptr; buffer = std::move(*buffer_or_error); } else { auto buffer_or_error = llvm::WritableMemoryBuffer::getFileSlice( - *external_path, size, offset, is_volatile); + path, size, offset, is_volatile); if (!buffer_or_error) return nullptr; buffer = std::move(*buffer_or_error); @@ -457,12 +436,10 @@ Expected<FileUP> FileSystem::Open(const FileSpec &file_spec, const mode_t open_mode = (open_flags & O_CREAT) ? GetOpenMode(permissions) : 0; - auto path = GetExternalPath(file_spec); - if (!path) - return errorCodeToError(path.getError()); + auto path = file_spec.GetPath(); int descriptor = llvm::sys::RetryAfterSignal( - -1, OpenWithFS, *this, path->c_str(), open_flags, open_mode); + -1, OpenWithFS, *this, path.c_str(), open_flags, open_mode); if (!File::DescriptorIsValid(descriptor)) return llvm::errorCodeToError( @@ -474,29 +451,6 @@ Expected<FileUP> FileSystem::Open(const FileSpec &file_spec, return std::move(file); } -ErrorOr<std::string> FileSystem::GetExternalPath(const llvm::Twine &path) { - if (!m_mapped) - return path.str(); - - // If VFS mapped we know the underlying FS is a RedirectingFileSystem. - ErrorOr<vfs::RedirectingFileSystem::LookupResult> Result = - static_cast<vfs::RedirectingFileSystem &>(*m_fs).lookupPath(path.str()); - if (!Result) { - if (Result.getError() == llvm::errc::no_such_file_or_directory) { - return path.str(); - } - return Result.getError(); - } - - if (Optional<StringRef> ExtRedirect = Result->getExternalRedirect()) - return std::string(*ExtRedirect); - return make_error_code(llvm::errc::not_supported); -} - -ErrorOr<std::string> FileSystem::GetExternalPath(const FileSpec &file_spec) { - return GetExternalPath(file_spec.GetPath()); -} - void FileSystem::Collect(const FileSpec &file_spec) { Collect(file_spec.GetPath()); } |