LLVM 19.0.0git
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
llvm::sys Namespace Reference

Namespaces

namespace  detail
 
namespace  fs
 
namespace  locale
 
namespace  path
 
namespace  unicode
 
namespace  windows
 

Classes

class  DynamicLibrary
 This class provides a portable interface to dynamic libraries which also might be known as shared libraries, shared objects, dynamic shared objects, or dynamic link libraries. More...
 
class  InitializeCOMRAII
 
class  Memory
 This class provides various memory handling functions that manipulate MemoryBlock instances. More...
 
class  MemoryBlock
 This class encapsulates the notion of a memory block which has an address and a size. More...
 
class  OwningMemoryBlock
 Owning version of MemoryBlock. More...
 
class  Process
 A collection of legacy interfaces for querying information about the current executing process. More...
 
struct  ProcessInfo
 This struct encapsulates information about a process. More...
 
struct  ProcessStatistics
 This struct encapsulates information about a process execution. More...
 
class  SmartMutex
 SmartMutex - A mutex with a compile time constant parameter that indicates whether this mutex should become a no-op when we're not running in multithreaded mode. More...
 
class  SmartRWMutex
 SmartMutex - An R/W mutex with a compile time constant parameter that indicates whether this mutex should become a no-op when we're not running in multithreaded mode. More...
 
struct  UnicodeCharRange
 Represents a closed range of Unicode code points [Lower, Upper]. More...
 
class  UnicodeCharSet
 Holds a reference to an ordered array of UnicodeCharRange and allows to quickly check if a code point is contained in the set represented by this array. More...
 
class  UtcClock
 
class  Watchdog
 This class provides an abstraction for a timeout around an operation that must complete in a given amount of time. More...
 

Typedefs

typedef uint32_t cas_flag
 
template<typename D = std::chrono::nanoseconds>
using TimePoint = std::chrono::time_point< std::chrono::system_clock, D >
 A time point on the system clock.
 
template<typename D = std::chrono::nanoseconds>
using UtcTime = std::chrono::time_point< UtcClock, D >
 
typedef SmartMutex< false > Mutex
 Mutex - A standard, always enforced mutex.
 
template<bool mt_only>
using SmartScopedLock = std::lock_guard< SmartMutex< mt_only > >
 
typedef SmartScopedLock< false > ScopedLock
 
typedef ::pid_t procid_t
 
typedef procid_t process_t
 
typedef SmartRWMutex< false > RWMutex
 
template<bool mt_only>
using SmartScopedReader = const std::shared_lock< SmartRWMutex< mt_only > >
 ScopedReader - RAII acquisition of a reader lock.
 
typedef SmartScopedReader< false > ScopedReader
 
template<bool mt_only>
using SmartScopedWriter = std::lock_guard< SmartRWMutex< mt_only > >
 ScopedWriter - RAII acquisition of a writer lock.
 
typedef SmartScopedWriter< false > ScopedWriter
 
using SignalHandlerCallback = void(*)(void *)
 

Enumerations

enum class  COMThreadingMode { SingleThreaded , MultiThreaded }
 
enum  WindowsEncodingMethod { WEM_UTF8 , WEM_CurrentCodePage , WEM_UTF16 }
 File encoding options when writing contents that a non-UTF8 tool will read (on Windows systems). More...
 

Functions

void MemoryFence ()
 
cas_flag CompareAndSwap (volatile cas_flag *ptr, cas_flag new_value, cas_flag old_value)
 
UtcTime< std::chrono::seconds > toUtcTime (std::time_t T)
 Convert a std::time_t to a UtcTime.
 
std::time_t toTimeT (TimePoint<> TP)
 Convert a TimePoint to std::time_t.
 
std::time_t toTimeT (UtcTime<> TP)
 Convert a UtcTime to std::time_t.
 
TimePoint< std::chrono::seconds > toTimePoint (std::time_t T)
 Convert a std::time_t to a TimePoint.
 
TimePoint toTimePoint (std::time_t T, uint32_t nsec)
 Convert a std::time_t + nanoseconds to a TimePoint.
 
std::string StrError ()
 Returns a string representation of the errno value, using whatever thread-safe variant of strerror() is available.
 
std::string StrError (int errnum)
 Like the no-argument version above, but uses errnum instead of errno.
 
template<typename FailT , typename Fun , typename... Args>
decltype(auto) RetryAfterSignal (const FailT &Fail, const Fun &F, const Args &... As)
 
raw_ostreamoperator<< (raw_ostream &OS, const Memory::ProtectionFlags &PF)
 Debugging output for Memory::ProtectionFlags.
 
raw_ostreamoperator<< (raw_ostream &OS, const MemoryBlock &MB)
 Debugging output for MemoryBlock.
 
ErrorOr< std::string > findProgramByName (StringRef Name, ArrayRef< StringRef > Paths={})
 Find the first executable file Name in Paths.
 
std::error_code ChangeStdinMode (fs::OpenFlags Flags)
 
std::error_code ChangeStdoutMode (fs::OpenFlags Flags)
 
std::error_code ChangeStdinToBinary ()
 
std::error_code ChangeStdoutToBinary ()
 
int ExecuteAndWait (StringRef Program, ArrayRef< StringRef > Args, std::optional< ArrayRef< StringRef > > Env=std::nullopt, ArrayRef< std::optional< StringRef > > Redirects={}, unsigned SecondsToWait=0, unsigned MemoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr, std::optional< ProcessStatistics > *ProcStat=nullptr, BitVector *AffinityMask=nullptr)
 This function executes the program using the arguments provided.
 
