LLVM 20.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.
 
 ~TempFile ()
 
 TempFile (const TempFile &)=delete
 
TempFileoperator= (const TempFile &)=delete
 
 TempFile (TempFile &&)=default
 
TempFileoperator= (TempFile &&)=default
 
StringRef path () const
 The path to the file.
 

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(), Name, llvm::sys::fs::openFileForWrite(), and OS.

◆ ~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: