13#ifndef LLVM_SUPPORT_MEMORYBUFFER_H 
   14#define LLVM_SUPPORT_MEMORYBUFFER_H 
   53  const char *BufferStart; 
 
   54  const char *BufferEnd;   
 
   59  void init(
const char *BufStart, 
const char *BufEnd,
 
   60            bool RequiresNullTerminator);
 
   99  getFile(
const Twine &Filename, 
bool IsText = 
false,
 
  100          bool RequiresNullTerminator = 
true, 
bool IsVolatile = 
false,
 
  101          std::optional<Align> Alignment = std::nullopt);
 
  107  getFileAsStream(
const Twine &Filename);
 
  114                   int64_t 
Offset, 
bool IsVolatile = 
false,
 
  115                   std::optional<Align> Alignment = std::nullopt);
 
  128              bool RequiresNullTerminator = 
true, 
bool IsVolatile = 
false,
 
  129              std::optional<Align> Alignment = std::nullopt);
 
  133  static std::unique_ptr<MemoryBuffer>
 
  135               bool RequiresNullTerminator = 
true);
 
  137  static std::unique_ptr<MemoryBuffer>
 
  142  static std::unique_ptr<MemoryBuffer>
 
  143  getMemBufferCopy(
StringRef InputData, 
const Twine &BufferName = 
"");
 
  151  getFileOrSTDIN(
const Twine &Filename, 
bool IsText = 
false,
 
  152                 bool RequiresNullTerminator = 
true,
 
  153                 std::optional<Align> Alignment = std::nullopt);
 
  158               bool IsVolatile = 
false,
 
  159               std::optional<Align> Alignment = std::nullopt);
 
 
  205          std::optional<Align> Alignment = std::nullopt);
 
  210               bool IsVolatile = 
false,
 
  211               std::optional<Align> Alignment = std::nullopt);
 
  219  LLVM_ABI static std::unique_ptr<WritableMemoryBuffer>
 
  221                        std::optional<Align> Alignment = std::nullopt);
 
  226  LLVM_ABI 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.
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
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...
MutableArrayRef< char > getBuffer()
static LLVM_ABI std::unique_ptr< WritableMemoryBuffer > getNewMemBuffer(size_t Size, const Twine &BufferName="")
Allocate a new zero-initialized MemoryBuffer of the specified size.
static LLVM_ABI ErrorOr< std::unique_ptr< WritableMemoryBuffer > > getFile(const Twine &Filename, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
WritableMemoryBuffer()=default
static LLVM_ABI 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 LLVM_ABI 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.
WriteThroughMemoryBuffer()=default
MutableArrayRef< char > getBuffer()
static LLVM_ABI ErrorOr< std::unique_ptr< WriteThroughMemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1)
static LLVM_ABI 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.