LLVM 22.0.0git
llvm::vfs Namespace Reference

Namespaces

namespace  detail

Classes

class  directory_entry
 A member of a directory, yielded by a directory_iterator. More...
class  directory_iterator
 An input iterator over the entries in a virtual path, similar to llvm::sys::fs::directory_iterator. More...
class  File
 Represents an open file. More...
class  FileSystem
 The virtual file system interface. More...
class  HashingOutputBackend
 An output backend that only generates the hash for outputs. More...
class  HashingOutputFile
 HashingOutputFile. More...
class  HashingStream
 raw_pwrite_stream that writes to a hasher. More...
class  InMemoryFileSystem
 An in-memory file system. More...
class  NullOutputFileImpl
class  OnDiskOutputBackend
 An output backend that creates files on disk, wrapping APIs in sys::fs. More...
class  OutputBackend
 Interface for virtualized outputs. More...
struct  OutputConfig
 Full configuration for an output for use by the OutputBackend. More...
class  OutputConfigError
 Error related to an OutputConfig for an OutputFile. More...
class  OutputError
 Error related to an OutputFile. More...
class  OutputFile
 A virtualized output file that writes to a specific backend. More...
class  OutputFileImpl
class  OverlayFileSystem
 A file system that allows overlaying one AbstractFileSystem on top of another. More...
class  ProxyFileSystem
 By default, this delegates all calls to the underlying file system. More...
class  ProxyOutputBackend
 A helper class for proxying another backend, with the default implementation to forward to the underlying backend. More...
class  recursive_directory_iterator
 An input iterator over the recursive contents of a virtual path, similar to llvm::sys::fs::recursive_directory_iterator. More...
class  RedirectingFileSystem
 A virtual file system parsed from a YAML file. More...
class  RedirectingFileSystemParser
 A helper class to hold the common YAML parsing state. More...
class  RedirectingFSDirIterImpl
 Directory iterator implementation for RedirectingFileSystem's directory entries. More...
class  Status
 The result of a status operation. More...
class  TempFileOutputError
 Error related to a temporary file for an OutputFile. More...
class  TracingFileSystem
 File system that tracks the number of calls to the underlying file system. More...
struct  YAMLVFSEntry
class  YAMLVFSWriter

Enumerations

enum class  OutputErrorCode { not_closed = 1 , invalid_config , already_closed , has_open_proxy }

Functions

LLVM_ABI IntrusiveRefCntPtr< FileSystemgetRealFileSystem ()
 Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
LLVM_ABI std::unique_ptr< FileSystemcreatePhysicalFileSystem ()
 Create an vfs::FileSystem for the 'real' file system, as seen by the operating system.
LLVM_ABI llvm::sys::fs::UniqueID getNextVirtualUniqueID ()
 Get a globally unique ID for a virtual file or directory.
LLVM_ABI std::unique_ptr< FileSystemgetVFSFromYAML (std::unique_ptr< llvm::MemoryBuffer > Buffer, llvm::SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, void *DiagContext=nullptr, IntrusiveRefCntPtr< FileSystem > ExternalFS=getRealFileSystem())
 Gets a FileSystem for a virtual file system described in YAML format.
void collectVFSEntries (RedirectingFileSystem &VFS, SmallVectorImpl< YAMLVFSEntry > &CollectedEntries)
 Collect all pairs of <virtual path, real path> entries from the VFS.
IntrusiveRefCntPtr< OutputBackendmakeNullOutputBackend ()
 Create a backend that ignores all output.
IntrusiveRefCntPtr< OutputBackendmakeFilteringOutputBackend (IntrusiveRefCntPtr< OutputBackend > UnderlyingBackend, std::function< bool(StringRef, std::optional< OutputConfig >)> Filter)
 Make a backend where OutputBackend::createFile() forwards to UnderlyingBackend when Filter is true, and otherwise returns a NullOutput.
IntrusiveRefCntPtr< OutputBackendmakeMirroringOutputBackend (IntrusiveRefCntPtr< OutputBackend > Backend1, IntrusiveRefCntPtr< OutputBackend > Backend2)
 Create a backend that forwards OutputBackend::createFile() to both Backend1 and Backend2.
const std::error_category & output_category ()
std::error_code make_error_code (OutputErrorCode EV)
Error convertToOutputError (const Twine &OutputPath, std::error_code EC)
 Return Error::success() or use OutputPath to create an OutputError, depending on EC.
Error convertToTempFileOutputError (const Twine &TempPath, const Twine &OutputPath, std::error_code EC)
 Return Error::success() or use TempPath and OutputPath to create a TempFileOutputError, depending on EC.
void consumeDiscardOnDestroy (OutputFile &File)
 Update File to silently discard itself if it's still open when it's destroyed.
Expected< OutputFileconsumeDiscardOnDestroy (Expected< OutputFile > File)
 Update File to silently discard itself if it's still open when it's destroyed.
static sys::fs::UniqueID getUniqueID (hash_code Hash)
static sys::fs::UniqueID getFileID (sys::fs::UniqueID Parent, llvm::StringRef Name, llvm::StringRef Contents)
static sys::fs::UniqueID getDirectoryID (sys::fs::UniqueID Parent, llvm::StringRef Name)

Enumeration Type Documentation

◆ OutputErrorCode

enum class llvm::vfs::OutputErrorCode
strong
Enumerator
not_closed 
invalid_config 
already_closed 
has_open_proxy 

Definition at line 24 of file VirtualOutputError.h.

Function Documentation

◆ collectVFSEntries()

