LLVM 19.0.0git
Classes | Namespaces | Functions
Error.h File Reference
#include "llvm-c/Error.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/abi-breaking.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <functional>
#include <memory>
#include <new>
#include <optional>
#include <string>
#include <system_error>
#include <type_traits>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

class  llvm::ErrorInfoBase
 Base class for error info classes. More...
 
class  llvm::Error
 Lightweight error class with error context and mandatory checking. More...
 
class  llvm::ErrorSuccess
 Subclass of Error for the sole purpose of identifying the success path in the type system. More...
 
class  llvm::ErrorInfo< ThisErrT, ParentErrT >
 Base class for user error types. More...
 
class  llvm::ErrorList
 Special ErrorInfo subclass representing a list of ErrorInfos. More...
 
class  llvm::Expected< T >
 Tagged union holding either a T or a Error. More...
 
class  llvm::ErrorHandlerTraits< HandlerT >
 Helper for testing applicability of, and applying, handlers for ErrorInfo types. More...
 
class  llvm::ErrorHandlerTraits< Error(&)(ErrT &)>
 
class  llvm::ErrorHandlerTraits< void(&)(ErrT &)>
 
class  llvm::ErrorHandlerTraits< Error(&)(std::unique_ptr< ErrT >)>
 Specialization for functions of the form 'Error (std::unique_ptr<ErrT>)'. More...
 
class  llvm::ErrorHandlerTraits< void(&)(std::unique_ptr< ErrT >)>
 Specialization for functions of the form 'void (std::unique_ptr<ErrT>)'. More...
 
class  llvm::ErrorHandlerTraits< RetT(C::*)(ErrT &)>
 
class  llvm::ErrorHandlerTraits< RetT(C::*)(ErrT &) const >
 
class  llvm::ErrorHandlerTraits< RetT(C::*)(const ErrT &)>
 
class  llvm::ErrorHandlerTraits< RetT(C::*)(const ErrT &) const >
 
class  llvm::ErrorHandlerTraits< RetT(C::*)(std::unique_ptr< ErrT >)>
 Specialization for member functions of the form 'RetT (std::unique_ptr<ErrT>)'. More...
 
class  llvm::ErrorHandlerTraits< RetT(C::*)(std::unique_ptr< ErrT >) const >
 Specialization for member functions of the form 'RetT (std::unique_ptr<ErrT>) const'. More...
 
class  llvm::ErrorAsOutParameter
 Helper for Errors used as out-parameters. More...
 
class  llvm::ExpectedAsOutParameter< T >
 Helper for Expected<T>s used as out-parameters. More...
 
class  llvm::ECError
 This class wraps a std::error_code in a Error. More...
 
class  llvm::StringError
 This class wraps a string in an Error. More...
 
class  llvm::FileError
 This class wraps a filename and another Error. More...
 
class  llvm::ExitOnError
 Helper for check-and-exit error handling. More...
 

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 

Functions

template<typename ErrT , typename... ArgTs>
Error llvm::make_error (ArgTs &&... Args)
 Make a Error instance representing failure using the given error info type.
 
Error llvm::joinErrors (Error E1, Error E2)
 Concatenate errors.
 
void llvm::report_fatal_error (Error Err, bool gen_crash_diag=true)
 Report a serious error, calling any installed error handler.
 
void llvm::cantFail (Error Err, const char *Msg=nullptr)
 Report a fatal error if Err is a failure value.
 
template<typename T >
T llvm::cantFail (Expected< T > ValOrErr, const char *Msg=nullptr)
 Report a fatal error if ValOrErr is a failure value, otherwise unwraps and returns the contained value.
 
template<typename T >
Tllvm::cantFail (Expected< T & > ValOrErr, const char *Msg=nullptr)
 Report a fatal error if ValOrErr is a failure value, otherwise unwraps and returns the contained reference.
 
Error llvm::handleErrorImpl (std::unique_ptr< ErrorInfoBase > Payload)
 
