15ffd83dbSDimitry Andric //===-- DataBufferLLVM.cpp ------------------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #include "lldb/Utility/DataBufferLLVM.h"
100b57cec5SDimitry Andric 
110b57cec5SDimitry Andric #include "llvm/Support/MemoryBuffer.h"
120b57cec5SDimitry Andric 
13*5f7ddb14SDimitry Andric #include <cassert>
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric using namespace lldb_private;
160b57cec5SDimitry Andric 
DataBufferLLVM(std::unique_ptr<llvm::WritableMemoryBuffer> MemBuffer)170b57cec5SDimitry Andric DataBufferLLVM::DataBufferLLVM(
180b57cec5SDimitry Andric     std::unique_ptr<llvm::WritableMemoryBuffer> MemBuffer)
190b57cec5SDimitry Andric     : Buffer(std::move(MemBuffer)) {
200b57cec5SDimitry Andric   assert(Buffer != nullptr &&
210b57cec5SDimitry Andric          "Cannot construct a DataBufferLLVM with a null buffer");
220b57cec5SDimitry Andric }
230b57cec5SDimitry Andric 
24*5f7ddb14SDimitry Andric DataBufferLLVM::~DataBufferLLVM() = default;
250b57cec5SDimitry Andric 
GetBytes()260b57cec5SDimitry Andric uint8_t *DataBufferLLVM::GetBytes() {
270b57cec5SDimitry Andric   return reinterpret_cast<uint8_t *>(Buffer->getBufferStart());
280b57cec5SDimitry Andric }
290b57cec5SDimitry Andric 
GetBytes() const300b57cec5SDimitry Andric const uint8_t *DataBufferLLVM::GetBytes() const {
310b57cec5SDimitry Andric   return reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
320b57cec5SDimitry Andric }
330b57cec5SDimitry Andric 
GetByteSize() const340b57cec5SDimitry Andric lldb::offset_t DataBufferLLVM::GetByteSize() const {
350b57cec5SDimitry Andric   return Buffer->getBufferSize();
360b57cec5SDimitry Andric }
37