ProcessInfo ExecuteNoWait (StringRef Program, ArrayRef< StringRef > Args, std::optional< ArrayRef< StringRef > > Env, ArrayRef< std::optional< StringRef > > Redirects={}, unsigned MemoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr, BitVector *AffinityMask=nullptr, bool DetachProcess=false)
 Similar to ExecuteAndWait, but returns immediately.
 
bool commandLineFitsWithinSystemLimits (StringRef Program, ArrayRef< StringRef > Args)
 Return true if the given arguments fit within system-specific argument length limits.
 
bool commandLineFitsWithinSystemLimits (StringRef Program, ArrayRef< const char * > Args)
 Return true if the given arguments fit within system-specific argument length limits.
 
std::error_code writeFileWithEncoding (StringRef FileName, StringRef Contents, WindowsEncodingMethod Encoding=WEM_UTF8)
 Saves the UTF8-encoded contents string into the file FileName using a specific encoding.
 
ProcessInfo Wait (const ProcessInfo &PI, std::optional< unsigned > SecondsToWait, std::string *ErrMsg=nullptr, std::optional< ProcessStatistics > *ProcStat=nullptr, bool Polling=false)
 This function waits for the process specified by PI to finish.
 
void printArg (llvm::raw_ostream &OS, StringRef Arg, bool Quote)
 Print a command argument, and optionally quote it.
 
void RunInterruptHandlers ()
 This function runs all the registered interrupt handlers, including the removal of files registered by RemoveFileOnSignal.
 
bool RemoveFileOnSignal (StringRef Filename, std::string *ErrMsg=nullptr)
 This function registers signal handlers to ensure that if a signal gets delivered that the named file is removed.
 
void DontRemoveFileOnSignal (StringRef Filename)
 This function removes a file from the list of files to be removed on signal delivery.
 
void PrintStackTraceOnErrorSignal (StringRef Argv0, bool DisableCrashReporting=false)
 When an error signal (such as SIGABRT or SIGSEGV) is delivered to the process, print a stack trace and then exit.
 
void DisableSystemDialogsOnCrash ()
 Disable all system dialog boxes that appear when the process crashes.
 
void PrintStackTrace (raw_ostream &OS, int Depth=0)
 Print the stack trace using the given raw_ostream object.
 
void RunSignalHandlers ()
 
void AddSignalHandler (SignalHandlerCallback FnPtr, void *Cookie)
 Add a function to be called when an abort/kill signal is delivered to the process.
 
void SetInterruptFunction (void(*IF)())
 This function registers a function to be called when the user "interrupts" the program (typically by pressing ctrl-c).
 
void SetInfoSignalFunction (void(*Handler)())
 Registers a function to be called when an "info" signal is delivered to the process.
 
void SetOneShotPipeSignalFunction (void(*Handler)())
 Registers a function to be called in a "one-shot" manner when a pipe signal is delivered to the process (i.e., on a failed write to a pipe).
 
void DefaultOneShotPipeSignalHandler ()
 On Unix systems and Windows, this function exits with an "IO error" exit code.
 
void CleanupOnSignal (uintptr_t Context)
 This function does the following:
 
void unregisterHandlers ()
 
unsigned char getSwappedBytes (unsigned char C)
 
signed char getSwappedBytes (signed char C)
 
char getSwappedBytes (char C)
 
unsigned short getSwappedBytes (unsigned short C)
 
signed short getSwappedBytes (signed short C)
 
unsigned int getSwappedBytes (unsigned int C)
 
signed int getSwappedBytes (signed int C)
 
unsigned long getSwappedBytes (unsigned long C)
 
signed long getSwappedBytes (signed long C)
 
unsigned long long getSwappedBytes (unsigned long long C)
 
signed long long getSwappedBytes (signed long long C)
 
float getSwappedBytes (float C)
 
double getSwappedBytes (double C)
 
template<typename T >
std::enable_if_t< std::is_enum_v< T >, TgetSwappedBytes (T C)
 
template<typename T >
void swapByteOrder (T &Value)
 
bool operator< (uint32_t Value, UnicodeCharRange Range)
 
bool operator< (UnicodeCharRange Range, uint32_t Value)
 
bool RunningOnValgrind ()
 
void ValgrindDiscardTranslations (const void *Addr, size_t Len)
 
std::chrono::nanoseconds toDuration (FILETIME Time)
 
TimePoint toTimePoint (FILETIME Time)
 
FILETIME toFILETIME (TimePoint<> TP)
 
std::string getDefaultTargetTriple ()
 getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produce code for.
 
std::string getProcessTriple ()
 getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the current process, e.g.
 
StringRef getHostCPUName ()
 getHostCPUName - Get the LLVM name for the host CPU.
 
bool getHostCPUFeatures (StringMap< bool, MallocAllocator > &Features)
 getHostCPUFeatures - Get the LLVM names for the host CPU features.
 
void printDefaultTargetAndDetectedCPU (raw_ostream &OS)
 This is a function compatible with cl::AddExtraVersionPrinter, which adds info about the current target triple and detected CPU.
 
std::chrono::microseconds toDuration (const struct timeval &TV)
 Convert a struct timeval to a duration.
 
struct timespec toTimeSpec (TimePoint<> TP)
 Convert a time point to struct timespec.
 
