LLVM  13.0.0git
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/ADT/APFloat.h"

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

Public Types

using storage_type = std::conditional_t< isRef, wrap, T >
 
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, std::enable_if_t< std::is_convertible< OtherT, T >::value > *=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, std::enable_if_t< std::is_convertible< OtherT, T >::value > *=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, std::enable_if_t<!std::is_convertible< OtherT, T >::value > *=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 42 of file APFloat.h.

Member Typedef Documentation

◆ storage_type

template<class T >
using llvm::Expected< T >::storage_type = std::conditional_t<isRef, wrap, T>

Definition at line 450 of file Error.h.

◆ value_type

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

Definition at line 451 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 461 of file Error.h.

◆ 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,
std::enable_if_t< std::is_convertible< OtherT, T >::value > *  = nullptr 
)
inline

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

Definition at line 480 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 493 of file Error.h.

◆ Expected() [5/6]

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

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

Definition at line 498 of file Error.h.

◆ Expected() [6/6]

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

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

Definition at line 507 of file Error.h.

◆ ~Expected()

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

Destroy an Expected<T>.

Definition at line 520 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 549 of file Error.h.

◆ get() [1/2]

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

Returns a reference to the stored T value.

Definition at line 537 of file Error.h.

Referenced by llvm::BitstreamCursor::advance(), llvm::BitcodeAnalyzer::analyze(), llvm::gsym::ObjectFileTransformer::convert(), llvm::object::Slice::create(), llvm::object::createBinary(), llvm::pdb::NativeSession::createFromExe(), decode(), llvm::DWARFLocationTable::dumpLocationList(), llvm::BitstreamCursor::EnterSubBlock(), llvm::object::IRObjectFile::findBitcodeInMemBuffer(), llvm::pdb::NativeInlineSiteSymbol::findInlineeLinesByVA(), llvm::MCJIT::findSymbol(), llvm::MCJIT::generateCodeForModule(), llvm::object::Archive::Child::getAsBinary(), llvm::object::Archive::Child::getBuffer(), getDbiStreamPtr(), llvm::object::Archive::Child::getMemoryBufferRef(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::Archive::Child::getName(), llvm::object::Archive::Child::getNext(), llvm::NewArchiveMember::getOldMember(), llvm::object::XCOFFObjectFile::getSymbolSection(), llvm::object::XCOFFObjectFile::getSymbolSectionName(), jumpToValueSymbolTable(), LLVMCreateBinary(), LLVMCreateObjectFile(), LLVMMachOUniversalBinaryCopyObjectForArch(), llvm::pdb::loadDataForEXE(), parseInlineInfo(), llvm::BitstreamCursor::ReadAbbrevRecord(), readCoverageMappingData(), llvm::elfabi::readELFFile(), llvm::BitstreamCursor::readRecord(), llvm::SimpleBitstreamCursor::ReadVBR(), llvm::SimpleBitstreamCursor::ReadVBR64(), llvm::pdb::NativeSession::searchForPdb(), llvm::BitstreamCursor::SkipBlock(), llvm::BitstreamCursor::skipRecord(), splitCodeGen(), and upgrade().

◆ 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 543 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 529 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 577 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 583 of file Error.h.

◆ operator->() [1/2]

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

Returns a pointer to the stored T value.

Definition at line 565 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 571 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 514 of file Error.h.

Referenced by llvm::MSVCPExpected< T >::operator=().

◆ 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> value.

Definition at line 557 of file Error.h.

Referenced by llvm::pdb::PDBFileBuilder::addNamedStream(), llvm::BitstreamCursor::advance(), advanceToMetaBlock(), llvm::BitcodeAnalyzer::analyze(), llvm::object::ELFFile< object::ELF64LE >::android_relas(), llvm::lto::backend(), llvm::object::BindRebaseSegInfo::BindRebaseSegInfo(), llvm::elfabi::buildStub(), llvm::pdb::PDBFileBuilder::commit(), llvm::msf::MSFBuilder::commit(), llvm::RuntimeDyldImpl::computeSectionStubBufSize(), llvm::object::computeSymbolSizes(), llvm::RuntimeDyldImpl::computeTotalAllocSize(), llvm::orc::shared::detail::ResultTraits< RetT >::consumeAbandoned(), llvm::object::SectionRef::containsSymbol(), llvm::gsym::ObjectFileTransformer::convert(), llvm::object::MinidumpFile::create(), llvm::GlobPattern::create(), llvm::symbolize::SymbolizableObjectFile::create(), llvm::MinidumpYAML::Stream::create(), llvm::object::Slice::create(), llvm::object::IRObjectFile::create(), llvm::lto::InputFile::create(), llvm::object::createBinary(), llvm::remarks::createBitstreamParserFromMeta(), llvm::pdb::NativeSession::createFromExe(), llvm::LTOModule::createInputFile(), llvm::mca::InstrBuilder::createInstruction(), llvm::jitlink::createLinkGraphFromELFObject(), createOnDiskBuffer(), llvm::remarks::createYAMLParserFromMeta(), decode(), llvm::object::ELFFile< object::ELF64LE >::decodeBBAddrMap(), doImportingForModule(), llvm::DWARFLocationTable::dumpLocationList(), llvm::object::ELFFile< object::ELF64LE >::dynamicEntries(), llvm::orc::RTDyldObjectLinkingLayer::emit(), llvm::RuntimeDyldImpl::emitSection(), llvm::BitstreamCursor::EnterSubBlock(), llvm::expectedToErrorOrAndEmitErrors(), llvm::RuntimeDyldELF::finalizeLoad(), llvm::RuntimeDyldCOFFX86_64::finalizeLoad(), llvm::pdb::GSIStreamBuilder::finalizeMsfLayout(), llvm::object::IRObjectFile::findBitcodeInMemBuffer(), llvm::object::IRObjectFile::findBitcodeInObject(), llvm::pdb::TpiStream::findFullDeclForForwardRef(), llvm::pdb::NativeInlineSiteSymbol::findInlineeLinesByVA(), llvm::pdb::NativeFunctionSymbol::findInlineFramesByVA(), llvm::pdb::SymbolCache::findLineNumbersByVA(), llvm::MCJIT::findSymbol(), llvm::lto::findThinLTOModule(), llvm::JITSymbolFlags::fromObjectSymbol(), llvm::ARMJITSymbolFlags::fromObjectSymbol(), llvm::DWARFDebugAranges::generate(), llvm::MCJIT::generateCodeForModule(), llvm::object::Archive::Child::getAsBinary(), llvm::getBitcodeFileContents(), getBitcodeFileMachine(), llvm::getBitcodeLTOInfo(), llvm::getBitcodeProducerString(), llvm::getBitcodeTargetTriple(), llvm::object::Archive::Child::getBuffer(), llvm::object::ObjectFile::getCommonSymbolSize(), llvm::object::SectionRef::getContents(), getDbiStreamPtr(), llvm::object::ELFFile< object::ELF64LE >::getDynSymtabSize(), llvm::object::getELFAddend(), llvm::object::getExtendedSymbolTableIndex(), llvm::MemoryBuffer::getFileAsStream(), getFileAux(), llvm::object::Archive::Child::getFullName(), llvm::gsym::GsymReader::getFunctionInfo(), llvm::getLazyBitcodeModule(), llvm::DWARFContext::getLineTableForUnit(), llvm::object::ELFFile< object::ELF64LE >::getLinkAsStrtab(), llvm::ExpressionFormat::getMatchingString(), getMemoryBufferForStream(), llvm::object::Archive::Child::getMemoryBufferRef(), llvm::getModuleSummaryIndex(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::Archive::Child::getName(), llvm::object::Archive::Child::getNext(), llvm::orc::getObjectSymbolInfo(), llvm::getOffset(), llvm::NewArchiveMember::getOldMember(), getOpenFileImpl(), getPdbPathFromExe(), llvm::LTOModule::getProducerString(), getReadWriteFile(), llvm::object::ELFObjectFile< ELFT >::getRelocatedSection(), llvm::remarks::getRemarksSectionContents(), llvm::StringSubstitution::getResult(), llvm::NumericSubstitution::getResult(), llvm::object::ELFFile< object::ELF64LE >::getSectionIndex(), getSingleModule(), llvm::object::ELFFile< object::ELF64LE >::getStringTableForSymtab(), llvm::object::ELFObjectFile< ELFT >::getSymbolAddress(), llvm::object::ELFObjectFile< ELFT >::getSymbolAlignment(), llvm::object::ELFObjectFile< ELFT >::getSymbolBinding(), llvm::object::ELFObjectFile< ELFT >::getSymbolELFType(), llvm::object::ELFObjectFile< ELFT >::getSymbolFlags(), getSymbolInfo(), llvm::object::ELFObjectFile< ELFT >::getSymbolName(), llvm::object::ELFObjectFile< ELFT >::getSymbolOther(), llvm::object::ELFObjectFile< ELFT >::getSymbolSection(), llvm::object::XCOFFObjectFile::getSymbolSection(), llvm::object::COFFObjectFile::getSymbolSection(), llvm::object::XCOFFObjectFile::getSymbolSectionName(), llvm::object::ELFObjectFile< ELFT >::getSymbolType(), llvm::object::ELFObjectFile< ELFT >::getSymbolValueImpl(), getUUID(), llvm::object::ELFFile< object::ELF64LE >::getVersionDefinitions(), llvm::object::ELFFile< object::ELF64LE >::getVersionDependencies(), llvm::pdb::PDBFile::hasPDBInjectedSourceStream(), llvm::pdb::PDBFile::hasPDBStringTable(), llvm::FunctionImporter::importFunctions(), isArchiveSymbol(), llvm::isBitcodeContainingObjCCategory(), llvm::LTOModule::isBitcodeFile(), llvm::LTOModule::isBitcodeForTarget(), isBlock(), llvm::object::Decompressor::isCompressed(), llvm::object::ObjectFile::isSectionBitcode(), llvm::isThumbFunc(), isVariableIndexable(), jumpToValueSymbolTable(), llvm::remarks::RemarkLinker::link(), llvm::jitlink::JITLinkerBase::linkPhase2(), LLVMCreateBinary(), LLVMCreateObjectFile(), LLVMMachOUniversalBinaryCopyObjectForArch(), LLVMMoveToContainingSection(), LLVMRemarkParserGetNext(), llvm::object::ResourceSectionRef::load(), llvm::pdb::loadDataForEXE(), llvm::xray::loadInstrumentationMap(), loadObj(), llvm::xray::loadProfile(), llvm::xray::loadTraceFile(), llvm::object::ELFFile< object::ELF64LE >::loadVersionMap(), llvm::lto::localCache(), llvm::gsym::GsymReader::lookup(), lookupSections(), llvm::MSVCPExpected< T >::MSVCPExpected(), llvm::remarks::YAMLRemarkParser::next(), llvm::orc::DebugObjectManagerPlugin::notifyEmitted(), llvm::parseBitcodeFile(), parseBitcodeFileImpl(), parseBlock(), llvm::remarks::BitstreamParserHelper::parseBlockInfoBlock(), llvm::Pattern::parseNumericSubstitutionBlock(), parseRecord(), llvm::remarks::YAMLRemarkParser::parseRemark(), parseV5DirFileTables(), llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldCOFFAArch64::processRelocationRef(), llvm::RuntimeDyldELF::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), llvm::BitstreamCursor::ReadAbbrevRecord(), readCoverageMappingData(), llvm::elfabi::readELFFile(), llvm::object::readIRSymtab(), llvm::readModuleSummaryIndex(), llvm::BitstreamCursor::readRecord(), readTriple(), llvm::pdb::PDBFile::safelyCreateNamedStream(), llvm::pdb::NativeSession::searchForPdb(), llvm::orc::shared::detail::RespondHelper< true >::sendResult(), llvm::remarks::RemarkLinker::serialize(), llvm::setupLLVMOptimizationRemarks(), llvm::BitstreamCursor::SkipBlock(), llvm::BitstreamCursor::skipRecord(), llvm::lto::thinBackend(), upgrade(), llvm::DWARFLocationTable::visitAbsoluteLocationList(), llvm::writeArchive(), llvm::writeArchiveToStream(), llvm::elfabi::writeELFBinaryToFile(), llvm::writeToOutput(), llvm::object::writeUniversalBinary(), llvm::object::writeUniversalBinaryToStream(), and llvm::yaml::yaml2ObjectFile().

Friends And Related Function Documentation

◆ Expected

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

Definition at line 441 of file Error.h.

◆ ExpectedAsOutParameter

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

Definition at line 440 of file Error.h.

Member Data Documentation

◆ ErrorStorage

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

Definition at line 682 of file Error.h.

◆ TStorage

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

Definition at line 681 of file Error.h.


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