14 #ifndef LLVM_SUPPORT_MEMORYBUFFER_H 15 #define LLVM_SUPPORT_MEMORYBUFFER_H 30 class MemoryBufferRef;
43 const char *BufferStart;
44 const char *BufferEnd;
49 void init(
const char *BufStart,
const char *BufEnd,
50 bool RequiresNullTerminator);
82 bool RequiresNullTerminator =
true,
bool IsVolatile =
false);
105 bool RequiresNullTerminator =
true,
bool IsVolatile =
false);
109 static std::unique_ptr<MemoryBuffer>
111 bool RequiresNullTerminator =
true);
113 static std::unique_ptr<MemoryBuffer>
118 static std::unique_ptr<MemoryBuffer>
128 bool RequiresNullTerminator =
true);
192 static std::unique_ptr<WritableMemoryBuffer>
193 getNewUninitMemBuffer(
size_t Size,
const Twine &BufferName =
"");
198 static std::unique_ptr<WritableMemoryBuffer>
199 getNewMemBuffer(
size_t Size,
const Twine &BufferName =
"");
271 : Buffer(Buffer), Identifier(Identifier) {}
287 #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.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFileSlice(int 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.
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
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
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.
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
StringRef getBuffer() const
The access may reference the value stored in memory.
May access map via data and modify it. Written to path.
May only access map via const_data as read only.
MutableArrayRef< char > getBuffer()
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
MemoryBufferRef(MemoryBuffer &Buffer)
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.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFile(int 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.
MutableArrayRef< char > getBuffer()