diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-24 01:01:00 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-24 01:01:00 +0000 |
commit | 23629167fefb8117a4d2cc9213c8a29d5b4a1197 (patch) | |
tree | c410512ef1b5e0f0e81b7f333cafabc3ad716f5d /source/Utility/DataBufferLLVM.cpp | |
parent | ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (diff) | |
download | src-test2-23629167fefb8117a4d2cc9213c8a29d5b4a1197.tar.gz src-test2-23629167fefb8117a4d2cc9213c8a29d5b4a1197.zip |
Notes
Diffstat (limited to 'source/Utility/DataBufferLLVM.cpp')
-rw-r--r-- | source/Utility/DataBufferLLVM.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/source/Utility/DataBufferLLVM.cpp b/source/Utility/DataBufferLLVM.cpp index bebcafbf9150..713c3c2814ea 100644 --- a/source/Utility/DataBufferLLVM.cpp +++ b/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()); -} |