template<typename HandlerT , typename... HandlerTs>
Error llvm::handleErrorImpl (std::unique_ptr< ErrorInfoBase > Payload, HandlerT &&Handler, HandlerTs &&... Handlers)
 
template<typename... HandlerTs>
Error llvm::handleErrors (Error E, HandlerTs &&... Hs)
 Pass the ErrorInfo(s) contained in E to their respective handlers.
 
template<typename... HandlerTs>
void llvm::handleAllErrors (Error E, HandlerTs &&... Handlers)
 Behaves the same as handleErrors, except that by contract all errors must be handled by the given handlers (i.e.
 
void llvm::handleAllErrors (Error E)
 Check that E is a non-error, then drop it.
 
template<typename T , typename RecoveryFtor , typename... HandlerTs>
Expected< Tllvm::handleExpected (Expected< T > ValOrErr, RecoveryFtor &&RecoveryPath, HandlerTs &&... Handlers)
 Handle any errors (if present) in an Expected<T>, then try a recovery path.
 
void llvm::logAllUnhandledErrors (Error E, raw_ostream &OS, Twine ErrorBanner={})
 Log all errors (if any) in E to OS.
 
std::string llvm::toString (Error E)
 Write all error messages (if any) in E to a string.
 
void llvm::consumeError (Error Err)
 Consume a Error without doing anything.
 
template<typename T >
std::optional< Tllvm::expectedToOptional (Expected< T > &&E)
 Convert an Expected to an Optional without doing anything.
 
template<typename T >
std::optional< Tllvm::expectedToStdOptional (Expected< T > &&E)
 
bool llvm::errorToBool (Error Err)
 Helper for converting an Error to a bool.
 
std::error_code llvm::inconvertibleErrorCode ()
 The value returned by this function can be returned from convertToErrorCode for Error values where no sensible translation to std::error_code exists.
 
Error llvm::errorCodeToError (std::error_code EC)
 Helper for converting an std::error_code to a Error.
 
std::error_code llvm::errorToErrorCode (Error Err)
 Helper for converting an ECError to a std::error_code.
 
std::error_code llvm::errnoAsErrorCode ()
 Helper to get errno as an std::error_code.
 
template<typename T >
Expected< Tllvm::errorOrToExpected (ErrorOr< T > &&EO)
 Convert an ErrorOr<T> to an Expected<T>.
 
template<typename T >
ErrorOr< Tllvm::expectedToErrorOr (Expected< T > &&E)
 Convert an Expected<T> to an ErrorOr<T>.
 
template<typename... Ts>
Error llvm::createStringError (std::error_code EC, char const *Fmt, const Ts &... Vals)
 Create formatted StringError object.
 
Error llvm::createStringError (std::error_code EC, char const *Msg)
 
Error llvm::createStringError (std::error_code EC, const Twine &S)
 
template<typename... Ts>
Error llvm::createStringError (std::errc EC, char const *Fmt, const Ts &... Vals)
 
Error llvm::createFileError (const Twine &F, Error E)
 Concatenate a source file path and/or name with an Error.
 
Error llvm::createFileError (const Twine &F, size_t Line, Error E)
 Concatenate a source file path and/or name with line number and an Error.
 
Error llvm::createFileError (const Twine &F, std::error_code EC)
 Concatenate a source file path and/or name with a std::error_code to form an Error object.
 
Error llvm::createFileError (const Twine &F, size_t Line, std::error_code EC)
 Concatenate a source file path and/or name with line number and std::error_code to form an Error object.
 
Error llvm::createFileError (const Twine &F, ErrorSuccess)=delete
 
LLVMErrorRef llvm::wrap (Error Err)
 Conversion from Error to LLVMErrorRef for C error bindings.
 
Error llvm::unwrap (LLVMErrorRef ErrRef)
 Conversion from LLVMErrorRef to Error for C error bindings.