struct timeval toTimeVal (TimePoint< std::chrono::microseconds > TP)
 Convert a time point to struct timeval.
 

Variables

const char EnvPathSeparator = ':'
 This is the OS-specific separator for PATH like environment variables:
 
constexpr bool IsBigEndianHost
 
static const bool IsLittleEndianHost = !IsBigEndianHost
 

Typedef Documentation

◆ cas_flag

Definition at line 34 of file Atomic.h.

◆ Mutex

typedef SmartMutex<false> llvm::sys::Mutex

Mutex - A standard, always enforced mutex.

Definition at line 66 of file Mutex.h.

◆ process_t

Definition at line 42 of file Program.h.

◆ procid_t

typedef ::pid_t llvm::sys::procid_t

Definition at line 41 of file Program.h.

◆ RWMutex

Definition at line 153 of file RWMutex.h.

◆ ScopedLock

Definition at line 71 of file Mutex.h.

◆ ScopedReader

Definition at line 170 of file RWMutex.h.

◆ ScopedWriter

Definition at line 187 of file RWMutex.h.

◆ SignalHandlerCallback

using llvm::sys::SignalHandlerCallback = typedef void (*)(void *)

Definition at line 61 of file Signals.h.

◆ SmartScopedLock

template<bool mt_only>
using llvm::sys::SmartScopedLock = typedef std::lock_guard<SmartMutex<mt_only> >

Definition at line 69 of file Mutex.h.

◆ SmartScopedReader

template<bool mt_only>
using llvm::sys::SmartScopedReader = typedef const std::shared_lock<SmartRWMutex<mt_only> >

ScopedReader - RAII acquisition of a reader lock.

Definition at line 158 of file RWMutex.h.

◆ SmartScopedWriter

template<bool mt_only>
using llvm::sys::SmartScopedWriter = typedef std::lock_guard<SmartRWMutex<mt_only> >

ScopedWriter - RAII acquisition of a writer lock.

Definition at line 175 of file RWMutex.h.

◆ TimePoint

template<typename D = std::chrono::nanoseconds>
using llvm::sys::TimePoint = typedef std::chrono::time_point<std::chrono::system_clock, D>

A time point on the system clock.

This is provided for two reasons:

  • to insulate us against subtle differences in behavior to differences in system clock precision (which is implementation-defined and differs between platforms).
  • to shorten the type name The default precision is nanoseconds. If you need a specific precision specify it explicitly. If unsure, use the default. If you need a time point on a clock other than the system_clock, use std::chrono directly.

Definition at line 34 of file Chrono.h.

◆ UtcTime

template<typename D = std::chrono::nanoseconds>
using llvm::sys::UtcTime = typedef std::chrono::time_point<UtcClock, D>

Definition at line 41 of file Chrono.h.

Enumeration Type Documentation

◆ COMThreadingMode

enum class llvm::sys::COMThreadingMode
strong
Enumerator
SingleThreaded 
MultiThreaded 

Definition at line 20 of file COM.h.

◆ WindowsEncodingMethod

File encoding options when writing contents that a non-UTF8 tool will read (on Windows systems).

For UNIX, we always use UTF-8.

Enumerator
WEM_UTF8 

UTF-8 is the LLVM native encoding, being the same as "do not perform encoding conversion".

WEM_CurrentCodePage 
WEM_UTF16 

Definition at line 172 of file Program.h.

Function Documentation

◆ AddSignalHandler()

void llvm::sys::AddSignalHandler ( SignalHandlerCallback  FnPtr,
void *  Cookie 
)

Add a function to be called when an abort/kill signal is delivered to the process.

The handler can have a cookie passed to it to identify what instance of the handler it is.

Referenced by llvm::dbgs(), llvm::InitLLVM::InitLLVM(), and llvm::PrintCrashIRInstrumentation::registerCallbacks().

◆ ChangeStdinMode()

std::error_code llvm::sys::ChangeStdinMode ( fs::OpenFlags  Flags)

◆ ChangeStdinToBinary()

std::error_code llvm::sys::ChangeStdinToBinary ( )

◆ ChangeStdoutMode()

std::error_code llvm::sys::ChangeStdoutMode ( fs::OpenFlags  Flags)

Referenced by getFD().

◆ ChangeStdoutToBinary()

std::error_code llvm::sys::ChangeStdoutToBinary ( )

◆ CleanupOnSignal()

void llvm::sys::CleanupOnSignal ( uintptr_t  Context)

This function does the following:

  • clean up any temporary files registered with RemoveFileOnSignal()
  • dump the callstack from the exception context
  • call any relevant interrupt/signal handlers
  • create a core/mini dump of the exception context whenever possible Context is a system-specific failure context: it is the signal type on Unix; the ExceptionContext on Windows.

◆ commandLineFitsWithinSystemLimits() [1/2]

bool llvm::sys::commandLineFitsWithinSystemLimits ( StringRef  Program,
ArrayRef< const char * >  Args 
)

Return true if the given arguments fit within system-specific argument length limits.

Definition at line 75 of file Program.cpp.

References A, commandLineFitsWithinSystemLimits(), llvm::SmallVectorImpl< T >::emplace_back(), and llvm::SmallVectorImpl< T >::reserve().

◆ commandLineFitsWithinSystemLimits() [2/2]

bool llvm::sys::commandLineFitsWithinSystemLimits ( StringRef  Program,
ArrayRef< StringRef Args 
)

