LLVM  4.0.0
ObjectBuffer.h
Go to the documentation of this file.
1 //===--- ObjectBuffer.h - Utility class to wrap object memory ---*- 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 // This file declares a wrapper class to hold the memory into which an
11 // object will be generated.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_EXECUTIONENGINE_OBJECTBUFFER_H
16 #define LLVM_EXECUTIONENGINE_OBJECTBUFFER_H
17 
18 #include "llvm/ADT/SmallVector.h"
21 
22 namespace llvm {
23 
24 class ObjectMemoryBuffer : public MemoryBuffer {
25 public:
26  template <unsigned N>
28  : SV(SV), BufferName("<in-memory object>") {
29  init(this->SV.begin(), this->SV.end(), false);
30  }
31 
32  template <unsigned N>
34  : SV(SV), BufferName(Name) {
35  init(this->SV.begin(), this->SV.end(), false);
36  }
37  const char* getBufferIdentifier() const override { return BufferName.c_str(); }
38 
39  BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; }
40 
41 private:
43  std::string BufferName;
44 };
45 
46 } // namespace llvm
47 
48 #endif
void init(const char *BufStart, const char *BufEnd, bool RequiresNullTerminator)
init - Initialize this MemoryBuffer as a reference to externally allocated memory, memory that we know is already null terminated.
const char * getBufferIdentifier() const override
Return an identifier for this buffer, typically the filename it was read from.
Definition: ObjectBuffer.h:37
ObjectMemoryBuffer(SmallVector< char, N > SV, StringRef Name)
Definition: ObjectBuffer.h:33
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
Definition: SmallVector.h:115
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:843
ObjectMemoryBuffer(SmallVector< char, N > SV)
Definition: ObjectBuffer.h:27
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
Definition: SmallVector.h:119
BufferKind
The kind of memory backing used to support the MemoryBuffer.
Definition: MemoryBuffer.h:146
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
BufferKind getBufferKind() const override
Return information on the memory mechanism used to support the MemoryBuffer.
Definition: ObjectBuffer.h:39