LLVM 20.0.0git
Functions
MemoryBuffer.cpp File Reference
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Config/config.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/SmallVectorMemoryBuffer.h"
#include <algorithm>
#include <cassert>
#include <cstring>
#include <new>
#include <sys/types.h>
#include <system_error>
#include <unistd.h>

Go to the source code of this file.

Functions

static void CopyStringRef (char *Memory, StringRef Data)
 CopyStringRef - Copies contents of a StringRef into a block of memory and null-terminates it.
 
void * operator new (size_t N, const NamedBufferAlloc &Alloc)
 
template<typename MB >
static ErrorOr< std::unique_ptr< MB > > getFileAux (const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsText, bool RequiresNullTerminator, bool IsVolatile, std::optional< Align > Alignment)
 
static ErrorOr< std::unique_ptr< WritableMemoryBuffer > > getMemBufferCopyImpl (StringRef InputData, const Twine &BufferName)
 
static ErrorOr< std::unique_ptr< WritableMemoryBuffer > > getMemoryBufferForStream (sys::fs::file_t FD, const Twine &BufferName)
 
template<typename MB >
static ErrorOr< std::unique_ptr< MB > > getOpenFileImpl (sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, uint64_t MapSize, int64_t Offset, bool RequiresNullTerminator, bool IsVolatile, std::optional< Align > Alignment)
 
static bool shouldUseMmap (sys::fs::file_t FD, size_t FileSize, size_t MapSize, off_t Offset, bool RequiresNullTerminator, int PageSize, bool IsVolatile)
 
static ErrorOr< std::unique_ptr< WriteThroughMemoryBuffer > > getReadWriteFile (const Twine &Filename, uint64_t FileSize, uint64_t MapSize, uint64_t Offset)
 

Function Documentation

◆ CopyStringRef()

static void CopyStringRef ( char Memory,
StringRef  Data 
)
static

CopyStringRef - Copies contents of a StringRef into a block of memory and null-terminates it.

Definition at line 64 of file MemoryBuffer.cpp.

References llvm::Data.

Referenced by llvm::WritableMemoryBuffer::getNewUninitMemBuffer(), and operator new().

◆ getFileAux()

template<typename MB >
static ErrorOr< std::unique_ptr< MB > > getFileAux ( const Twine Filename,
uint64_t  MapSize,
uint64_t  Offset,
bool  IsText,
bool  RequiresNullTerminator,
bool  IsVolatile,
std::optional< Align Alignment 
)
static

◆ getMemBufferCopyImpl()

static ErrorOr< std::unique_ptr< WritableMemoryBuffer > > getMemBufferCopyImpl ( StringRef  InputData,
const Twine BufferName 
)
static

◆ getMemoryBufferForStream()

static ErrorOr< std::unique_ptr< WritableMemoryBuffer > > getMemoryBufferForStream ( sys::fs::file_t  FD,
const Twine BufferName 
)
static

◆ getOpenFileImpl()

template<typename MB >
static ErrorOr< std::unique_ptr< MB > > getOpenFileImpl ( sys::fs::file_t  FD,
const Twine Filename,
uint64_t  FileSize,
uint64_t  MapSize,
int64_t  Offset,
bool  RequiresNullTerminator,
bool  IsVolatile,
std::optional< Align Alignment 
)
static

◆ getReadWriteFile()

static ErrorOr< std::unique_ptr< WriteThroughMemoryBuffer > > getReadWriteFile ( const Twine Filename,
uint64_t  FileSize,
uint64_t  MapSize,
uint64_t  Offset 
)
static

◆ operator new()

void * operator new ( size_t  N,
const NamedBufferAlloc &  Alloc 
)

◆ shouldUseMmap()

static bool shouldUseMmap ( sys::fs::file_t  FD,
size_t  FileSize,
size_t  MapSize,
off_t  Offset,
bool  RequiresNullTerminator,
int  PageSize,
bool  IsVolatile 
)
static

Definition at line 357 of file MemoryBuffer.cpp.

References assert(), End, llvm::Offset, PageSize, and llvm::sys::fs::status().

Referenced by getOpenFileImpl().