Return true if the given arguments fit within system-specific argument length limits.

Referenced by commandLineFitsWithinSystemLimits().

◆ CompareAndSwap()

sys::cas_flag llvm::sys::CompareAndSwap ( volatile cas_flag ptr,
sys::cas_flag  new_value,
sys::cas_flag  old_value 
)

Definition at line 44 of file Atomic.cpp.

Referenced by llvm::call_once().

◆ DefaultOneShotPipeSignalHandler()

void llvm::sys::DefaultOneShotPipeSignalHandler ( )

On Unix systems and Windows, this function exits with an "IO error" exit code.

Referenced by llvm::InitLLVM::InitLLVM().

◆ DisableSystemDialogsOnCrash()

void llvm::sys::DisableSystemDialogsOnCrash ( )

Disable all system dialog boxes that appear when the process crashes.

Referenced by llvm::CrashRecoveryContext::CrashRecoveryContext().

◆ DontRemoveFileOnSignal()

void llvm::sys::DontRemoveFileOnSignal ( StringRef  Filename)

This function removes a file from the list of files to be removed on signal delivery.

Referenced by llvm::sys::fs::TempFile::discard(), llvm::sys::fs::TempFile::keep(), and llvm::LockFileManager::~LockFileManager().

◆ ExecuteAndWait()

int llvm::sys::ExecuteAndWait ( StringRef  Program,
ArrayRef< StringRef Args,
std::optional< ArrayRef< StringRef > >  Env = std::nullopt,
ArrayRef< std::optional< StringRef > >  Redirects = {},
unsigned  SecondsToWait = 0,
unsigned  MemoryLimit = 0,
std::string *  ErrMsg = nullptr,
bool ExecutionFailed = nullptr,
std::optional< ProcessStatistics > *  ProcStat = nullptr,
BitVector AffinityMask = nullptr 
)

This function executes the program using the arguments provided.

The invoked program will inherit the stdin, stdout, and stderr file descriptors, the environment and other configuration settings of the invoking program. This function waits for the program to finish, so should be avoided in library functions that aren't expected to block. Consider using ExecuteNoWait() instead.

Returns
an integer result code indicating the status of the program. A zero or positive value indicates the result code of the program. -1 indicates failure to execute -2 indicates a crash during execution or timeout
Parameters
ProgramPath of the program to be executed. It is presumed this is the result of the findProgramByName method.
ArgsAn array of strings that are passed to the program. The first element should be the name of the program. The array should not be terminated by an empty StringRef.
EnvAn optional vector of strings to use for the program's environment. If not provided, the current program's environment will be used. If specified, the vector should not be terminated by an empty StringRef.
RedirectsAn array of optional paths. Should have a size of zero or three. If the array is empty, no redirections are performed. Otherwise, the inferior process's stdin(0), stdout(1), and stderr(2) will be redirected to the corresponding paths, if the optional path is present (not std::nullopt). When an empty path is passed in, the corresponding file descriptor will be disconnected (ie, /dev/null'd) in a portable way.
SecondsToWaitIf non-zero, this specifies the amount of time to wait for the child process to exit. If the time expires, the child is killed and this call returns. If zero, this function will wait until the child finishes or forever if it doesn't.
MemoryLimitIf non-zero, this specifies max. amount of memory can be allocated by process. If memory usage will be higher limit, the child is killed and this call returns. If zero
  • no memory limit.
ErrMsgIf non-zero, provides a pointer to a string instance in which error messages will be returned. If the string is non-empty upon return an error occurred while invoking the program.
ProcStatIf non-zero,
AffinityMaskprovides a pointer to a structure in which process execution statistics will be stored. CPUs or processors the new program shall run on.

Definition at line 32 of file Program.cpp.

References assert(), Execute(), and llvm::Wait.

Referenced by llvm::doSystemDiff(), ExecGraphViewer(), llvm::DotCfgChangeReporter::genHTML(), llvm::IRChangedTester::handleIR(), and printSymbolizedStackTrace().

◆ ExecuteNoWait()

ProcessInfo llvm::sys::ExecuteNoWait ( StringRef  Program,
ArrayRef< StringRef Args,
std::optional< ArrayRef< StringRef > >  Env,
ArrayRef< std::optional< StringRef > >  Redirects = {},
unsigned  MemoryLimit = 0,
std::string *  ErrMsg = nullptr,
bool ExecutionFailed = nullptr,
BitVector AffinityMask = nullptr,
bool  DetachProcess = false 
)

Similar to ExecuteAndWait, but returns immediately.

Returns
The ProcessInfo of the newly launched process.
Note
On Microsoft Windows systems, users will need to either call Wait until the process has finished executing or win32's CloseHandle API on ProcessInfo.ProcessHandle to avoid memory leaks.
Parameters
DetachProcessIf true the executed program detatches from the controlling terminal. I/O streams such as llvm::outs, llvm::errs, and stdin will be closed until redirected to another output location

Definition at line 57 of file Program.cpp.

References assert(), and Execute().

Referenced by ExecGraphViewer().

◆ findProgramByName()

ErrorOr< std::string > llvm::sys::findProgramByName ( StringRef  Name,
ArrayRef< StringRef Paths = {} 
)

Find the first executable file Name in Paths.

This does not perform hashing as a shell would but instead stats each PATH entry individually so should generally be avoided. Core LLVM library functions and options should instead require fully specified paths.

