LLVM  6.0.0svn
Public Types | Public Member Functions | Friends | List of all members
llvm::Expected< T > Class Template Reference

Tagged union holding either a T or a Error. More...

#include "llvm/Support/CachePruning.h"

Collaboration diagram for llvm::Expected< T >:
Collaboration graph
[legend]

Public Types

using storage_type = typename std::conditional< isRef, wrap, T >::type
 
using value_type = T
 

Public Member Functions

 Expected (Error Err)
 Create an Expected<T> error value from the given Error. More...
 
 Expected (ErrorSuccess)=delete
 Forbid to convert from Error::success() implicitly, this avoids having Expected<T> foo() { return Error::success(); } which compiles otherwise but triggers the assertion above. More...
 
template<typename OtherT >
 Expected (OtherT &&Val, typename std::enable_if< std::is_convertible< OtherT, T >::value >::type *=nullptr)
 Create an Expected<T> success value from the given OtherT value, which must be convertible to T. More...
 
 Expected (Expected &&Other)
 Move construct an Expected<T> value. More...
 
template<class OtherT >
 Expected (Expected< OtherT > &&Other, typename std::enable_if< std::is_convertible< OtherT, T >::value >::type *=nullptr)
 Move construct an Expected<T> value from an Expected<OtherT>, where OtherT must be convertible to T. More...
 
template<class OtherT >
 Expected (Expected< OtherT > &&Other, typename std::enable_if<!std::is_convertible< OtherT, T >::value >::type *=nullptr)
 Move construct an Expected<T> value from an Expected<OtherT>, where OtherT isn't convertible to T. More...
 
Expectedoperator= (Expected &&Other)
 Move-assign from another Expected<T>. More...
 
 ~Expected ()
 Destroy an Expected<T>. More...
 
 operator bool ()
 Return false if there is an error. More...
 
reference get ()
 Returns a reference to the stored T value. More...
 
const_reference get () const
 Returns a const reference to the stored T value. More...
 
template<typename ErrT >
bool errorIsA () const
 Check that this Expected<T> is an error of type ErrT. More...
 
Error takeError ()
 Take ownership of the stored error. More...
 
pointer operator-> ()
 Returns a pointer to the stored T value. More...
 
const_pointer operator-> () const
 Returns a const pointer to the stored T value. More...
 
reference operator* ()
 Returns a reference to the stored T value. More...
 
const_reference operator* () const
 Returns a const reference to the stored T value. More...
 

Friends

template<class T1 >
class ExpectedAsOutParameter
 
template<class OtherT >
class Expected
 

Detailed Description

template<class T>
class llvm::Expected< T >

Tagged union holding either a T or a Error.

This class parallels ErrorOr, but replaces error_code with Error. Since Error cannot be copied, this class replaces getError() with takeError(). It also adds an bool errorIsA<ErrT>() method for testing the error class type.

Definition at line 23 of file CachePruning.h.

Member Typedef Documentation

◆ storage_type

template<class T>
using llvm::Expected< T >::storage_type = typename std::conditional<isRef, wrap, T>::type

Definition at line 427 of file Error.h.

◆ value_type

template<class T>
using llvm::Expected< T >::value_type = T

Definition at line 428 of file Error.h.

Constructor & Destructor Documentation

◆ Expected() [1/6]

template<class T>
llvm::Expected< T >::Expected ( Error  Err)
inline

Create an Expected<T> error value from the given Error.

Definition at line 438 of file Error.h.

References assert().

◆ Expected() [2/6]

template<class T>
llvm::Expected< T >::Expected ( ErrorSuccess  )
delete

Forbid to convert from Error::success() implicitly, this avoids having Expected<T> foo() { return Error::success(); } which compiles otherwise but triggers the assertion above.

◆ Expected() [3/6]

template<class T>
template<typename OtherT >
llvm::Expected< T >::Expected ( OtherT &&  Val,
typename std::enable_if< std::is_convertible< OtherT, T >::value >::type *  = nullptr 
)
inline

Create an Expected<T> success value from the given OtherT value, which must be convertible to T.

Definition at line 457 of file Error.h.

