summaryrefslogtreecommitdiff
path: root/lldb/source/Host/common/FileSystem.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
commit344a3780b2e33f6ca763666c380202b18aab72a3 (patch)
treef0b203ee6eb71d7fdd792373e3c81eb18d6934dd /lldb/source/Host/common/FileSystem.cpp
parentb60736ec1405bb0a8dd40989f67ef4c93da068ab (diff)
Diffstat (limited to 'lldb/source/Host/common/FileSystem.cpp')
-rw-r--r--lldb/source/Host/common/FileSystem.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp
index 9fa8854d950e..a2c3b3556a6c 100644
--- a/lldb/source/Host/common/FileSystem.cpp
+++ b/lldb/source/Host/common/FileSystem.cpp
@@ -19,11 +19,11 @@
#include "llvm/Support/Program.h"
#include "llvm/Support/Threading.h"
-#include <errno.h>
+#include <cerrno>
+#include <climits>
+#include <cstdarg>
+#include <cstdio>
#include <fcntl.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <stdio.h>
#ifdef _WIN32
#include "lldb/Host/windows/windows.h"
@@ -307,7 +307,7 @@ FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
std::unique_ptr<llvm::WritableMemoryBuffer> buffer;
if (size == 0) {
auto buffer_or_error =
- llvm::WritableMemoryBuffer::getFile(*external_path, -1, is_volatile);
+ llvm::WritableMemoryBuffer::getFile(*external_path, is_volatile);
if (!buffer_or_error)
return nullptr;
buffer = std::move(*buffer_or_error);
@@ -478,20 +478,18 @@ ErrorOr<std::string> FileSystem::GetExternalPath(const llvm::Twine &path) {
return path.str();
// If VFS mapped we know the underlying FS is a RedirectingFileSystem.
- ErrorOr<vfs::RedirectingFileSystem::Entry *> E =
+ ErrorOr<vfs::RedirectingFileSystem::LookupResult> Result =
static_cast<vfs::RedirectingFileSystem &>(*m_fs).lookupPath(path.str());
- if (!E) {
- if (E.getError() == llvm::errc::no_such_file_or_directory) {
+ if (!Result) {
+ if (Result.getError() == llvm::errc::no_such_file_or_directory) {
return path.str();
}
- return E.getError();
+ return Result.getError();
}
- auto *F = dyn_cast<vfs::RedirectingFileSystem::RedirectingFileEntry>(*E);
- if (!F)
- return make_error_code(llvm::errc::not_supported);
-
- return F->getExternalContentsPath().str();
+ 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) {