Parameters
Namename of the executable to find. If it contains any system slashes, it will be returned as is.
Pathsoptional list of paths to search for Name. If empty it will use the system PATH environment instead.
Returns
The fully qualified path to the first Name in Paths if it exists. Name if Name has slashes in it. Otherwise an error.

Referenced by llvm::doSystemDiff(), llvm::DotCfgChangeReporter::genHTML(), llvm::IRChangedTester::handleIR(), and printSymbolizedStackTrace().

◆ getDefaultTargetTriple()

std::string llvm::sys::getDefaultTargetTriple ( )

getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produce code for.

The target triple is a string in the format of: CPU_TYPE-VENDOR-OPERATING_SYSTEM or CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM

Referenced by llvm::object::Archive::getDefaultKind(), llvm::object::MachOObjectFile::getHostArch(), LLVMGetDefaultTargetTriple(), and printDefaultTargetAndDetectedCPU().

◆ getHostCPUFeatures()

bool llvm::sys::getHostCPUFeatures ( StringMap< bool, MallocAllocator > &  Features)

getHostCPUFeatures - Get the LLVM names for the host CPU features.

The particular format of the names are target dependent, and suitable for passing as -mattr to the target which matches the host.

Parameters
Features- A string mapping feature names to either true (if enabled) or false (if disabled). This routine makes no guarantees about exactly which features may appear in this map, except that they are all valid LLVM feature names.
Returns
- True on success.

Referenced by llvm::orc::JITTargetMachineBuilder::detectHost(), llvm::codegen::getFeatureList(), llvm::codegen::getFeaturesStr(), and LLVMGetHostCPUFeatures().

◆ getHostCPUName()

StringRef llvm::sys::getHostCPUName ( )

getHostCPUName - Get the LLVM name for the host CPU.

The particular format of the name is target dependent, and suitable for passing as -mcpu to the target which matches the host.

Returns
- The host CPU name, or empty if the CPU could not be determined.

Definition at line 1689 of file Host.cpp.

Referenced by llvm::orc::JITTargetMachineBuilder::detectHost(), llvm::codegen::getCPUStr(), LLVMGetHostCPUName(), and printDefaultTargetAndDetectedCPU().

◆ getProcessTriple()

std::string llvm::sys::getProcessTriple ( )

◆ getSwappedBytes() [1/14]

char llvm::sys::getSwappedBytes ( char  C)
inline

Definition at line 33 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ getSwappedBytes() [2/14]

double llvm::sys::getSwappedBytes ( double  C)
inline

Definition at line 51 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ getSwappedBytes() [3/14]

float llvm::sys::getSwappedBytes ( float  C)
inline

Definition at line 47 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ getSwappedBytes() [4/14]

signed char llvm::sys::getSwappedBytes ( signed char  C)
inline

Definition at line 32 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ getSwappedBytes() [5/14]

signed int llvm::sys::getSwappedBytes ( signed int  C)
inline

Definition at line 39 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ getSwappedBytes() [6/14]

signed long llvm::sys::getSwappedBytes ( signed long  C)
inline

Definition at line 42 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ getSwappedBytes() [7/14]

signed long long llvm::sys::getSwappedBytes ( signed long long  C)
inline

Definition at line 45 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ getSwappedBytes() [8/14]

signed short llvm::sys::getSwappedBytes ( signed short  C)
inline

Definition at line 36 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ getSwappedBytes() [9/14]

template<typename T >
std::enable_if_t< std::is_enum_v< T >, T > llvm::sys::getSwappedBytes ( T  C)
inline

Definition at line 56 of file SwapByteOrder.h.

References llvm::byteswap(), llvm::CallingConv::C, and llvm::to_underlying().

◆ getSwappedBytes() [10/14]

unsigned char llvm::sys::getSwappedBytes ( unsigned char  C)
inline

Definition at line 31 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

Referenced by swapByteOrder().

◆ getSwappedBytes() [11/14]

unsigned int llvm::sys::getSwappedBytes ( unsigned int  C)
inline

Definition at line 38 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ getSwappedBytes() [12/14]

unsigned long llvm::sys::getSwappedBytes ( unsigned long  C)
inline

Definition at line 41 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ getSwappedBytes() [13/14]

unsigned long long llvm::sys::getSwappedBytes ( unsigned long long  C)
inline

Definition at line 44 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ getSwappedBytes() [14/14]

unsigned short llvm::sys::getSwappedBytes ( unsigned short  C)
inline

Definition at line 35 of file SwapByteOrder.h.

References llvm::byteswap(), and llvm::CallingConv::C.

◆ MemoryFence()

void llvm::sys::MemoryFence ( )

Definition at line 30 of file Atomic.cpp.

Referenced by llvm::call_once().

◆ operator<() [1/2]

bool llvm::sys::operator< ( uint32_t  Value,
UnicodeCharRange  Range 
)
inline

Definition at line 28 of file UnicodeCharRanges.h.

◆ operator<() [2/2]

bool llvm::sys::operator< ( UnicodeCharRange  Range,
uint32_t  Value 
)
inline

Definition at line 31 of file UnicodeCharRanges.h.

◆ operator<<() [1/2]

raw_ostream & llvm::sys::operator<< ( raw_ostream OS,
const Memory::ProtectionFlags PF 
)

◆ operator<<() [2/2]

raw_ostream & llvm::sys::operator<< ( raw_ostream OS,
const MemoryBlock MB 
)

