13 #ifndef LLVM_SUPPORT_MEMORYBUFFER_H 14 #define LLVM_SUPPORT_MEMORYBUFFER_H 29 class MemoryBufferRef;
42 const char *BufferStart;
43 const char *BufferEnd;
48 void init(
const char *BufStart,
const char *BufEnd,
49 bool RequiresNullTerminator);
81 bool RequiresNullTerminator =
true,
bool IsVolatile =
false);
104 bool RequiresNullTerminator =
true,
bool IsVolatile =
false);
108 static std::unique_ptr<MemoryBuffer>
110 bool RequiresNullTerminator =
true);
112 static std::unique_ptr<MemoryBuffer>
117 static std::unique_ptr<MemoryBuffer>
127 bool RequiresNullTerminator =
true);
191 static std::unique_ptr<WritableMemoryBuffer>
192 getNewUninitMemBuffer(
size_t Size,
const Twine &BufferName =
"");
197 static std::unique_ptr<WritableMemoryBuffer>
198 getNewMemBuffer(
size_t Size,
const Twine &BufferName =
"");
270 : Buffer(Buffer), Identifier(Identifier) {}
286 #endif // LLVM_SUPPORT_MEMORYBUFFER_H virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
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.
Represents either an error or a value T.
StringRef getBuffer() const
This class represents lattice values for constants.
const char * getBufferEnd() const
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
constexpr char IsVolatile[]
Key for Kernel::Arg::Metadata::mIsVolatile.
MemoryBuffer & operator=(const MemoryBuffer &)=delete
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
size_t getBufferSize() const
virtual BufferKind getBufferKind() const =0
Return information on the memory mechanism used to support the MemoryBuffer.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFileSlice(sys::fs::file_t FD, const Twine &Filename, uint64_t MapSize, int64_t Offset, bool IsVolatile=false)
Given an already-open file descriptor, map some slice of it into a MemoryBuffer.
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
StringRef getBuffer() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator=true, bool IsVolatile=false)
Given an already-open file descriptor, read the file and return a MemoryBuffer.
The access may reference the value stored in memory.
MemoryBufferRef(const MemoryBuffer &Buffer)
May access map via data and modify it. Written to path.
May only access map via const_data as read only.
MutableArrayRef< char > getBuffer()
LLVM_NODISCARD size_t size() const
size - Get the string size.
static constexpr sys::fs::mapped_file_region::mapmode Mapmode
static ErrorOr< std::unique_ptr< MemoryBuffer > > getSTDIN()
Read all of stdin into a file buffer, and return it.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
size_t getBufferSize() const
This class is an extension of MemoryBuffer, which allows write access to the underlying contents and ...
MemoryBufferRef getMemBufferRef() const
This interface provides simple read-only access to a block of memory, and provides simple methods for...
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it...
StringRef getBufferIdentifier() const
May modify via data, but changes are lost on destruction.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile=false)
Map a subrange of the specified file as a MemoryBuffer.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
const char * getBufferEnd() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileAsStream(const Twine &Filename)
Read all of the specified file into a MemoryBuffer as a stream (i.e.
This class is an extension of MemoryBuffer, which allows copy-on-write access to the underlying conte...
BufferKind
The kind of memory backing used to support the MemoryBuffer.
const char * getBufferStart() const
Provides ErrorOr<T> smart pointer.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
const char * getBufferStart() const
MemoryBufferRef(StringRef Buffer, StringRef Identifier)
StringRef - Represent a constant reference to a string, i.e.
MutableArrayRef< char > getBuffer()