llvm::WriteThroughMemoryBuffer::getFile

getFile overloads

Synopses

Declared in <llvm/Support/MemoryBuffer.h>

Map the specified file as a write-through memory buffer.

static
ErrorOr<std::unique_ptr<WriteThroughMemoryBuffer>>
getFile(
    Twine const& Filename,
    int64_t FileSize = -1);
» more...

Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.

static
ErrorOr<std::unique_ptr<MemoryBuffer>>
getFile(
    Twine const& Filename,
    bool IsText = false,
    bool RequiresNullTerminator = true,
    bool IsVolatile = false,
    std::optional<Align> Alignment = std::nullopt);
» more...

Return Value

  • The write-through buffer on success, or an error on failure.
  • The file contents on success, or an error on failure.

Parameters

NameDescription
FilenamePath of the file to map.
FileSizeSize of the file in bytes, or -1 to determine it from the file itself.
IsTextSet to true to indicate that the file should be read in text mode.
RequiresNullTerminatorWhether the buffer must be null-terminated.
IsVolatileSet to true to indicate that the contents of the file can change outside the user's control, e.g. when libclang tries to parse while the user is editing/updating the file or if the file is on an NFS.
AlignmentSet to indicate that the buffer should be aligned to at least the specified alignment.