LLVM 20.0.0git
|
Represents either an error or a value T. More...
#include "llvm/Support/ErrorOr.h"
Public Types | |
using | storage_type = std::conditional_t< isRef, wrap, T > |
Public Member Functions | |
template<class E > | |
ErrorOr (E ErrorCode, std::enable_if_t< std::is_error_code_enum< E >::value||std::is_error_condition_enum< E >::value, void * >=nullptr) | |
ErrorOr (std::error_code EC) | |
template<class OtherT > | |
ErrorOr (OtherT &&Val, std::enable_if_t< std::is_convertible_v< OtherT, T > > *=nullptr) | |
ErrorOr (const ErrorOr &Other) | |
template<class OtherT > | |
ErrorOr (const ErrorOr< OtherT > &Other, std::enable_if_t< std::is_convertible_v< OtherT, T > > *=nullptr) | |
template<class OtherT > | |
ErrorOr (const ErrorOr< OtherT > &Other, std::enable_if_t<!std::is_convertible_v< OtherT, const T & > > *=nullptr) | |
ErrorOr (ErrorOr &&Other) | |
template<class OtherT > | |
ErrorOr (ErrorOr< OtherT > &&Other, std::enable_if_t< std::is_convertible_v< OtherT, T > > *=nullptr) | |
template<class OtherT > | |
ErrorOr (ErrorOr< OtherT > &&Other, std::enable_if_t<!std::is_convertible_v< OtherT, T > > *=nullptr) | |
ErrorOr & | operator= (const ErrorOr &Other) |
ErrorOr & | operator= (ErrorOr &&Other) |
~ErrorOr () | |
operator bool () const | |
Return false if there is an error. | |
reference | get () |
const_reference | get () const |
std::error_code | getError () const |
pointer | operator-> () |
const_pointer | operator-> () const |
reference | operator* () |
const_reference | operator* () const |
Friends | |
template<class OtherT > | |
class | ErrorOr |
Represents either an error or a value T.
ErrorOr<T> is a pointer-like class that represents the result of an operation. The result is either an error, or a value of type T. This is designed to emulate the usage of returning a pointer where nullptr indicates failure. However instead of just knowing that the operation failed, we also have an error_code and optional user data that describes why it failed.
It is used like the following.
Implicit conversion to bool returns true if there is a usable value. The unary * and -> operators provide pointer like access to the value. Accessing the value when there is an error has undefined behavior.
When T is a reference type the behavior is slightly different. The reference is held in a std::reference_wrapper<std::remove_reference<T>::type>, and there is special handling to make operator -> work as if T was not a reference.
T cannot be a rvalue reference.
using llvm::ErrorOr< T >::storage_type = std::conditional_t<isRef, wrap, T> |
|
inline |
Definition at line 74 of file ErrorOr.h.
References llvm::make_error_code().
|
inline |
|
inline |
Definition at line 93 of file ErrorOr.h.
References llvm::Other.
|
inline |
Definition at line 98 of file ErrorOr.h.
References llvm::Other.
|
inlineexplicit |
Definition at line 104 of file ErrorOr.h.
References llvm::Other.
|
inline |
Definition at line 110 of file ErrorOr.h.
References llvm::Other.
|
inline |
Definition at line 115 of file ErrorOr.h.
References llvm::Other.
|
inlineexplicit |
Definition at line 123 of file ErrorOr.h.
References llvm::Other.
|
inline |
|
inline |
Definition at line 149 of file ErrorOr.h.
Referenced by llvm::SampleProfileLoaderBaseImpl< FT >::computeBlockWeights(), llvm::object::createBinary(), llvm::LTOModule::createFromFile(), llvm::LTOModule::createFromOpenFileSlice(), llvm::SpecialCaseList::createInternal(), llvm::object::ObjectFile::createObjectFile(), llvm::DiffFilesWithTolerance(), doList(), llvm::cl::ExpansionContext::expandResponseFiles(), llvm::getLazyIRFileModule(), llvm::LTOModule::isBitcodeFile(), LLVMCreateMemoryBufferWithContentsOfFile(), LLVMCreateMemoryBufferWithSTDIN(), LLVMGetBitcodeModuleInContext2(), LLVMParseBitcodeInContext2(), llvm::logicalview::LVBinaryReader::mapVirtualAddress(), llvm::gsym::GsymReader::openFile(), llvm::parseAssemblyFile(), parseAssemblyFileWithIndex(), llvm::parseIRFile(), llvm::parseSummaryIndexAssemblyFile(), llvm::pdb::PDBContext::PDBContext(), llvm::SampleProfileLoaderBaseImpl< FT >::propagateWeights(), and llvm::CtxProfAnalysis::run().
|
inline |
Definition at line 150 of file ErrorOr.h.
References llvm::ErrorOr< T >::get().
Referenced by llvm::ErrorOr< T >::get().
|
inline |
Definition at line 152 of file ErrorOr.h.
Referenced by llvm::LTOCodeGenerator::compileOptimized(), llvm::object::createBinary(), llvm::LTOModule::createFromFile(), llvm::LTOModule::createFromOpenFileSlice(), llvm::objcopy::coff::createGnuDebugLinkSectionContents(), llvm::SpecialCaseList::createInternal(), llvm::object::ObjectFile::createObjectFile(), llvm::remarks::createYAMLParserFromMeta(), llvm::DiffFilesWithTolerance(), llvm::vfs::RedirectingFileSystem::dir_begin(), doList(), llvm::cl::ExpansionContext::expandResponseFiles(), llvm::codegen::getBBSectionsMode(), llvm::object::Archive::Child::getBuffer(), llvm::NewArchiveMember::getFile(), llvm::getLazyIRFileModule(), llvm::getModuleSummaryIndexForFile(), llvm::libDriverMain(), LLVMCreateMemoryBufferWithContentsOfFile(), LLVMCreateMemoryBufferWithSTDIN(), LLVMGetBitcodeModuleInContext2(), LLVMParseBitcodeInContext2(), loadPdbFile(), llvm::localCache(), openFile(), llvm::gsym::GsymReader::openFile(), llvm::SymbolRewriter::RewriteMapParser::parse(), llvm::parseAssemblyFile(), parseAssemblyFileWithIndex(), llvm::parseIRFile(), llvm::parseSummaryIndexAssemblyFile(), llvm::CtxProfAnalysis::run(), llvm::vfs::RedirectingFileSystem::status(), llvm::streamFile(), llvm::TableGenMain(), and llvm::lto::thinBackend().
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 129 of file ErrorOr.h.
References llvm::Other.
Definition at line 134 of file ErrorOr.h.
References llvm::Other.
AlignedCharArrayUnion<std::error_code> llvm::ErrorOr< T >::ErrorStorage |
AlignedCharArrayUnion<storage_type> llvm::ErrorOr< T >::TStorage |