Debugging output for MemoryBlock.

Definition at line 43 of file Memory.cpp.

References llvm::sys::MemoryBlock::allocatedSize(), llvm::sys::MemoryBlock::base(), and OS.

◆ printArg()

void llvm::sys::printArg ( llvm::raw_ostream OS,
StringRef  Arg,
bool  Quote 
)

Print a command argument, and optionally quote it.

Definition at line 84 of file Program.cpp.

References llvm::StringRef::find_first_of(), llvm::StringRef::npos, and OS.

Referenced by flattenCommandLine().

◆ printDefaultTargetAndDetectedCPU()

void llvm::sys::printDefaultTargetAndDetectedCPU ( raw_ostream OS)

This is a function compatible with cl::AddExtraVersionPrinter, which adds info about the current target triple and detected CPU.

Definition at line 2053 of file Host.cpp.

References getDefaultTargetTriple(), getHostCPUName(), and OS.

◆ PrintStackTrace()

void llvm::sys::PrintStackTrace ( raw_ostream OS,
int  Depth = 0 
)

Print the stack trace using the given raw_ostream object.

Parameters
Depthrefers to the number of stackframes to print. If not specified, the entire frame is printed.

◆ PrintStackTraceOnErrorSignal()

void llvm::sys::PrintStackTraceOnErrorSignal ( StringRef  Argv0,
bool  DisableCrashReporting = false 
)

When an error signal (such as SIGABRT or SIGSEGV) is delivered to the process, print a stack trace and then exit.

Print a stack trace if a fatal signal occurs.

Parameters
Argv0the current binary name, used to find the symbolizer relative to the current binary before searching $PATH; can be StringRef(), in which case we will only search $PATH.
DisableCrashReportingif true, disable the normal crash reporting mechanisms on the underlying operating system.

Referenced by llvm::InitLLVM::InitLLVM().

◆ RemoveFileOnSignal()

bool llvm::sys::RemoveFileOnSignal ( StringRef  Filename,
std::string *  ErrMsg = nullptr 
)

This function registers signal handlers to ensure that if a signal gets delivered that the named file is removed.

Remove a file if a fatal signal occurs.

Referenced by llvm::sys::fs::TempFile::create().

◆ RetryAfterSignal()

template<typename FailT , typename Fun , typename... Args>
decltype(auto) llvm::sys::RetryAfterSignal ( const FailT &  Fail,
const Fun &  F,
const Args &...  As 
)
inline

Definition at line 32 of file Errno.h.

References F, and Fail.

◆ RunInterruptHandlers()

void llvm::sys::RunInterruptHandlers ( )

This function runs all the registered interrupt handlers, including the removal of files registered by RemoveFileOnSignal.

Referenced by llvm::PrintFatalError(), llvm::PrintFatalNote(), and llvm::report_fatal_error().

◆ RunningOnValgrind()

bool llvm::sys::RunningOnValgrind ( )

Definition at line 32 of file Valgrind.cpp.

◆ RunSignalHandlers()

void llvm::sys::RunSignalHandlers ( )

◆ SetInfoSignalFunction()

void llvm::sys::SetInfoSignalFunction ( void(*)()  Handler)

Registers a function to be called when an "info" signal is delivered to the process.

On POSIX systems, this will be SIGUSR1; on systems that have it, SIGINFO will also be used (typically ctrl-t).

Note that signal handlers are not allowed to call any non-reentrant functions. An null function pointer disables the current installed function. Note also that the handler may be executed on a different thread on some platforms.

Referenced by llvm::EnablePrettyStackTraceOnSigInfoForThisThread().

◆ SetInterruptFunction()

void llvm::sys::SetInterruptFunction ( void(*)()  IF)

This function registers a function to be called when the user "interrupts" the program (typically by pressing ctrl-c).

When the user interrupts the program, the specified interrupt function is called instead of the program being killed, and the interrupt function automatically disabled.

Note that interrupt functions are not allowed to call any non-reentrant functions. An null interrupt function pointer disables the current installed function. Note also that the handler may be executed on a different thread on some platforms.

◆ SetOneShotPipeSignalFunction()

void llvm::sys::SetOneShotPipeSignalFunction ( void(*)()  Handler)

Registers a function to be called in a "one-shot" manner when a pipe signal is delivered to the process (i.e., on a failed write to a pipe).

After the pipe signal is handled once, the handler is unregistered.

The LLVM signal handling code will not install any handler for the pipe signal unless one is provided with this API (see DefaultOneShotPipeSignalHandler). This handler must be provided before any other LLVM signal handlers are installed: the InitLLVM constructor has a flag that can simplify this setup.

Note that the handler is not allowed to call any non-reentrant functions. A null handler pointer disables the current installed function. Note also that the handler may be executed on a different thread on some platforms.

Referenced by llvm::InitLLVM::InitLLVM().

◆ StrError() [1/2]

std::string llvm::sys::StrError ( )

Returns a string representation of the errno value, using whatever thread-safe variant of strerror() is available.

Be sure to call this immediately after the function that set errno, or errno may have been overwritten by an intervening call.

Referenced by MakeErrMsg().

◆ StrError() [2/2]

std::string llvm::sys::StrError ( int  errnum)

Like the no-argument version above, but uses errnum instead of errno.

Definition at line 35 of file Errno.cpp.

◆ swapByteOrder()

template<typename T >
void llvm::sys::swapByteOrder ( T Value)
inline

