|
| Expected (Error &&Err) |
| Create an Expected<T> error value from the given Error.
|
|
| 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.
|
|
template<typename OtherT > |
| Expected (OtherT &&Val, std::enable_if_t< std::is_convertible_v< OtherT, T > > *=nullptr) |
| Create an Expected<T> success value from the given OtherT value, which must be convertible to T.
|
|
| Expected (Expected &&Other) |
| Move construct an Expected<T> value.
|
|
template<class OtherT > |
| Expected (Expected< OtherT > &&Other, std::enable_if_t< std::is_convertible_v< OtherT, T > > *=nullptr) |
| Move construct an Expected<T> value from an Expected<OtherT>, where OtherT must be convertible to T.
|
|
template<class OtherT > |
| Expected (Expected< OtherT > &&Other, std::enable_if_t<!std::is_convertible_v< OtherT, T > > *=nullptr) |
| Move construct an Expected<T> value from an Expected<OtherT>, where OtherT isn't convertible to T.
|
|
Expected & | operator= (Expected &&Other) |
| Move-assign from another Expected<T>.
|
|
| ~Expected () |
| Destroy an Expected<T>.
|
|
| operator bool () |
| Return false if there is an error.
|
|
reference | get () |
| Returns a reference to the stored T value.
|
|
const_reference | get () const |
| Returns a const reference to the stored T value.
|
|
template<class OtherT > |
Error | moveInto (OtherT &Value, std::enable_if_t< std::is_assignable_v< OtherT &, T && > > *=nullptr) && |
| Returns takeError() after moving the held T (if any) into V .
|
|
template<typename ErrT > |
bool | errorIsA () const |
| Check that this Expected<T> is an error of type ErrT.
|
|
Error | takeError () |
| Take ownership of the stored error.
|
|
pointer | operator-> () |
| Returns a pointer to the stored T value.
|
|
const_pointer | operator-> () const |
| Returns a const pointer to the stored T value.
|
|
reference | operator* () |
| Returns a reference to the stored T value.
|
|
const_reference | operator* () const |
| Returns a const reference to the stored T value.
|
|
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.
Example usage of 'Expected<T>' as a function return type:
"B must not be zero!");
}
}
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Tagged union holding either a T or a Error.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Checking the results of to a function returning 'Expected<T>':
if (
auto E = Result.takeError()) {
errs() <<
"Problem with division " <<
toString(std::move(
E)) <<
"\n";
return;
}
outs() <<
"The answer is " << *Result <<
"\n";
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
For unit-testing a function returning an 'Expected<T>', see the 'EXPECT_THAT_EXPECTED' macros in llvm/Testing/Support/Error.h
Definition at line 481 of file Error.h.
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 608 of file Error.h.
References Unchecked.
Referenced by accumulateLocs(), llvm::LLVMTargetMachine::addAsmPrinter(), llvm::objcopy::coff::addGnuDebugLink(), llvm::objcopy::NameMatcher::addMatcher(), llvm::pdb::PDBFileBuilder::addNamedStream(), llvm::BitstreamCursor::advance(), advanceToMetaBlock(), llvm::BitcodeAnalyzer::analyze(), llvm::object::ELFFile< ELFT >::android_relas(), appendFile(), llvm::object::Archive::Archive(), llvm::object::ArchiveMemberHeader::ArchiveMemberHeader(), llvm::lto::backend(), llvm::object::BindRebaseSegInfo::BindRebaseSegInfo(), llvm::objcopy::elf::ELFBuilder< ELFT >::build(), llvm::ifs::buildStub(), llvm::object::Archive::Child::Child(), codegen(), llvm::pdb::PDBFileBuilder::commit(), computeMemberData(), llvm::RuntimeDyldImpl::computeSectionStubBufSize(), llvm::object::computeSymbolSizes(), llvm::RuntimeDyldImpl::computeTotalAllocSize(), llvm::object::SectionRef::containsSymbol(), llvm::gsym::ObjectFileTransformer::convert(), llvm::object::Slice::create(), llvm::MinidumpYAML::Stream::create(), llvm::symbolize::SymbolizableObjectFile::create(), llvm::lto::InputFile::create(), llvm::object::IRObjectFile::create(), llvm::coverage::BinaryCoverageReader::create(), llvm::object::MinidumpFile::create(), llvm::InstrProfSymtab::create(), llvm::objcopy::NameOrPattern::create(), llvm::object::createBinary(), llvm::raw_socket_stream::createConnectedUnix(), llvm::pdb::NativeSession::createFromExe(), llvm::LTOModule::createInputFile(), llvm::mca::InstrBuilder::createInstruction(), llvm::logicalview::LVBinaryReader::createInstructions(), llvm::jitlink::createLinkGraphFromELFObject(), createMemberHeaderParseError(), llvm::objcopy::createNewArchiveMembers(), llvm::object::ObjectFile::createObjectFile(), createOnDiskBuffer(), llvm::object::SymbolicFile::createSymbolicFile(), llvm::ListeningSocket::createUnix(), llvm::remarks::createYAMLParserFromMeta(), llvm::object::ELFFile< ELFT >::crels(), decode(), llvm::gsym::MergedFunctionsInfo::decode(), decodeBBAddrMapImpl(), llvm::objcopy::deepWriteArchive(), llvm::FileCheckPatternContext::defineCmdlineVariables(), llvm::NewArchiveMember::detectKindFromObject(), doImportingForModuleForTest(), doList(), llvm::DWARFLocationTable::dumpLocationList(), llvm::DWARFDebugNames::Entry::dumpParentIdx(), dumpSectionToFile(), llvm::objcopy::wasm::dumpSectionToFile(), llvm::object::ELFFile< ELFT >::dynamicEntries(), llvm::orc::RTDyldObjectLinkingLayer::emit(), llvm::DWARFYAML::emitDebugNames(), llvm::RuntimeDyldImpl::emitSection(), llvm::gsym::MergedFunctionsInfo::encode(), llvm::BitstreamCursor::EnterSubBlock(), llvm::BinaryOperation::eval(), llvm::objcopy::executeObjcopyOnArchive(), llvm::objcopy::coff::executeObjcopyOnBinary(), llvm::objcopy::elf::executeObjcopyOnBinary(), llvm::objcopy::wasm::executeObjcopyOnBinary(), llvm::objcopy::xcoff::executeObjcopyOnBinary(), llvm::objcopy::elf::executeObjcopyOnIHex(), llvm::objcopy::macho::executeObjcopyOnMachOUniversalBinary(), llvm::objcopy::elf::executeObjcopyOnRawBinary(), llvm::expectedToErrorOrAndEmitErrors(), llvm::DWARFAbbreviationDeclarationSet::extract(), llvm::object::extractOffloadBinaries(), extractSections(), llvm::DebuginfodFetcher::fetch(), llvm::ifs::filterIFSSyms(), llvm::objcopy::elf::ASCIIHexWriter::finalize(), llvm::orc::DebugObject::finalizeAsync(), llvm::RuntimeDyldCOFFX86_64::finalizeLoad(), llvm::RuntimeDyldELF::finalizeLoad(), llvm::DebuginfodCollection::findBinaryPath(), llvm::object::IRObjectFile::findBitcodeInMemBuffer(), llvm::object::IRObjectFile::findBitcodeInObject(), llvm::DebuginfodCollection::findDebugBinaryPath(), llvm::pdb::TpiStream::findFullDeclForForwardRef(), llvm::pdb::NativeInlineSiteSymbol::findInlineeLinesByVA(), llvm::pdb::NativeFunctionSymbol::findInlineFramesByVA(), llvm::pdb::SymbolCache::findLineNumbersByVA(), llvm::MCJIT::findSymbol(), llvm::pdb::SymbolCache::findSymbolByTypeIndex(), llvm::lto::findThinLTOModule(), llvm::dwarf_linker::finiteLoop(), llvm::JITSymbolFlags::fromObjectSymbol(), llvm::ARMJITSymbolFlags::fromObjectSymbol(), llvm::DWARFDebugAranges::generate(), llvm::MCJIT::generateCodeForModule(), llvm::DWARFUnit::getAbbreviations(), llvm::object::AbstractArchiveMemberHeader::getAccessMode(), llvm::offloading::amdgpu::getAMDGPUMetaDataFromImage(), llvm::object::Archive::Child::getAsBinary(), llvm::DWARFFormValue::getAsCString(), llvm::object::COFFObjectFile::getAuxSymbol(), llvm::getBitcodeFileContents(), getBitcodeFileMachine(), llvm::getBitcodeLTOInfo(), llvm::getBitcodeProducerString(), llvm::getBitcodeTargetTriple(), llvm::object::Archive::Child::getBuffer(), llvm::getCachedOrDownloadArtifact(), llvm::orc::getCOFFObjectFileSymbolInfo(), llvm::object::ObjectFile::getCommonSymbolSize(), llvm::object::XCOFFObjectFile::getCommonSymbolSizeImpl(), llvm::object::SectionRef::getContents(), llvm::object::ResourceSectionRef::getContents(), getCUIdentifiers(), getDbiStreamPtr(), llvm::dwarf_linker::parallel::CompileUnit::getDirAndFilenameFromLineTable(), llvm::object::ELFFile< ELFT >::getDynSymtabSize(), llvm::object::getELFAddend(), llvm::orc::getELFObjectFileSymbolInfo(), getEnableSplitLTOUnitAndUnifiedFlag(), llvm::object::ELFFile< ELFT >::getEntry(), llvm::object::XCOFFObjectFile::getExceptionEntries(), llvm::object::getExtendedSymbolTableIndex(), llvm::MemoryBuffer::getFileAsStream(), getFileAux(), llvm::object::Archive::Child::getFullName(), llvm::gsym::GsymReader::getFunctionInfoDataForAddress(), llvm::orc::getGenericObjectFileSymbolInfo(), llvm::BinaryOperation::getImplicitFormat(), llvm::object::XCOFFObjectFile::getImportFileTable(), llvm::object::AbstractArchiveMemberHeader::getLastModified(), llvm::getLazyBitcodeModule(), llvm::getLazyIRModule(), llvm::DWARFContext::getLineTableForUnit(), llvm::object::ELFFile< ELFT >::getLinkAsStrtab(), llvm::orc::getMachOObjectFileSymbolInfo(), llvm::object::MinidumpFile::getMemory64List(), llvm::object::Archive::Child::getMemoryBufferRef(), llvm::pdb::getModuleDebugStream(), llvm::getModuleSummaryIndex(), llvm::object::Archive::Child::getName(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::Archive::Child::getNext(), llvm::object::ArchiveMemberHeader::getNextChildLoc(), llvm::object::BigArchiveMemberHeader::getNextChildLoc(), llvm::getOffset(), llvm::NewArchiveMember::getOldMember(), getOpenFileImpl(), getPdbPathFromExe(), llvm::object::ELFObjectFileBase::getPltEntries(), llvm::LTOModule::getProducerString(), llvm::object::BigArchiveMemberHeader::getRawName(), getReadWriteFile(), llvm::object::ELFObjectFile< ELFT >::getRelocatedSection(), llvm::remarks::getRemarksSectionContents(), llvm::StringSubstitution::getResult(), llvm::NumericSubstitution::getResult(), llvm::object::ELFFile< ELFT >::getSectionAndRelocations(), llvm::object::ELFFile< ELFT >::getSectionIndex(), llvm::objcopy::elf::SectionTableRef::getSectionOfType(), getSingleModule(), llvm::object::BigArchiveMemberHeader::getSize(), llvm::object::ELFFile< ELFT >::getStringTableForSymtab(), llvm::object::ELFObjectFile< ELFT >::getSymbolAddress(), llvm::object::WasmObjectFile::getSymbolAddress(), llvm::object::ELFObjectFile< ELFT >::getSymbolAlignment(), llvm::object::XCOFFObjectFile::getSymbolAlignment(), llvm::object::ELFObjectFile< ELFT >::getSymbolBinding(), llvm::object::ELFObjectFile< ELFT >::getSymbolELFType(), llvm::object::ELFObjectFile< ELFT >::getSymbolFlags(), llvm::object::XCOFFObjectFile::getSymbolFlags(), getSymbolInfo(), llvm::object::ELFObjectFile< ELFT >::getSymbolName(), llvm::object::ELFObjectFile< ELFT >::getSymbolOther(), llvm::object::ELFObjectFile< ELFT >::getSymbolSection(), llvm::object::COFFObjectFile::getSymbolSection(), llvm::object::XCOFFObjectFile::getSymbolSection(), llvm::object::XCOFFObjectFile::getSymbolSectionName(), llvm::object::XCOFFObjectFile::getSymbolSize(), llvm::object::ELFObjectFile< ELFT >::getSymbolType(), llvm::object::MachOObjectFile::getSymbolType(), llvm::object::XCOFFObjectFile::getSymbolType(), llvm::object::ELFObjectFile< ELFT >::getSymbolValueImpl(), getUUID(), llvm::BitcodeReaderValueList::getValueFwdRef(), llvm::object::ELFFile< ELFT >::getVersionDefinitions(), llvm::object::ELFFile< ELFT >::getVersionDependencies(), llvm::object::XCOFFSymbolRef::getXCOFFCsectAuxRef(), llvm::jitlink::COFFLinkGraphBuilder::graphifySections(), llvm::jitlink::COFFLinkGraphBuilder::graphifySymbols(), handleCompressedSection(), llvm::handleSection(), hasObjCCategoryInModule(), llvm::pdb::PDBFile::hasPDBInjectedSourceStream(), llvm::pdb::PDBFile::hasPDBStringTable(), llvm::FunctionImporter::importFunctions(), llvm::objcopy::elf::Section::initialize(), llvm::objcopy::elf::SectionIndexSection::initialize(), llvm::objcopy::elf::SymbolTableSection::initialize(), llvm::objcopy::elf::RelocSectionWithSymtabBase< SymTabType >::initialize(), initRelocations(), isArchiveSymbol(), llvm::isBitcodeContainingObjCCategory(), llvm::LTOModule::isBitcodeFile(), llvm::LTOModule::isBitcodeForTarget(), isBlock(), isCodeViewDebugSubsection(), llvm::object::COFFObjectFile::isDebugSection(), llvm::object::ELFObjectFile< ELFT >::isDebugSection(), llvm::object::MachOObjectFile::isDebugSection(), llvm::object::XCOFFSymbolRef::isFunction(), llvm::object::ObjectFile::isSectionBitcode(), llvm::object::ArchiveMemberHeader::isThin(), llvm::isThumbFunc(), isVariableIndexable(), jumpToValueSymbolTable(), llvm::libDriverMain(), llvm::remarks::RemarkLinker::link(), llvm::jitlink::JITLinkerBase::linkPhase2(), llvm::jitlink::JITLinkerBase::linkPhase3(), llvm::jitlink::JITLinkerBase::linkPhase4(), LLVMCreateBinary(), LLVMCreateObjectFile(), LLVMGetBitcodeModuleInContext(), LLVMMachOUniversalBinaryCopyObjectForArch(), LLVMMoveToContainingSection(), LLVMParseBitcodeInContext(), LLVMRemarkParserGetNext(), llvm::object::ResourceSectionRef::load(), llvm::pdb::loadDataForEXE(), llvm::xray::loadInstrumentationMap(), loadObj(), llvm::RuntimeDyldImpl::loadObjectImpl(), llvm::xray::loadProfile(), llvm::xray::loadTraceFile(), llvm::object::ELFFile< ELFT >::loadVersionMap(), llvm::localCache(), lookupSections(), llvm::BTFParser::ParseContext::makeExtractor(), llvm::logicalview::LVBinaryReader::mapVirtualAddress(), llvm::CodeGenDataReader::mergeFromObjectFile(), llvm::MSVCPExpected< T >::MSVCPExpected(), llvm::remarks::YAMLRemarkParser::next(), llvm::orc::DebugObjectManagerPlugin::notifyEmitted(), llvm::pdb::InputFile::open(), llvm::BTFParser::parse(), llvm::remarks::YAMLRemarkParser::parseArg(), llvm::parseBitcodeFile(), parseBitcodeFileImpl(), parseBlock(), llvm::remarks::BitstreamParserHelper::parseBlockInfoBlock(), llvm::remarks::YAMLRemarkParser::parseDebugLoc(), llvm::parseIR(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadata(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadataAttachment(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadataKinds(), llvm::Pattern::parseNumericSubstitutionBlock(), llvm::Pattern::parsePattern(), parseRecord(), llvm::remarks::YAMLRemarkParser::parseRemark(), parseV5DirFileTables(), llvm::ifs::populateSymbols(), llvm::Pattern::printSubstitutions(), llvm::RuntimeDyldCOFFAArch64::processRelocationRef(), llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), llvm::RuntimeDyldELF::processRelocationRef(), llvm::BitstreamCursor::ReadAbbrevRecord(), readBBAddrMapImpl(), readBlobInRecord(), llvm::BitstreamCursor::ReadBlockInfoBlock(), readCoverageMappingData(), readDynsymVersionsImpl(), llvm::ifs::readELFFile(), llvm::msgpack::Document::readFromBlob(), readIdentificationBlock(), llvm::object::readIRSymtab(), llvm::readModuleSummaryIndex(), readModuleTriple(), llvm::sys::fs::readNativeFileToEOF(), llvm::BitstreamCursor::readRecord(), readTriple(), llvm::InstrProfLookupTrait::readValueProfilingData(), llvm::objcopy::coff::Object::removeSymbols(), llvm::pdb::PDBFile::safelyCreateNamedStream(), searchForExe(), llvm::pdb::NativeSession::searchForPdb(), llvm::remarks::RemarkLinker::serialize(), setSectionFlagsAndType(), llvm::dwarf_linker::parallel::SectionDescriptor::setSizesForSectionCreatedByAsmPrinter(), llvm::setupLLVMOptimizationRemarks(), llvm::BitstreamCursor::SkipBlock(), llvm::BitstreamCursor::skipRecord(), llvm::streamFile(), llvm::lto::thinBackend(), updateSection(), upgrade(), llvm::DWARFLocationTable::visitAbsoluteLocationList(), llvm::write(), llvm::writeArchive(), llvm::writeArchiveToStream(), writeDIE(), writeDWARFLists(), llvm::ifs::writeELFBinaryToFile(), llvm::object::writeImportLibrary(), llvm::writeToOutput(), writeUniversalArchsToStream(), llvm::object::writeUniversalBinary(), and llvm::yaml::yaml2ObjectFile().