]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Utility/DataBufferLLVM.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Utility / DataBufferLLVM.cpp
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
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
28 DataBufferLLVM::~DataBufferLLVM() {}
29
30 uint8_t *DataBufferLLVM::GetBytes() {
31   return reinterpret_cast<uint8_t *>(Buffer->getBufferStart());
32 }
33
34 const uint8_t *DataBufferLLVM::GetBytes() const {
35   return reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
36 }
37
38 lldb::offset_t DataBufferLLVM::GetByteSize() const {
39   return Buffer->getBufferSize();
40 }