◆ Expected() [4/6]

template<class T>
llvm::Expected< T >::Expected ( Expected< T > &&  Other)
inline

Move construct an Expected<T> value.

Definition at line 470 of file Error.h.

References Other.

◆ Expected() [5/6]

template<class T>
template<class OtherT >
llvm::Expected< T >::Expected ( Expected< OtherT > &&  Other,
typename std::enable_if< std::is_convertible< OtherT, T >::value >::type *  = nullptr 
)
inline

Move construct an Expected<T> value from an Expected<OtherT>, where OtherT must be convertible to T.

Definition at line 475 of file Error.h.

References Other.

◆ Expected() [6/6]

template<class T>
template<class OtherT >
llvm::Expected< T >::Expected ( Expected< OtherT > &&  Other,
typename std::enable_if<!std::is_convertible< OtherT, T >::value >::type *  = nullptr 
)
inlineexplicit

Move construct an Expected<T> value from an Expected<OtherT>, where OtherT isn't convertible to T.

Definition at line 484 of file Error.h.

References Other.

◆ ~Expected()

template<class T>
llvm::Expected< T >::~Expected ( )
inline

Destroy an Expected<T>.

Definition at line 498 of file Error.h.

Member Function Documentation

◆ errorIsA()

template<class T>
template<typename ErrT >
bool llvm::Expected< T >::errorIsA ( ) const
inline

Check that this Expected<T> is an error of type ErrT.

Definition at line 527 of file Error.h.

◆ get() [1/2]

template<class T>
reference llvm::Expected< T >::get ( )
inline

◆ get() [2/2]

template<class T>
const_reference llvm::Expected< T >::get ( ) const
inline

Returns a const reference to the stored T value.

Definition at line 521 of file Error.h.

◆ operator bool()

template<class T>
llvm::Expected< T >::operator bool ( )
inlineexplicit

Return false if there is an error.

Definition at line 507 of file Error.h.

◆ operator*() [1/2]

template<class T>
reference llvm::Expected< T >::operator* ( )
inline

Returns a reference to the stored T value.

Definition at line 555 of file Error.h.

◆ operator*() [2/2]

template<class T>
const_reference llvm::Expected< T >::operator* ( ) const
inline

Returns a const reference to the stored T value.

Definition at line 561 of file Error.h.

References assert(), llvm::dbgs(), llvm::ReferenceStorage< T >::get(), llvm::ErrorInfoBase::log(), Other, and T1.

◆ operator->() [1/2]

template<class T>
pointer llvm::Expected< T >::operator-> ( )
inline

Returns a pointer to the stored T value.

Definition at line 543 of file Error.h.

◆ operator->() [2/2]

template<class T>
const_pointer llvm::Expected< T >::operator-> ( ) const
inline

Returns a const pointer to the stored T value.

Definition at line 549 of file Error.h.

◆ operator=()

template<class T>
Expected& llvm::Expected< T >::operator= ( Expected< T > &&  Other)
inline

Move-assign from another Expected<T>.

Definition at line 492 of file Error.h.

References Other.

◆ takeError()

template<class T>
Error llvm::Expected< T >::takeError ( )
inline

Take ownership of the stored error.

After calling this the Expected<T> is in an indeterminate state that can only be safely destructed. No further calls (beside the destructor) should be made on the Expected<T> vaule.

Definition at line 535 of file Error.h.

References llvm::lltok::Error, and llvm::Error::success().

