1 //===--- DataBufferLLVM.cpp -------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Utility/DataBufferLLVM.h"
10 
11 #include "llvm/ADT/Twine.h"
12 #include "llvm/Support/FileSystem.h"
13 #include "llvm/Support/MemoryBuffer.h"
14 
15 #include <assert.h>
16 #include <type_traits>
17 
18 using namespace lldb_private;
19 
20 DataBufferLLVM::DataBufferLLVM(
21     std::unique_ptr<llvm::WritableMemoryBuffer> MemBuffer)
22     : Buffer(std::move(MemBuffer)) {
23   assert(Buffer != nullptr &&
24          "Cannot construct a DataBufferLLVM with a null buffer");
25 }
26 
27 DataBufferLLVM::~DataBufferLLVM() {}
28 
29 uint8_t *DataBufferLLVM::GetBytes() {
30   return reinterpret_cast<uint8_t *>(Buffer->getBufferStart());
31 }
32 
33 const uint8_t *DataBufferLLVM::GetBytes() const {
34   return reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
35 }
36 
37 lldb::offset_t DataBufferLLVM::GetByteSize() const {
38   return Buffer->getBufferSize();
39 }
40