LLVM  16.0.0git
Public Member Functions | List of all members
llvm::unittest::TempFile Class Reference

A RAII object that creates a file upon initialization and removes it upon destruction. More...

#include "llvm/Testing/Support/SupportHelpers.h"

Public Member Functions

 TempFile (StringRef Name, StringRef Suffix="", StringRef Contents="", bool Unique=false)
 Creates a managed file. More...
 
 ~TempFile ()
 
 TempFile (const TempFile &)=delete
 
TempFileoperator= (const TempFile &)=delete
 
 TempFile (TempFile &&)=default
 
TempFileoperator= (TempFile &&)=default
 
StringRef path () const
 The path to the file. More...
 

Detailed Description

A RAII object that creates a file upon initialization and removes it upon destruction.

Definition at line 203 of file SupportHelpers.h.

Constructor & Destructor Documentation

◆ TempFile() [1/3]

llvm::unittest::TempFile::TempFile ( StringRef  Name,
StringRef  Suffix = "",
StringRef  Contents = "",
bool  Unique = false 
)
inline

Creates a managed file.

Parameters
NameThe name of the file to create.
ContentsThe string to write to the file.
UniqueIf true, the file will be created using llvm::sys::fs::createTemporaryFile.

Definition at line 213 of file SupportHelpers.h.

References llvm::sys::fs::createTemporaryFile(), llvm::raw_fd_ostream::error(), llvm::raw_ostream::flush(), and llvm::sys::fs::openFileForWrite().

◆ ~TempFile()

llvm::unittest::TempFile::~TempFile ( )
inline

Definition at line 235 of file SupportHelpers.h.

References llvm::sys::fs::remove().

◆ TempFile() [2/3]

llvm::unittest::TempFile::TempFile ( const TempFile )
delete

◆ TempFile() [3/3]

llvm::unittest::TempFile::TempFile ( TempFile &&  )
default

Member Function Documentation

◆ operator=() [1/2]

TempFile& llvm::unittest::TempFile::operator= ( const TempFile )
delete

◆ operator=() [2/2]

TempFile& llvm::unittest::TempFile::operator= ( TempFile &&  )
default

◆ path()

StringRef llvm::unittest::TempFile::path ( ) const
inline

The path to the file.

Definition at line 248 of file SupportHelpers.h.


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