1 //===--- DataBufferLLVM.cpp -------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "lldb/Utility/DataBufferLLVM.h"
11 
12 #include "llvm/ADT/Twine.h"
13 #include "llvm/Support/FileSystem.h"
14 #include "llvm/Support/MemoryBuffer.h"
15 
16 #include <assert.h>
17 #include <type_traits>
18 
19 using namespace lldb_private;
20 
DataBufferLLVM(std::unique_ptr<llvm::WritableMemoryBuffer> MemBuffer)21 DataBufferLLVM::DataBufferLLVM(
22     std::unique_ptr<llvm::WritableMemoryBuffer> MemBuffer)
23     : Buffer(std::move(MemBuffer)) {
24   assert(Buffer != nullptr &&
25          "Cannot construct a DataBufferLLVM with a null buffer");
26 }
27 
~DataBufferLLVM()28 DataBufferLLVM::~DataBufferLLVM() {}
29 
GetBytes()30 uint8_t *DataBufferLLVM::GetBytes() {
31   return reinterpret_cast<uint8_t *>(Buffer->getBufferStart());
32 }
33 
GetBytes() const34 const uint8_t *DataBufferLLVM::GetBytes() const {
35   return reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
36 }
37 
GetByteSize() const38 lldb::offset_t DataBufferLLVM::GetByteSize() const {
39   return Buffer->getBufferSize();
40 }
41