Definition at line 61 of file SwapByteOrder.h.

References getSwappedBytes().

Referenced by llvm::support::endian::byte_swap(), checkThreadCommand(), llvm::dwarf_linker::parallel::CompileUnit::cloneDieAttrExpression(), llvm::orc::shared::SPSSerializationTraits< SPSTagT, SPSTagT, std::enable_if_t< std::is_same< SPSTagT, bool >::value||std::is_same< SPSTagT, char >::value||std::is_same< SPSTagT, int8_t >::value||std::is_same< SPSTagT, int16_t >::value||std::is_same< SPSTagT, int32_t >::value||std::is_same< SPSTagT, int64_t >::value||std::is_same< SPSTagT, uint8_t >::value||std::is_same< SPSTagT, uint16_t >::value||std::is_same< SPSTagT, uint32_t >::value||std::is_same< SPSTagT, uint64_t >::value > >::deserialize(), llvm::dwarf_linker::parallel::SectionDescriptor::emitIntVal(), llvm::hashing::detail::fetch32(), llvm::hashing::detail::fetch64(), getArray(), llvm::object::MachOObjectFile::getChainedFixupsSegments(), llvm::object::MachOChainedFixupEntry::moveNext(), readInteger(), llvm::orc::shared::SPSSerializationTraits< SPSTagT, SPSTagT, std::enable_if_t< std::is_same< SPSTagT, bool >::value||std::is_same< SPSTagT, char >::value||std::is_same< SPSTagT, int8_t >::value||std::is_same< SPSTagT, int16_t >::value||std::is_same< SPSTagT, int32_t >::value||std::is_same< SPSTagT, int64_t >::value||std::is_same< SPSTagT, uint8_t >::value||std::is_same< SPSTagT, uint16_t >::value||std::is_same< SPSTagT, uint32_t >::value||std::is_same< SPSTagT, uint64_t >::value > >::serialize(), llvm::dxbc::ShaderHash::swapBytes(), llvm::dxbc::ContainerVersion::swapBytes(), llvm::dxbc::Header::swapBytes(), llvm::dxbc::PartHeader::swapBytes(), llvm::dxbc::BitcodeHeader::swapBytes(), llvm::dxbc::ProgramHeader::swapBytes(), llvm::dxbc::HullPSVInfo::swapBytes(), llvm::dxbc::DomainPSVInfo::swapBytes(), llvm::dxbc::GeometryPSVInfo::swapBytes(), llvm::dxbc::MeshPSVInfo::swapBytes(), llvm::dxbc::AmplificationPSVInfo::swapBytes(), llvm::dxbc::PSV::v0::RuntimeInfo::swapBytes(), llvm::dxbc::PSV::v0::ResourceBindInfo::swapBytes(), llvm::dxbc::PSV::v0::SignatureElement::swapBytes(), llvm::dxbc::PSV::v2::RuntimeInfo::swapBytes(), llvm::dxbc::PSV::v2::ResourceBindInfo::swapBytes(), llvm::dxbc::ProgramSignatureHeader::swapBytes(), llvm::dxbc::ProgramSignatureElement::swapBytes(), llvm::object::detail::swapBytes(), llvm::dxbc::PSV::v1::RuntimeInfo::swapBytes(), llvm::MachO::swapStruct(), and writeInteger().

◆ toDuration() [1/2]

std::chrono::microseconds llvm::sys::toDuration ( const struct timeval &  TV)
inline

Convert a struct timeval to a duration.

Note that timeval can be used both as a time point and a duration. Be sure to check what the input represents.

Definition at line 81 of file Unix.h.

◆ toDuration() [2/2]

std::chrono::nanoseconds llvm::sys::toDuration ( FILETIME  Time)
inline

Definition at line 204 of file WindowsSupport.h.

◆ toFILETIME()

FILETIME llvm::sys::toFILETIME ( TimePoint<>  TP)
inline

Definition at line 225 of file WindowsSupport.h.

◆ toTimePoint() [1/3]

TimePoint llvm::sys::toTimePoint ( FILETIME  Time)
inline

Definition at line 213 of file WindowsSupport.h.

◆ toTimePoint() [2/3]

TimePoint< std::chrono::seconds > llvm::sys::toTimePoint ( std::time_t  T)
inline

◆ toTimePoint() [3/3]

TimePoint llvm::sys::toTimePoint ( std::time_t  T,
uint32_t  nsec 
)
inline

Convert a std::time_t + nanoseconds to a TimePoint.

Definition at line 72 of file Chrono.h.

◆ toTimeSpec()

struct timespec llvm::sys::toTimeSpec ( TimePoint<>  TP)
inline

Convert a time point to struct timespec.

Definition at line 87 of file Unix.h.

References llvm::count(), and toTimeT().

◆ toTimeT() [1/2]

std::time_t llvm::sys::toTimeT ( TimePoint<>  TP)
inline

Convert a TimePoint to std::time_t.

Definition at line 50 of file Chrono.h.

Referenced by llvm::getStructTM(), llvm::getStructTMUtc(), printBigArchiveMemberHeader(), printRestOfMemberHeader(), toTimeSpec(), and toTimeVal().

◆ toTimeT() [2/2]

std::time_t llvm::sys::toTimeT ( UtcTime<>  TP)
inline

Convert a UtcTime to std::time_t.

Definition at line 57 of file Chrono.h.

◆ toTimeVal()

