forked from OSchip/llvm-project
[lldb] Return a DataBuffer from FileSystem::CreateDataBuffer (NFC)
The concrete class (DataBufferLLVM) is an implementation detail.
This commit is contained in:
parent
492cb7bf91
commit
2165c36be4
|
@ -10,7 +10,7 @@
|
|||
#define LLDB_HOST_FILESYSTEM_H
|
||||
|
||||
#include "lldb/Host/File.h"
|
||||
#include "lldb/Utility/DataBufferLLVM.h"
|
||||
#include "lldb/Utility/DataBuffer.h"
|
||||
#include "lldb/Utility/FileSpec.h"
|
||||
#include "lldb/Utility/Status.h"
|
||||
|
||||
|
@ -142,12 +142,12 @@ public:
|
|||
|
||||
//// Create memory buffer from path.
|
||||
/// \{
|
||||
std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const llvm::Twine &path,
|
||||
uint64_t size = 0,
|
||||
uint64_t offset = 0);
|
||||
std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const FileSpec &file_spec,
|
||||
uint64_t size = 0,
|
||||
uint64_t offset = 0);
|
||||
std::shared_ptr<DataBuffer> CreateDataBuffer(const llvm::Twine &path,
|
||||
uint64_t size = 0,
|
||||
uint64_t offset = 0);
|
||||
std::shared_ptr<DataBuffer> CreateDataBuffer(const FileSpec &file_spec,
|
||||
uint64_t size = 0,
|
||||
uint64_t offset = 0);
|
||||
/// \}
|
||||
|
||||
/// Call into the Host to see if it can help find the file.
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
namespace llvm {
|
||||
class WritableMemoryBuffer;
|
||||
class Twine;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace lldb_private {
|
||||
|
||||
|
@ -31,8 +31,6 @@ public:
|
|||
const uint8_t *GetBytes() const override;
|
||||
lldb::offset_t GetByteSize() const override;
|
||||
|
||||
char *GetChars() { return reinterpret_cast<char *>(GetBytes()); }
|
||||
|
||||
private:
|
||||
friend FileSystem;
|
||||
/// Construct a DataBufferLLVM from \p Buffer. \p Buffer must be a valid
|
||||
|
@ -41,6 +39,6 @@ private:
|
|||
|
||||
std::unique_ptr<llvm::WritableMemoryBuffer> Buffer;
|
||||
};
|
||||
}
|
||||
} // namespace lldb_private
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "lldb/Target/Thread.h"
|
||||
#include "lldb/Utility/Args.h"
|
||||
#include "lldb/Utility/DataBufferHeap.h"
|
||||
#include "lldb/Utility/DataBufferLLVM.h"
|
||||
#include "lldb/Utility/StreamString.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include <cinttypes>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "lldb/Utility/AnsiTerminal.h"
|
||||
#include "lldb/Utility/ConstString.h"
|
||||
#include "lldb/Utility/DataBuffer.h"
|
||||
#include "lldb/Utility/DataBufferLLVM.h"
|
||||
#include "lldb/Utility/RegularExpression.h"
|
||||
#include "lldb/Utility/Stream.h"
|
||||
#include "lldb/lldb-enumerations.h"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "lldb/Host/FileSystem.h"
|
||||
|
||||
#include "lldb/Utility/DataBufferLLVM.h"
|
||||
#include "lldb/Utility/LLDBAssert.h"
|
||||
#include "lldb/Utility/TildeExpressionResolver.h"
|
||||
|
||||
|
@ -272,7 +273,7 @@ void FileSystem::Resolve(FileSpec &file_spec) {
|
|||
file_spec.SetIsResolved(true);
|
||||
}
|
||||
|
||||
std::shared_ptr<DataBufferLLVM>
|
||||
std::shared_ptr<DataBuffer>
|
||||
FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
|
||||
uint64_t offset) {
|
||||
const bool is_volatile = !IsLocal(path);
|
||||
|
@ -293,7 +294,7 @@ FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
|
|||
return std::shared_ptr<DataBufferLLVM>(new DataBufferLLVM(std::move(buffer)));
|
||||
}
|
||||
|
||||
std::shared_ptr<DataBufferLLVM>
|
||||
std::shared_ptr<DataBuffer>
|
||||
FileSystem::CreateDataBuffer(const FileSpec &file_spec, uint64_t size,
|
||||
uint64_t offset) {
|
||||
return CreateDataBuffer(file_spec.GetPath(), size, offset);
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
#include "lldb/Host/ProcessLauncher.h"
|
||||
#include "lldb/Host/ThreadLauncher.h"
|
||||
#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
|
||||
#include "lldb/Utility/DataBufferLLVM.h"
|
||||
#include "lldb/Utility/FileSpec.h"
|
||||
#include "lldb/Utility/LLDBLog.h"
|
||||
#include "lldb/Utility/Log.h"
|
||||
|
@ -528,8 +527,9 @@ Status Host::RunShellCommand(llvm::StringRef shell_path, const Args &args,
|
|||
auto Buffer =
|
||||
FileSystem::Instance().CreateDataBuffer(output_file_spec);
|
||||
if (error.Success())
|
||||
command_output_ptr->assign(Buffer->GetChars(),
|
||||
Buffer->GetByteSize());
|
||||
command_output_ptr->assign(
|
||||
reinterpret_cast<char *>(Buffer->GetBytes()),
|
||||
Buffer->GetByteSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue