#include #include #include #include #include #include ">

LLVM: lib/Support/MemoryBuffer.cpp File Reference (original) (raw)

#include "[llvm/Support/MemoryBuffer.h](MemoryBuffer%5F8h%5Fsource.html)"
#include "[llvm/ADT/STLExtras.h](STLExtras%5F8h%5Fsource.html)"
#include "[llvm/ADT/SmallString.h](SmallString%5F8h%5Fsource.html)"
#include "llvm/Config/config.h"
#include "[llvm/Support/Alignment.h](Alignment%5F8h%5Fsource.html)"
#include "[llvm/Support/AutoConvert.h](AutoConvert%5F8h%5Fsource.html)"
#include "[llvm/Support/Errc.h](Errc%5F8h%5Fsource.html)"
#include "[llvm/Support/Error.h](llvm%5F2Support%5F2Error%5F8h%5Fsource.html)"
#include "[llvm/Support/ErrorHandling.h](llvm%5F2Support%5F2ErrorHandling%5F8h%5Fsource.html)"
#include "[llvm/Support/FileSystem.h](FileSystem%5F8h%5Fsource.html)"
#include "[llvm/Support/Process.h](Process%5F8h%5Fsource.html)"
#include "[llvm/Support/Program.h](Program%5F8h%5Fsource.html)"
#include "[llvm/Support/SmallVectorMemoryBuffer.h](SmallVectorMemoryBuffer%5F8h%5Fsource.html)"
#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
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
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)

CopyStringRef()

getFileAux()

Definition at line 274 of file MemoryBuffer.cpp.

References llvm::sys::fs::closeFile(), llvm::errorToErrorCode(), getOpenFileImpl(), llvm::sys::fs::OF_None, llvm::sys::fs::OF_TextWithCRLF, llvm::Offset, llvm::sys::fs::openNativeFileForRead(), and llvm::Expected< T >::takeError().

Referenced by llvm::MemoryBuffer::getFile(), llvm::WritableMemoryBuffer::getFile(), llvm::MemoryBuffer::getFileSlice(), and llvm::WritableMemoryBuffer::getFileSlice().

getMemBufferCopyImpl()

getMemoryBufferForStream()

getOpenFileImpl()

Definition at line 470 of file MemoryBuffer.cpp.

References llvm::sys::fs::block_file, llvm::MutableArrayRef< T >::data(), llvm::MutableArrayRef< T >::drop_front(), llvm::ArrayRef< T >::empty(), llvm::errorToErrorCode(), llvm::ErrorOr< T >::getError(), getMemoryBufferForStream(), llvm::WritableMemoryBuffer::getNewUninitMemBuffer(), llvm::sys::Process::getPageSizeEstimate(), llvm::make_error_code(), llvm::not_enough_memory, llvm::Offset, PageSize, llvm::sys::fs::readNativeFileSlice(), llvm::sys::fs::regular_file, shouldUseMmap(), llvm::ArrayRef< T >::size(), llvm::sys::fs::status(), and llvm::Expected< T >::takeError().

Referenced by getFileAux(), llvm::MemoryBuffer::getOpenFile(), and llvm::MemoryBuffer::getOpenFileSlice().

getReadWriteFile()

Definition at line 416 of file MemoryBuffer.cpp.

References llvm::sys::fs::block_file, llvm::sys::fs::CD_OpenExisting, llvm::errorToErrorCode(), llvm::invalid_argument, llvm::make_error_code(), llvm::sys::fs::OF_None, llvm::Offset, llvm::sys::fs::openNativeFileForReadWrite(), llvm::sys::fs::regular_file, llvm::sys::fs::status(), and llvm::Expected< T >::takeError().

Referenced by llvm::WriteThroughMemoryBuffer::getFile(), and llvm::WriteThroughMemoryBuffer::getFileSlice().

operator new()

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

shouldUseMmap()

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