struct timeval llvm::sys::toTimeVal ( TimePoint< std::chrono::microseconds >  TP)
inline

Convert a time point to struct timeval.

Definition at line 97 of file Unix.h.

References llvm::count(), and toTimeT().

◆ toUtcTime()

UtcTime< std::chrono::seconds > llvm::sys::toUtcTime ( std::time_t  T)
inline

Convert a std::time_t to a UtcTime.

Definition at line 44 of file Chrono.h.

◆ unregisterHandlers()

void llvm::sys::unregisterHandlers ( )

◆ ValgrindDiscardTranslations()

void llvm::sys::ValgrindDiscardTranslations ( const void *  Addr,
size_t  Len 
)

Definition at line 36 of file Valgrind.cpp.

◆ Wait()

ProcessInfo llvm::sys::Wait ( const ProcessInfo PI,
std::optional< unsigned SecondsToWait,
std::string *  ErrMsg = nullptr,
std::optional< ProcessStatistics > *  ProcStat = nullptr,
bool  Polling = false 
)

This function waits for the process specified by PI to finish.

Returns
A
See also
ProcessInfo struct with Pid set to:
  • The process id of the child process if the child process has changed state.
  • 0 if the child process has not changed state.
Note
Users of this function should always check the ReturnCode member of the
See also
ProcessInfo returned from this function.
Parameters
PIThe child process that should be waited on.
SecondsToWaitIf std::nullopt, waits until child has terminated. If a value, this specifies the amount of time to wait for the child process. If the time expires, and Polling is false, the child is killed and this < function returns. If the time expires and Polling is true, the child is resumed.

If zero, this function will perform a non-blocking wait on the child process.

Parameters
ErrMsgIf non-zero, provides a pointer to a string instance in which error messages will be returned. If the string is non-empty upon return an error occurred while invoking the program.
ProcStatIf non-zero, provides
Pollinga pointer to a structure in which process execution statistics will be stored. If true, do not kill the process on timeout.

◆ writeFileWithEncoding()

std::error_code llvm::sys::writeFileWithEncoding ( StringRef  FileName,
StringRef  Contents,
WindowsEncodingMethod  Encoding = WEM_UTF8 
)

Saves the UTF8-encoded contents string into the file FileName using a specific encoding.

This write file function adds the possibility to choose which encoding to use when writing a text file. On Windows, this is important when writing files with internationalization support with an encoding that is different from the one used in LLVM (UTF-8). We use this when writing response files, since GCC tools on MinGW only understand legacy code pages, and VisualStudio tools only understand UTF-16. For UNIX, using different encodings is silently ignored, since all tools work well with UTF-8. This function assumes that you only use UTF-8 text data and will convert it to your desired encoding before writing to the file.

FIXME: We use EM_CurrentCodePage to write response files for GNU tools in a MinGW/MinGW-w64 environment, which has serious flaws but currently is our best shot to make gcc/ld understand international characters. This should be changed as soon as binutils fix this to support UTF16 on mingw.

Returns
non-zero error_code if failed

Variable Documentation

◆ EnvPathSeparator

const char llvm::sys::EnvPathSeparator = ':'

This is the OS-specific separator for PATH like environment variables:

Definition at line 32 of file Program.h.

Referenced by llvm::findVCToolChainViaEnvironment().

◆ IsBigEndianHost

constexpr bool llvm::sys::IsBigEndianHost
constexpr
Initial value:

Definition at line 26 of file SwapByteOrder.h.

Referenced by llvm::FoldingSetNodeID::AddString(), llvm::object::convertUTF16LEToUTF8String(), llvm::orc::shared::SPSSerializationTraits< SPSTagT, SPSTagT, std::enable_if_t< std::is_same< SPSTagT, bool >::value||std::is_same< SPSTagT, char >::value||std::is_same< SPSTagT, int8_t >::value||std::is_same< SPSTagT, int16_t >::value||std::is_same< SPSTagT, int32_t >::value||std::is_same< SPSTagT, int64_t >::value||std::is_same< SPSTagT, uint8_t >::value||std::is_same< SPSTagT, uint16_t >::value||std::is_same< SPSTagT, uint32_t >::value||std::is_same< SPSTagT, uint64_t >::value > >::deserialize(), llvm::hashing::detail::fetch32(), llvm::hashing::detail::fetch64(), llvm::mcdxbc::PSVRuntimeInfo::finalize(), llvm::object::ViewArray< T >::iterator::operator*(), llvm::object::DirectX::PSVRuntimeInfo::parse(), readInteger(), readStruct(), llvm::orc::shared::SPSSerializationTraits< SPSTagT, SPSTagT, std::enable_if_t< std::is_same< SPSTagT, bool >::value||std::is_same< SPSTagT, char >::value||std::is_same< SPSTagT, int8_t >::value||std::is_same< SPSTagT, int16_t >::value||std::is_same< SPSTagT, int32_t >::value||std::is_same< SPSTagT, int64_t >::value||std::is_same< SPSTagT, uint8_t >::value||std::is_same< SPSTagT, uint16_t >::value||std::is_same< SPSTagT, uint32_t >::value||std::is_same< SPSTagT, uint64_t >::value > >::serialize(), llvm::mcdxbc::Signature::write(), and llvm::mcdxbc::PSVRuntimeInfo::write().

◆ IsLittleEndianHost

const bool llvm::sys::IsLittleEndianHost = !IsBigEndianHost
static