LLVM 22.0.0git
llvm::vfs::OutputFile Class Reference

A virtualized output file that writes to a specific backend. More...

#include "llvm/Support/VirtualOutputFile.h"

Classes

class  TrackedProxy

Public Member Functions

StringRef getPath () const
bool isOpen () const
 Check if keep() or discard() has already been called.
 operator bool () const
raw_pwrite_streamgetOS ()
 operator raw_pwrite_stream & ()
template<class T>
raw_ostreamoperator<< (T &&V)
Error keep ()
 Keep an output.
Error discard ()
 Discard an output, cleaning up any temporary state.
void discardOnDestroy (unique_function< void(Error E)> Handler)
 Discard the output when destroying it if it's still open, sending the result to Handler.
Expected< std::unique_ptr< raw_pwrite_stream > > createProxy ()
 Create a proxy stream for clients that need to pass an owned stream to a producer.
bool hasOpenProxy () const
std::unique_ptr< OutputFileImpltakeImpl ()
 Take the implementation.
bool isNull () const
 Check whether this is a null output file.
 OutputFile ()=default
 OutputFile (const Twine &Path, std::unique_ptr< OutputFileImpl > Impl)
 ~OutputFile ()
 OutputFile (OutputFile &&O)
OutputFileoperator= (OutputFile &&O)

Detailed Description

A virtualized output file that writes to a specific backend.

One of keep(), discard(), or discardOnDestroy() must be called before destruction.

Definition at line 59 of file VirtualOutputFile.h.

Constructor & Destructor Documentation

◆ OutputFile() [1/3]

llvm::vfs::OutputFile::OutputFile ( )
default

Referenced by operator=(), and OutputFile().

◆ OutputFile() [2/3]

llvm::vfs::OutputFile::OutputFile ( const Twine & Path,
std::unique_ptr< OutputFileImpl > Impl )
inlineexplicit

Definition at line 120 of file VirtualOutputFile.h.

References assert(), and llvm::move().

◆ ~OutputFile()

llvm::vfs::OutputFile::~OutputFile ( )
inline

Definition at line 125 of file VirtualOutputFile.h.

◆ OutputFile() [3/3]

llvm::vfs::OutputFile::OutputFile ( OutputFile && O)
inline

Definition at line 126 of file VirtualOutputFile.h.

References OutputFile().

Member Function Documentation

◆ createProxy()

Expected< std::unique_ptr< raw_pwrite_stream > > OutputFile::createProxy ( )

Create a proxy stream for clients that need to pass an owned stream to a producer.

Errors if there's already a proxy. The proxy must be deleted before calling keep(). The proxy will crash if it's written to after calling discard().

Definition at line 46 of file VirtualOutputFile.cpp.

References getOS(), getPath(), llvm::vfs::has_open_proxy, and llvm::make_error().

◆ discard()

Error OutputFile::discard ( )

Discard an output, cleaning up any temporary state.

Errors if clean-up fails.

If it has already been closed, calls report_fatal_error().

Definition at line 74 of file VirtualOutputFile.cpp.

References llvm::vfs::already_closed, getPath(), LLVM_UNLIKELY, llvm::make_error(), and llvm::report_fatal_error().

Referenced by keep().

◆ discardOnDestroy()

void llvm::vfs::OutputFile::discardOnDestroy ( unique_function< void(Error E)> Handler)
inline

Discard the output when destroying it if it's still open, sending the result to Handler.

Definition at line 93 of file VirtualOutputFile.h.

References E().

◆ getOS()

raw_pwrite_stream & llvm::vfs::OutputFile::getOS ( )
inline

Definition at line 68 of file VirtualOutputFile.h.

References assert(), and isOpen().

Referenced by createProxy(), operator raw_pwrite_stream &(), and operator<<().

◆ getPath()

StringRef llvm::vfs::OutputFile::getPath ( ) const
inline

Definition at line 61 of file VirtualOutputFile.h.

Referenced by createProxy(), discard(), and keep().

◆ hasOpenProxy()

bool llvm::vfs::OutputFile::hasOpenProxy ( ) const
inline

Definition at line 103 of file VirtualOutputFile.h.

Referenced by takeImpl().

◆ isNull()

bool llvm::vfs::OutputFile::isNull ( ) const
inline

Check whether this is a null output file.

Definition at line 116 of file VirtualOutputFile.h.

References llvm::isa().

◆ isOpen()

bool llvm::vfs::OutputFile::isOpen ( ) const
inline

Check if keep() or discard() has already been called.

Definition at line 64 of file VirtualOutputFile.h.

Referenced by getOS(), and operator bool().

◆ keep()

Error OutputFile::keep ( )

Keep an output.

Errors if this fails.

If it has already been closed, calls report_fatal_error().

If there's an open proxy from createProxy(), calls discard() to clean up temporaries followed by report_fatal_error().

Definition at line 53 of file VirtualOutputFile.cpp.

References llvm::vfs::already_closed, discard(), getPath(), llvm::vfs::has_open_proxy, llvm::joinErrors(), LLVM_UNLIKELY, llvm::make_error(), and llvm::report_fatal_error().

◆ operator bool()

llvm::vfs::OutputFile::operator bool ( ) const
inlineexplicit

Definition at line 66 of file VirtualOutputFile.h.

References isOpen().

◆ operator raw_pwrite_stream &()

llvm::vfs::OutputFile::operator raw_pwrite_stream & ( )
inline

Definition at line 72 of file VirtualOutputFile.h.

References getOS().

◆ operator<<()

template<class T>
raw_ostream & llvm::vfs::OutputFile::operator<< ( T && V)
inline

Definition at line 73 of file VirtualOutputFile.h.

References getOS(), and T.

◆ operator=()

OutputFile & llvm::vfs::OutputFile::operator= ( OutputFile && O)
inline

Definition at line 127 of file VirtualOutputFile.h.

References OutputFile().

◆ takeImpl()

std::unique_ptr< OutputFileImpl > llvm::vfs::OutputFile::takeImpl ( )
inline

Take the implementation.

Precondition
hasOpenProxy() is false.
discardOnDestroy() has not been called.

Definition at line 109 of file VirtualOutputFile.h.

References assert(), and hasOpenProxy().


The documentation for this class was generated from the following files: