]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Utility/DataBufferLLVM.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Utility / DataBufferLLVM.h
1 //===--- DataBufferLLVM.h ---------------------------------------*- 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 #ifndef LLDB_CORE_DATABUFFERLLVM_H
11 #define LLDB_CORE_DATABUFFERLLVM_H
12
13 #include "lldb/Utility/DataBuffer.h"
14 #include "lldb/lldb-types.h" // for offset_t
15
16 #include <memory>
17 #include <stdint.h> // for uint8_t, uint64_t
18
19 namespace llvm {
20 class WritableMemoryBuffer;
21 class Twine;
22 }
23
24 namespace lldb_private {
25
26 class DataBufferLLVM : public DataBuffer {
27 public:
28   ~DataBufferLLVM();
29
30   static std::shared_ptr<DataBufferLLVM>
31   CreateSliceFromPath(const llvm::Twine &Path, uint64_t Size, uint64_t Offset);
32
33   static std::shared_ptr<DataBufferLLVM>
34   CreateFromPath(const llvm::Twine &Path);
35
36   uint8_t *GetBytes() override;
37   const uint8_t *GetBytes() const override;
38   lldb::offset_t GetByteSize() const override;
39
40   char *GetChars() { return reinterpret_cast<char *>(GetBytes()); }
41
42 private:
43   /// Construct a DataBufferLLVM from \p Buffer.  \p Buffer must be a valid
44   /// pointer.
45   explicit DataBufferLLVM(std::unique_ptr<llvm::WritableMemoryBuffer> Buffer);
46
47   std::unique_ptr<llvm::WritableMemoryBuffer> Buffer;
48 };
49 }
50
51 #endif