void llvm::vfs::collectVFSEntries ( RedirectingFileSystem & VFS,
SmallVectorImpl< YAMLVFSEntry > & CollectedEntries )

Collect all pairs of <virtual path, real path> entries from the VFS.

This is used by the module dependency collector to forward the entries into the reproducer output VFS YAML file.

Definition at line 2710 of file VirtualFileSystem.cpp.

References getVFSEntries(), llvm::vfs::RedirectingFileSystem::lookupPath(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

◆ consumeDiscardOnDestroy() [1/2]

Expected< OutputFile > llvm::vfs::consumeDiscardOnDestroy ( Expected< OutputFile > File)
inline

Update File to silently discard itself if it's still open when it's destroyed.

Definition at line 161 of file VirtualOutputFile.h.

References consumeDiscardOnDestroy().

◆ consumeDiscardOnDestroy() [2/2]

void llvm::vfs::consumeDiscardOnDestroy ( OutputFile & File)
inline

Update File to silently discard itself if it's still open when it's destroyed.

Definition at line 155 of file VirtualOutputFile.h.

References llvm::consumeError().

Referenced by consumeDiscardOnDestroy().

◆ convertToOutputError()

Error llvm::vfs::convertToOutputError ( const Twine & OutputPath,
std::error_code EC )
inline

Return Error::success() or use OutputPath to create an OutputError, depending on EC.

Definition at line 65 of file VirtualOutputError.h.

References llvm::make_error(), and llvm::Error::success().

Referenced by areFilesDifferent(), and llvm::vfs::OnDiskOutputBackend::makeAbsolute().

◆ convertToTempFileOutputError()

Error llvm::vfs::convertToTempFileOutputError ( const Twine & TempPath,
const Twine & OutputPath,
std::error_code EC )
inline

Return Error::success() or use TempPath and OutputPath to create a TempFileOutputError, depending on EC.

Definition at line 120 of file VirtualOutputError.h.

References llvm::make_error(), and llvm::Error::success().

◆ createPhysicalFileSystem()

std::unique_ptr< FileSystem > llvm::vfs::createPhysicalFileSystem ( )

Create an vfs::FileSystem for the 'real' file system, as seen by the operating system.

It has its own working directory, independent of (but initially equal to) that of the process.

Definition at line 405 of file VirtualFileSystem.cpp.

◆ getDirectoryID()

◆ getFileID()

◆ getNextVirtualUniqueID()

UniqueID llvm::vfs::getNextVirtualUniqueID ( )

Get a globally unique ID for a virtual file or directory.

Definition at line 2720 of file VirtualFileSystem.cpp.

Referenced by llvm::vfs::RedirectingFileSystemParser::lookupOrCreateEntry().

◆ getRealFileSystem()

◆ getUniqueID()

sys::fs::UniqueID llvm::vfs::getUniqueID ( hash_code Hash)
static

Definition at line 815 of file VirtualFileSystem.cpp.

Referenced by getDirectoryID(), and getFileID().

◆ getVFSFromYAML()

LLVM_ABI std::unique_ptr< FileSystem > llvm::vfs::getVFSFromYAML ( std::unique_ptr< llvm::MemoryBuffer > Buffer,
llvm::SourceMgr::DiagHandlerTy DiagHandler,
StringRef YAMLFilePath,
void * DiagContext = nullptr,
IntrusiveRefCntPtr< FileSystem > ExternalFS = getRealFileSystem() )

Gets a FileSystem for a virtual file system described in YAML format.

References DiagHandler().

◆ make_error_code()

◆ makeFilteringOutputBackend()

IntrusiveRefCntPtr< OutputBackend > llvm::vfs::makeFilteringOutputBackend ( IntrusiveRefCntPtr< OutputBackend > UnderlyingBackend,
std::function< bool(StringRef, std::optional< OutputConfig >)> Filter )

Make a backend where OutputBackend::createFile() forwards to UnderlyingBackend when Filter is true, and otherwise returns a NullOutput.

Definition at line 49 of file VirtualOutputBackends.cpp.

References assert(), llvm::vfs::ProxyOutputBackend::createFileImpl(), llvm::Filter, and llvm::makeIntrusiveRefCnt().

◆ makeMirroringOutputBackend()

IntrusiveRefCntPtr< OutputBackend > llvm::vfs::makeMirroringOutputBackend ( IntrusiveRefCntPtr< OutputBackend > Backend1,
IntrusiveRefCntPtr< OutputBackend > Backend2 )

Create a backend that forwards OutputBackend::createFile() to both Backend1 and Backend2.

Writing to such backend will create identical outputs using two different backends.

Definition at line 81 of file VirtualOutputBackends.cpp.

References assert(), llvm::consumeError(), llvm::raw_ostream::enable_colors(), llvm::isa(), llvm::joinErrors(), llvm::makeIntrusiveRefCnt(), llvm::Offset, llvm::vfs::ProxyOutputBackend::ProxyOutputBackend(), Ptr, llvm::Release, Retain, Size, and llvm::raw_ostream::write().

◆ makeNullOutputBackend()

IntrusiveRefCntPtr< OutputBackend > llvm::vfs::makeNullOutputBackend ( )

Create a backend that ignores all output.

Definition at line 35 of file VirtualOutputBackends.cpp.

References llvm::makeIntrusiveRefCnt().

◆ output_category()

const std::error_category & llvm::vfs::output_category ( )

Definition at line 50 of file VirtualOutputError.cpp.

References const, and output_category().

Referenced by make_error_code(), and output_category().