class WritableMemoryBuffer

Declaration

class WritableMemoryBuffer : public MemoryBuffer { /* full declaration omitted */ };

Description

This class is an extension of MemoryBuffer, which allows copy-on-write access to the underlying contents. It only supports creation methods that are guaranteed to produce a writable buffer. For example, mapping a file read-only is not supported.

Declared at: llvm/include/llvm/Support/MemoryBuffer.h:155

Inherits from: MemoryBuffer

Member Variables

protected static const sys::fs::mapped_file_region::mapmode Mapmode = sys::fs::mapped_file_region::priv

Inherited from MemoryBuffer:

protected static Mapmode = sys::fs::mapped_file_region::readonly

Method Overview

  • protected WritableMemoryBuffer()
  • public MutableArrayRef<char> getBuffer()
  • public char * getBufferEnd()
  • public char * getBufferStart()
  • public static ErrorOr<std::unique_ptr<WritableMemoryBuffer>> getFile(const llvm::Twine & Filename, int64_t FileSize = -1, bool IsVolatile = false)
  • public static ErrorOr<std::unique_ptr<WritableMemoryBuffer>> getFileSlice(const llvm::Twine & Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile = false)
  • public static std::unique_ptr<WritableMemoryBuffer> getNewMemBuffer(size_t Size, const llvm::Twine & BufferName = "")
  • public static std::unique_ptr<WritableMemoryBuffer> getNewUninitMemBuffer(size_t Size, const llvm::Twine & BufferName = "")

Inherited from MemoryBuffer:

Methods

WritableMemoryBuffer()

Declared at: llvm/include/llvm/Support/MemoryBuffer.h:157

MutableArrayRef<char> getBuffer()

Declared at: llvm/include/llvm/Support/MemoryBuffer.h:175

char* getBufferEnd()

Declared at: llvm/include/llvm/Support/MemoryBuffer.h:172

char* getBufferStart()

Declared at: llvm/include/llvm/Support/MemoryBuffer.h:169

static ErrorOr<
    std::unique_ptr<WritableMemoryBuffer>>
getFile(const llvm::Twine& Filename,
        int64_t FileSize = -1,
        bool IsVolatile = false)

Declared at: llvm/include/llvm/Support/MemoryBuffer.h:180

Parameters

const llvm::Twine& Filename
int64_t FileSize = -1
bool IsVolatile = false

static ErrorOr<
    std::unique_ptr<WritableMemoryBuffer>>
getFileSlice(const llvm::Twine& Filename,
             uint64_t MapSize,
             uint64_t Offset,
             bool IsVolatile = false)

Description

Map a subrange of the specified file as a WritableMemoryBuffer.

Declared at: llvm/include/llvm/Support/MemoryBuffer.h:185

Parameters

const llvm::Twine& Filename
uint64_t MapSize
uint64_t Offset
bool IsVolatile = false

static std::unique_ptr<WritableMemoryBuffer>
getNewMemBuffer(
    size_t Size,
    const llvm::Twine& BufferName = "")

Description

Allocate a new zero-initialized MemoryBuffer of the specified size. Note that the caller need not initialize the memory allocated by this method. The memory is owned by the MemoryBuffer object.

Declared at: llvm/include/llvm/Support/MemoryBuffer.h:198

Parameters

size_t Size
const llvm::Twine& BufferName = ""

static std::unique_ptr<WritableMemoryBuffer>
getNewUninitMemBuffer(
    size_t Size,
    const llvm::Twine& BufferName = "")

Description

Allocate a new MemoryBuffer of the specified size that is not initialized. Note that the caller should initialize the memory allocated by this method. The memory is owned by the MemoryBuffer object.

Declared at: llvm/include/llvm/Support/MemoryBuffer.h:192

Parameters

size_t Size
const llvm::Twine& BufferName = ""