LLVM
8.0.1
|
Represents either an error or a value T. More...
#include "llvm/Support/ErrorOr.h"
Public Types | |
using | storage_type = typename std::conditional< isRef, wrap, T >::type |
Public Member Functions | |
template<class E > | |
ErrorOr (E ErrorCode, typename std::enable_if< std::is_error_code_enum< E >::value||std::is_error_condition_enum< E >::value, void *>::type=nullptr) | |
ErrorOr (std::error_code EC) | |
template<class OtherT > | |
ErrorOr (OtherT &&Val, typename std::enable_if< std::is_convertible< OtherT, T >::value >::type *=nullptr) | |
ErrorOr (const ErrorOr &Other) | |
template<class OtherT > | |
ErrorOr (const ErrorOr< OtherT > &Other, typename std::enable_if< std::is_convertible< OtherT, T >::value >::type *=nullptr) | |
template<class OtherT > | |
ErrorOr (const ErrorOr< OtherT > &Other, typename std::enable_if< !std::is_convertible< OtherT, const T &>::value >::type *=nullptr) | |
ErrorOr (ErrorOr &&Other) | |
template<class OtherT > | |
ErrorOr (ErrorOr< OtherT > &&Other, typename std::enable_if< std::is_convertible< OtherT, T >::value >::type *=nullptr) | |
template<class OtherT > | |
ErrorOr (ErrorOr< OtherT > &&Other, typename std::enable_if<!std::is_convertible< OtherT, T >::value >::type *=nullptr) | |
ErrorOr & | operator= (const ErrorOr &Other) |
ErrorOr & | operator= (ErrorOr &&Other) |
~ErrorOr () | |
operator bool () const | |
Return false if there is an error. More... | |
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 = typename std::conditional<isRef, wrap, T>::type |
|
inline |
Definition at line 75 of file ErrorOr.h.
References llvm::make_error_code().
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 147 of file ErrorOr.h.
Referenced by llvm::ErrorOr< T >::operator*().
|
inline |
Definition at line 157 of file ErrorOr.h.
Referenced by branchDiv(), callsiteIsHot(), llvm::object::createBinary(), llvm::LTOModule::createFromFile(), llvm::LTOModule::createFromOpenFileSlice(), llvm::SpecialCaseList::createInternal(), llvm::object::ObjectFile::createObjectFile(), llvm::DiffFilesWithTolerance(), ExpandResponseFile(), llvm::symbolize::LLVMSymbolizer::flush(), llvm::LTOModule::isBitcodeFile(), LLVMCreateMemoryBufferWithContentsOfFile(), LLVMCreateMemoryBufferWithSTDIN(), LLVMGetBitcodeModuleInContext2(), LLVMParseBitcodeInContext2(), llvm::pdb::PDBContext::PDBContext(), and setupMemoryBuffer().
|
inline |
|
inline |
Definition at line 160 of file ErrorOr.h.
Referenced by branchDiv(), llvm::LTOCodeGenerator::compileOptimized(), llvm::object::createBinary(), llvm::LTOModule::createFromFile(), llvm::LTOModule::createFromOpenFileSlice(), llvm::SpecialCaseList::createInternal(), llvm::object::ObjectFile::createObjectFile(), llvm::DiffFilesWithTolerance(), llvm::vfs::RedirectingFileSystem::dir_begin(), llvm::object::Archive::Child::getBuffer(), llvm::NewArchiveMember::getFile(), llvm::sys::getHostCPUName(), llvm::getModuleSummaryIndexForFile(), getProcCpuinfoContent(), llvm::vfs::RedirectingFileSystem::getRealPath(), LLVMCreateMemoryBufferWithContentsOfFile(), LLVMCreateMemoryBufferWithSTDIN(), LLVMGetBitcodeModuleInContext2(), LLVMParseBitcodeInContext2(), llvm::pdb::loadDataForPDB(), llvm::lto::localCache(), openFile(), llvm::vfs::RedirectingFileSystem::openFileForRead(), llvm::ErrorOr< T >::operator*(), llvm::SymbolRewriter::RewriteMapParser::parse(), parseBitcodeFileImpl(), setupMemoryBuffer(), llvm::vfs::OverlayFileSystem::status(), llvm::vfs::RedirectingFileSystem::status(), and llvm::TableGenMain().
|
inlineexplicit |
|
inline |
|
inline |
Definition at line 174 of file ErrorOr.h.
References assert(), llvm::AlignedCharArray< Alignment, Size >::buffer, llvm::ErrorOr< T >::ErrorOr, llvm::ErrorOr< T >::ErrorStorage, llvm::ErrorOr< T >::getError(), Other, T1, llvm::ErrorOr< T >::TStorage, and llvm::ErrorOr< T >::~ErrorOr().
|
inline |
|
inline |
|
inline |
Definition at line 58 of file ErrorOr.h.
Referenced by llvm::ErrorOr< T >::operator*().
AlignedCharArrayUnion<std::error_code> llvm::ErrorOr< T >::ErrorStorage |
Definition at line 264 of file ErrorOr.h.
Referenced by llvm::ErrorOr< T >::operator*().
AlignedCharArrayUnion<storage_type> llvm::ErrorOr< T >::TStorage |
Definition at line 263 of file ErrorOr.h.
Referenced by llvm::ErrorOr< T >::operator*().