LLVM 20.0.0git
|
This class is an extension of MemoryBuffer, which allows write access to the underlying contents and committing those changes to the original source. More...
#include "llvm/Support/MemoryBuffer.h"
Public Member Functions | |
char * | getBufferStart () |
char * | getBufferEnd () |
MutableArrayRef< char > | getBuffer () |
StringRef | getBuffer () const |
const char * | getBufferEnd () const |
const char * | getBufferStart () const |
Public Member Functions inherited from llvm::MemoryBuffer | |
MemoryBuffer (const MemoryBuffer &)=delete | |
MemoryBuffer & | operator= (const MemoryBuffer &)=delete |
virtual | ~MemoryBuffer () |
const char * | getBufferStart () const |
const char * | getBufferEnd () const |
size_t | getBufferSize () const |
StringRef | getBuffer () const |
virtual StringRef | getBufferIdentifier () const |
Return an identifier for this buffer, typically the filename it was read from. | |
virtual void | dontNeedIfMmap () |
For read-only MemoryBuffer_MMap, mark the buffer as unused in the near future and the kernel can free resources associated with it. | |
virtual BufferKind | getBufferKind () const =0 |
Return information on the memory mechanism used to support the MemoryBuffer. | |
MemoryBufferRef | getMemBufferRef () const |
Static Public Member Functions | |
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. | |
Static Public Member Functions inherited from llvm::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, otherwise returning null. | |
static ErrorOr< std::unique_ptr< MemoryBuffer > > | getFileAsStream (const Twine &Filename) |
Read all of the specified file into a MemoryBuffer as a stream (i.e. | |
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. | |
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. | |
static std::unique_ptr< MemoryBuffer > | getMemBuffer (MemoryBufferRef Ref, bool RequiresNullTerminator=true) |
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. | |
static ErrorOr< std::unique_ptr< MemoryBuffer > > | getSTDIN () |
Read all of stdin into a file buffer, and return it. | |
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 "-". | |
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. | |
Protected Member Functions | |
WriteThroughMemoryBuffer ()=default | |
Protected Member Functions inherited from llvm::MemoryBuffer | |
MemoryBuffer ()=default | |
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. | |
Additional Inherited Members | |
Public Types inherited from llvm::MemoryBuffer | |
enum | BufferKind { MemoryBuffer_Malloc , MemoryBuffer_MMap } |
The kind of memory backing used to support the MemoryBuffer. More... | |
This class is an extension of MemoryBuffer, which allows write access to the underlying contents and committing those changes to the original source.
It only supports creation methods that are guaranteed to produce a writable buffer. For example, mapping a file read-only is not supported.
Definition at line 245 of file MemoryBuffer.h.
|
protecteddefault |
|
inline |
Definition at line 262 of file MemoryBuffer.h.
References getBufferEnd(), and getBufferStart().
|
inline |
Definition at line 70 of file MemoryBuffer.h.
|
inline |
Definition at line 259 of file MemoryBuffer.h.
References llvm::MemoryBuffer::getBufferEnd().
Referenced by getBuffer().
Definition at line 67 of file MemoryBuffer.h.
|
inline |
Definition at line 256 of file MemoryBuffer.h.
References llvm::MemoryBuffer::getBufferStart().
Referenced by getBuffer().
Definition at line 66 of file MemoryBuffer.h.
|
static |
Definition at line 459 of file MemoryBuffer.cpp.
References getReadWriteFile().
|
static |
Map a subrange of the specified file as a ReadWriteMemoryBuffer.
Map a subrange of the specified file as a WritableMemoryBuffer.
Definition at line 465 of file MemoryBuffer.cpp.
References getReadWriteFile(), and llvm::Offset.