Referenced by llvm::lto::LTO::add(), llvm::object::Archive::Archive(), llvm::object::ArchiveMemberHeader::ArchiveMemberHeader(), llvm::lto::backend(), llvm::object::Archive::Child::Child(), computeMemberData(), llvm::orc::rpc::detail::ResultTraits< RetT >::consumeAbandoned(), llvm::object::SectionRef::containsSymbol(), llvm::GlobPattern::create(), llvm::symbolize::SymbolizableObjectFile::create(), llvm::object::IRObjectFile::create(), llvm::lto::InputFile::create(), llvm::object::createBinary(), llvm::createPGOInstrumentationUseLegacyPass(), llvm::DWARFContext::defaultErrorHandler(), llvm::dlltoolDriverMain(), doImportingForModule(), llvm::coverage::CounterMappingContext::dump(), llvm::object::RelocVisitor::error(), llvm::coverage::CounterMappingContext::evaluate(), llvm::expectedToErrorOrAndEmitErrors(), llvm::pdb::GSIStreamBuilder::finalizeMsfLayout(), llvm::RuntimeDyldMachOX86_64::finalizeSection(), llvm::RuntimeDyldMachOI386::finalizeSection(), llvm::RuntimeDyldMachOAArch64::finalizeSection(), llvm::object::IRObjectFile::findBitcodeInMemBuffer(), llvm::MCJIT::findSymbol(), llvm::symbolize::LLVMSymbolizer::flush(), forceRenaming(), llvm::MCJIT::generateCodeForModule(), llvm::object::Archive::Child::getAsBinary(), llvm::object::COFFObjectFile::getAuxSymbol(), llvm::getBitcodeFileContents(), llvm::getBitcodeLTOInfo(), llvm::getBitcodeProducerString(), llvm::getBitcodeTargetTriple(), getBits(), llvm::object::Archive::Child::getBuffer(), llvm::object::Archive::Child::getFullName(), llvm::IndexedInstrProfReader::getFunctionCounts(), llvm::getLazyBitcodeModule(), getLazyIRModule(), llvm::object::Archive::Child::getMemoryBufferRef(), llvm::getModuleSummaryIndex(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::Archive::Child::getName(), llvm::object::Archive::Child::getNext(), llvm::getOffset(), llvm::NewArchiveMember::getOldMember(), llvm::object::Archive::Child::getRawSize(), getSingleModule(), llvm::object::Archive::Child::getSize(), getSymbolInfo(), getSymbols(), llvm::object::MachOObjectFile::getSymbolType(), llvm::handleExpected(), handleNonPrevailingComdat(), llvm::isBitcodeContainingObjCCategory(), isCoverageMappingDummy(), llvm::LTOModule::isThinLTO(), llvm::isThumbFunc(), jumpToValueSymbolTable(), LLVMCreateObjectFile(), LLVMGetBitcodeModuleInContext(), LLVMGetSymbolAddress(), LLVMGetSymbolName(), LLVMMoveToContainingSection(), LLVMParseBitcodeInContext(), llvm::orc::SimpleCompiler::operator()(), llvm::parseBitcodeFile(), parseBitcodeFileImpl(), llvm::parseIR(), llvm::object::ObjectFile::printSymbolName(), llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), llvm::RuntimeDyldELF::processRelocationRef(), llvm::RawInstrProfReader< IntPtrT >::readHeader(), llvm::object::readIRSymtab(), llvm::readModuleSummaryIndex(), llvm::InstrProfLookupTrait::readValueProfilingData(), readWideAPInt(), llvm::orc::RemoteObjectLayer< RPCEndpoint >::remoteToJITSymbol(), scan(), llvm::orc::rpc::detail::RespondHelper< true >::sendResult(), llvm::orc::rpc::detail::RespondHelper< false >::sendResult(), llvm::orc::OrcMCJITReplacement::setProcessAllSections(), llvm::object::SymbolicFile::SymbolicFile(), llvm::detail::TakeExpected(), llvm::lto::thinBackend(), upgrade(), llvm::writeArchive(), and llvm::lto::ThinBackendProc::~ThinBackendProc().

Friends And Related Function Documentation

◆ Expected

template<class T>
template<class OtherT >
friend class Expected
friend

Definition at line 418 of file Error.h.

◆ ExpectedAsOutParameter

template<class T>
template<class T1 >
friend class ExpectedAsOutParameter
friend

Definition at line 417 of file Error.h.

Member Data Documentation

◆ ErrorStorage

template<class T>
AlignedCharArrayUnion<error_type> llvm::Expected< T >::ErrorStorage

Definition at line 653 of file Error.h.

◆ TStorage

template<class T>
AlignedCharArrayUnion<storage_type> llvm::Expected< T >::TStorage

Definition at line 652 of file Error.h.


The documentation for this class was generated from the following files: