LLVM API Documentation
Represents either an error or a value T. More...
#include <ErrorOr.h>

Public Types | |
| typedef std::conditional < isRef, wrap, T >::type | storage_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=0) | |
| ErrorOr (std::error_code EC) | |
| ErrorOr (T Val) | |
| 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 () | |
| LLVM_EXPLICIT | operator bool () const |
| Return false if there is an error. | |
| reference | get () |
| const_reference | get () const |
| std::error_code | getError () const |
| pointer | operator-> () |
| reference | operator* () |
Friends | |
| 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.
ErrorOr<Buffer> getBuffer(); auto buffer = getBuffer(); if (error_code ec = buffer.getError()) return ec; buffer->write("adena");
An implicit conversion to bool provides a way to check if there was an error. 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 behaivor 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.
| typedef std::conditional<isRef, wrap, T>::type llvm::ErrorOr< T >::storage_type |
| llvm::ErrorOr< T >::ErrorOr | ( | E | ErrorCode, |
| typename std::enable_if< std::is_error_code_enum< E >::value||std::is_error_condition_enum< E >::value, void * >::type | = 0 |
||
| ) | [inline] |
Definition at line 97 of file ErrorOr.h.
References llvm::make_error_code().
| llvm::ErrorOr< T >::ErrorOr | ( | std::error_code | EC | ) | [inline] |
| llvm::ErrorOr< T >::ErrorOr | ( | T | Val | ) | [inline] |
| llvm::ErrorOr< T >::ErrorOr | ( | ErrorOr< T > && | Other | ) | [inline] |
| llvm::ErrorOr< T >::ErrorOr | ( | ErrorOr< OtherT > && | Other, |
| typename std::enable_if< std::is_convertible< OtherT, T >::value >::type * | = nullptr |
||
| ) | [inline] |
| llvm::ErrorOr< T >::ErrorOr | ( | ErrorOr< OtherT > && | Other, |
| typename std::enable_if<!std::is_convertible< OtherT, T >::value >::type * | = nullptr |
||
| ) | [inline, explicit] |
| llvm::ErrorOr< T >::~ErrorOr | ( | ) | [inline] |
| reference llvm::ErrorOr< T >::get | ( | ) | [inline] |
Definition at line 175 of file ErrorOr.h.
Referenced by llvm::object::Archive::Archive(), llvm::SpecialCaseList::create(), llvm::object::createBinary(), llvm::LTOModule::createFromFile(), llvm::LTOModule::createFromOpenFileSlice(), llvm::object::IRObjectFile::createIRObjectFile(), llvm::object::ObjectFile::createObjectFile(), llvm::DiffFilesWithTolerance(), ExpandResponseFile(), llvm::object::Archive::findSym(), llvm::object::MachOUniversalBinary::ObjectForArch::getAsArchive(), llvm::object::Archive::Child::getAsBinary(), llvm::getBitcodeTargetTriple(), llvm::getLazyIRFileModule(), getLazyIRModule(), llvm::object::Archive::Child::getMemoryBufferRef(), llvm::MCJIT::getSymbolAddress(), LLVMCreateMemoryBufferWithContentsOfFile(), LLVMCreateMemoryBufferWithSTDIN(), LLVMCreateObjectFile(), LLVMGetBitcodeModuleInContext(), LLVMParseBitcodeInContext(), sampleprof::SampleProfileReader::loadText(), llvm::parseAssemblyFile(), llvm::parseBitcodeFile(), llvm::parseIR(), llvm::parseIRFile(), and setupMemoryBuffer().
| const_reference llvm::ErrorOr< T >::get | ( | ) | const [inline] |
| std::error_code llvm::ErrorOr< T >::getError | ( | ) | const [inline] |
Definition at line 178 of file ErrorOr.h.
Referenced by llvm::object::Archive::Archive(), llvm::LTOCodeGenerator::compile(), llvm::SpecialCaseList::create(), llvm::object::createBinary(), llvm::LTOModule::createFromFile(), llvm::LTOModule::createFromOpenFileSlice(), llvm::object::IRObjectFile::createIRObjectFile(), llvm::object::ObjectFile::createObjectFile(), llvm::DiffFilesWithTolerance(), llvm::object::Archive::findSym(), llvm::object::MachOUniversalBinary::ObjectForArch::getAsArchive(), llvm::object::Archive::Child::getAsBinary(), llvm::object::COFFObjectFile::getAuxSymbol(), llvm::getLazyIRFileModule(), getLazyIRModule(), llvm::object::Archive::Child::getMemoryBufferRef(), llvm::object::ELFObjectFile< ELFT >::getRelocationValueString(), llvm::object::COFFObjectFile::getRelocationValueString(), llvm::object::ELFObjectFile< ELFT >::getSectionName(), llvm::MCJIT::getSymbolAddress(), llvm::object::ELFObjectFile< ELFT >::getSymbolName(), llvm::object::ELFObjectFile< ELFT >::getSymbolVersion(), LLVMCreateMemoryBufferWithContentsOfFile(), LLVMCreateMemoryBufferWithSTDIN(), LLVMGetBitcodeModuleInContext(), LLVMParseBitcodeInContext(), sampleprof::SampleProfileReader::loadText(), llvm::parseAssemblyFile(), llvm::parseIR(), llvm::parseIRFile(), setupMemoryBuffer(), and llvm::TableGenMain().
| LLVM_EXPLICIT llvm::ErrorOr< T >::operator bool | ( | ) | const [inline] |
| reference llvm::ErrorOr< T >::operator* | ( | ) | [inline] |
| pointer llvm::ErrorOr< T >::operator-> | ( | ) | [inline] |
| ErrorOr& llvm::ErrorOr< T >::operator= | ( | ErrorOr< T > && | Other | ) | [inline] |
| AlignedCharArrayUnion<std::error_code> llvm::ErrorOr< T >::ErrorStorage |
| AlignedCharArrayUnion<storage_type> llvm::ErrorOr< T >::TStorage |