13#ifndef LLVM_SUPPORT_MEMORYBUFFER_H
14#define LLVM_SUPPORT_MEMORYBUFFER_H
52 const char *BufferStart;
53 const char *BufferEnd;
58 void init(
const char *BufStart,
const char *BufEnd,
59 bool RequiresNullTerminator);
99 bool RequiresNullTerminator =
true,
bool IsVolatile =
false,
100 std::optional<Align> Alignment = std::nullopt);
113 int64_t
Offset,
bool IsVolatile =
false,
114 std::optional<Align> Alignment = std::nullopt);
127 bool RequiresNullTerminator =
true,
bool IsVolatile =
false,
128 std::optional<Align> Alignment = std::nullopt);
132 static std::unique_ptr<MemoryBuffer>
134 bool RequiresNullTerminator =
true);
136 static std::unique_ptr<MemoryBuffer>
141 static std::unique_ptr<MemoryBuffer>
151 bool RequiresNullTerminator =
true,
152 std::optional<Align> Alignment = std::nullopt);
157 bool IsVolatile =
false,
158 std::optional<Align> Alignment = std::nullopt);
204 std::optional<Align> Alignment = std::nullopt);
209 bool IsVolatile =
false,
210 std::optional<Align> Alignment = std::nullopt);
218 static std::unique_ptr<WritableMemoryBuffer>
220 std::optional<Align> Alignment = std::nullopt);
225 static std::unique_ptr<WritableMemoryBuffer>
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Provides ErrorOr<T> smart pointer.
Represents either an error or a value T.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Given an already-open file descriptor, read the file and return a MemoryBuffer.
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
BufferKind
The kind of memory backing used to support the MemoryBuffer.
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
size_t getBufferSize() const
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.
MemoryBuffer(const MemoryBuffer &)=delete
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFileSlice(sys::fs::file_t FD, const Twine &Filename, uint64_t MapSize, int64_t Offset, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Given an already-open file descriptor, map some slice of it into a MemoryBuffer.
virtual BufferKind getBufferKind() const =0
Return information on the memory mechanism used to support the MemoryBuffer.
void init(const char *BufStart, const char *BufEnd, bool RequiresNullTerminator)
init - Initialize this MemoryBuffer as a reference to externally allocated memory,...
StringRef getBuffer() 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.
virtual void dontNeedIfMmap()
For read-only MemoryBuffer_MMap, mark the buffer as unused in the near future and the kernel can free...
MemoryBufferRef getMemBufferRef() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
MemoryBuffer & operator=(const MemoryBuffer &)=delete
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Map a subrange of the specified file as a MemoryBuffer.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
const char * getBufferEnd() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getSTDIN()
Read all of stdin into a file buffer, and return it.
const char * getBufferStart() const
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class is an extension of MemoryBuffer, which allows copy-on-write access to the underlying conte...
MutableArrayRef< char > getBuffer()
static std::unique_ptr< WritableMemoryBuffer > getNewMemBuffer(size_t Size, const Twine &BufferName="")
Allocate a new zero-initialized MemoryBuffer of the specified size.
static ErrorOr< std::unique_ptr< WritableMemoryBuffer > > getFile(const Twine &Filename, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
WritableMemoryBuffer()=default
static std::unique_ptr< WritableMemoryBuffer > getNewUninitMemBuffer(size_t Size, const Twine &BufferName="", std::optional< Align > Alignment=std::nullopt)
Allocate a new MemoryBuffer of the specified size that is not initialized.
static ErrorOr< std::unique_ptr< WritableMemoryBuffer > > getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Map a subrange of the specified file as a WritableMemoryBuffer.
This class is an extension of MemoryBuffer, which allows write access to the underlying contents and ...
WriteThroughMemoryBuffer()=default
MutableArrayRef< char > getBuffer()
static ErrorOr< std::unique_ptr< WriteThroughMemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1)
static ErrorOr< std::unique_ptr< WriteThroughMemoryBuffer > > getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset)
Map a subrange of the specified file as a ReadWriteMemoryBuffer.
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
This is an optimization pass for GlobalISel generic memory operations.
@ Ref
The access may reference the value stored in memory.