summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility/DataBufferLLVM.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Utility/DataBufferLLVM.cpp')
-rw-r--r--lldb/source/Utility/DataBufferLLVM.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/lldb/source/Utility/DataBufferLLVM.cpp b/lldb/source/Utility/DataBufferLLVM.cpp
index bebcafbf915..713c3c2814e 100644
--- a/lldb/source/Utility/DataBufferLLVM.cpp
+++ b/lldb/source/Utility/DataBufferLLVM.cpp
@@ -18,7 +18,8 @@
using namespace lldb_private;
-DataBufferLLVM::DataBufferLLVM(std::unique_ptr<llvm::MemoryBuffer> MemBuffer)
+DataBufferLLVM::DataBufferLLVM(
+ std::unique_ptr<llvm::WritableMemoryBuffer> MemBuffer)
: Buffer(std::move(MemBuffer)) {
assert(Buffer != nullptr &&
"Cannot construct a DataBufferLLVM with a null buffer");
@@ -28,13 +29,13 @@ DataBufferLLVM::~DataBufferLLVM() {}
std::shared_ptr<DataBufferLLVM>
DataBufferLLVM::CreateSliceFromPath(const llvm::Twine &Path, uint64_t Size,
- uint64_t Offset, bool Private) {
+ uint64_t Offset) {
// If the file resides non-locally, pass the volatile flag so that we don't
// mmap it.
- if (!Private)
- Private = !llvm::sys::fs::is_local(Path);
+ bool IsVolatile = !llvm::sys::fs::is_local(Path);
- auto Buffer = llvm::MemoryBuffer::getFileSlice(Path, Size, Offset, Private);
+ auto Buffer =
+ llvm::WritableMemoryBuffer::getFileSlice(Path, Size, Offset, IsVolatile);
if (!Buffer)
return nullptr;
return std::shared_ptr<DataBufferLLVM>(
@@ -42,13 +43,12 @@ DataBufferLLVM::CreateSliceFromPath(const llvm::Twine &Path, uint64_t Size,
}
std::shared_ptr<DataBufferLLVM>
-DataBufferLLVM::CreateFromPath(const llvm::Twine &Path, bool NullTerminate, bool Private) {
+DataBufferLLVM::CreateFromPath(const llvm::Twine &Path) {
// If the file resides non-locally, pass the volatile flag so that we don't
// mmap it.
- if (!Private)
- Private = !llvm::sys::fs::is_local(Path);
+ bool IsVolatile = !llvm::sys::fs::is_local(Path);
- auto Buffer = llvm::MemoryBuffer::getFile(Path, -1, NullTerminate, Private);
+ auto Buffer = llvm::WritableMemoryBuffer::getFile(Path, -1, IsVolatile);
if (!Buffer)
return nullptr;
return std::shared_ptr<DataBufferLLVM>(
@@ -56,15 +56,13 @@ DataBufferLLVM::CreateFromPath(const llvm::Twine &Path, bool NullTerminate, bool
}
uint8_t *DataBufferLLVM::GetBytes() {
- return const_cast<uint8_t *>(GetBuffer());
+ return reinterpret_cast<uint8_t *>(Buffer->getBufferStart());
}
-const uint8_t *DataBufferLLVM::GetBytes() const { return GetBuffer(); }
+const uint8_t *DataBufferLLVM::GetBytes() const {
+ return reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
+}
lldb::offset_t DataBufferLLVM::GetByteSize() const {
return Buffer->getBufferSize();
}
-
-const uint8_t *DataBufferLLVM::GetBuffer() const {
- return reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
-}
OpenPOWER on IntegriCloud