[llvm] 89fab98 - [DebugInfo] llvm::Optional => std::optional
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 4 16:09:32 PST 2022
Author: Fangrui Song
Date: 2022-12-05T00:09:22Z
New Revision: 89fab98e884f05076bbd420d95b5de3596f5452c
URL: https://github.com/llvm/llvm-project/commit/89fab98e884f05076bbd420d95b5de3596f5452c
DIFF: https://github.com/llvm/llvm-project/commit/89fab98e884f05076bbd420d95b5de3596f5452c.diff
LOG: [DebugInfo] llvm::Optional => std::optional
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Added:
Modified:
bolt/include/bolt/Core/DebugData.h
bolt/lib/Core/BinaryContext.cpp
bolt/lib/Core/DebugData.cpp
bolt/lib/Core/Exceptions.cpp
bolt/lib/Rewrite/DWARFRewriter.cpp
lld/COFF/DebugTypes.cpp
lld/ELF/DWARF.cpp
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
llvm/include/llvm/BinaryFormat/Dwarf.h
llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
llvm/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h
llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h
llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h
llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h
llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h
llvm/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h
llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h
llvm/include/llvm/DebugInfo/CodeView/TypeTableCollection.h
llvm/include/llvm/DebugInfo/DIContext.h
llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
llvm/include/llvm/DebugInfo/DWARF/DWARFLocationExpression.h
llvm/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h
llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
llvm/include/llvm/DebugInfo/GSYM/GsymReader.h
llvm/include/llvm/DebugInfo/GSYM/InlineInfo.h
llvm/include/llvm/DebugInfo/GSYM/LineTable.h
llvm/include/llvm/DebugInfo/PDB/DIA/DIADataStream.h
llvm/include/llvm/DebugInfo/PDB/IPDBDataStream.h
llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
llvm/include/llvm/DebugInfo/PDB/Native/HashTable.h
llvm/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h
llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h
llvm/include/llvm/DebugInfo/PDB/Native/LinePrinter.h
llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h
llvm/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h
llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h
llvm/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h
llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
llvm/include/llvm/DebugInfo/Symbolize/Markup.h
llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
llvm/lib/BinaryFormat/Dwarf.cpp
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DIE.cpp
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp
llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp
llvm/lib/DebugInfo/GSYM/GsymReader.cpp
llvm/lib/DebugInfo/GSYM/InlineInfo.cpp
llvm/lib/DebugInfo/LogicalView/Readers/LVELFReader.cpp
llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp
llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
llvm/lib/DebugInfo/PDB/Native/NativeEnumTypes.cpp
llvm/lib/DebugInfo/PDB/Native/NativeInlineSiteSymbol.cpp
llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
llvm/lib/DebugInfo/Symbolize/Markup.cpp
llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
llvm/lib/ProfileData/InstrProfCorrelator.cpp
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
llvm/tools/llvm-pdbutil/TypeReferenceTracker.cpp
llvm/tools/llvm-profgen/ProfiledBinary.cpp
llvm/tools/llvm-readobj/COFFDumper.cpp
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
llvm/unittests/BinaryFormat/DwarfTest.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp
Removed:
################################################################################
diff --git a/bolt/include/bolt/Core/DebugData.h b/bolt/include/bolt/Core/DebugData.h
index 5be678cc12e27..1ba31fe4d2231 100644
--- a/bolt/include/bolt/Core/DebugData.h
+++ b/bolt/include/bolt/Core/DebugData.h
@@ -424,7 +424,7 @@ class DebugStrOffsetsWriter {
/// Initializes Buffer and Stream.
void initialize(const DWARFSection &StrOffsetsSection,
- const Optional<StrOffsetsContributionDescriptor> Contr);
+ const std::optional<StrOffsetsContributionDescriptor> Contr);
/// Update Str offset in .debug_str in .debug_str_offsets.
void updateAddressMap(uint32_t Index, uint32_t Address);
diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index 8f2bc4ceecc41..208b106c68f26 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -1482,14 +1482,14 @@ unsigned BinaryContext::addDebugFilenameToUnit(const uint32_t DestCUID,
"FileIndex out of range for the compilation unit.");
StringRef Dir = "";
if (FileNames[FileIndex - 1].DirIdx != 0) {
- if (Optional<const char *> DirName = dwarf::toString(
+ if (std::optional<const char *> DirName = dwarf::toString(
LineTable->Prologue
.IncludeDirectories[FileNames[FileIndex - 1].DirIdx - 1])) {
Dir = *DirName;
}
}
StringRef FileName = "";
- if (Optional<const char *> FName =
+ if (std::optional<const char *> FName =
dwarf::toString(FileNames[FileIndex - 1].Name))
FileName = *FName;
assert(FileName != "");
@@ -1545,7 +1545,7 @@ DWARFContext *BinaryContext::getDWOContext() const {
void BinaryContext::preprocessDWODebugInfo() {
for (const std::unique_ptr<DWARFUnit> &CU : DwCtx->compile_units()) {
DWARFUnit *const DwarfUnit = CU.get();
- if (llvm::Optional<uint64_t> DWOId = DwarfUnit->getDWOId()) {
+ if (std::optional<uint64_t> DWOId = DwarfUnit->getDWOId()) {
DWARFUnit *DWOCU = DwarfUnit->getNonSkeletonUnitDIE(false).getDwarfUnit();
if (!DWOCU->isDWOUnit()) {
std::string DWOName = dwarf::toString(
@@ -1648,9 +1648,9 @@ void BinaryContext::preprocessDebugInfo() {
std::optional<MD5::MD5Result> Checksum;
if (LineTable->Prologue.ContentTypes.HasMD5)
Checksum = LineTable->Prologue.FileNames[0].Checksum;
- Optional<const char *> Name =
+ std::optional<const char *> Name =
dwarf::toString(CU->getUnitDIE().find(dwarf::DW_AT_name), nullptr);
- if (Optional<uint64_t> DWOID = CU->getDWOId()) {
+ if (std::optional<uint64_t> DWOID = CU->getDWOId()) {
auto Iter = DWOCUs.find(*DWOID);
assert(Iter != DWOCUs.end() && "DWO CU was not found.");
Name = dwarf::toString(
@@ -1675,12 +1675,13 @@ void BinaryContext::preprocessDebugInfo() {
// means empty dir.
StringRef Dir = "";
if (FileNames[I].DirIdx != 0 || DwarfVersion >= 5)
- if (Optional<const char *> DirName = dwarf::toString(
+ if (std::optional<const char *> DirName = dwarf::toString(
LineTable->Prologue
.IncludeDirectories[FileNames[I].DirIdx - Offset]))
Dir = *DirName;
StringRef FileName = "";
- if (Optional<const char *> FName = dwarf::toString(FileNames[I].Name))
+ if (std::optional<const char *> FName =
+ dwarf::toString(FileNames[I].Name))
FileName = *FName;
assert(FileName != "");
std::optional<MD5::MD5Result> Checksum;
@@ -1811,7 +1812,7 @@ static void printDebugInfo(raw_ostream &OS, const MCInst &Instruction,
const DWARFDebugLine::Row &Row = LineTable->Rows[RowRef.RowIndex - 1];
StringRef FileName = "";
- if (Optional<const char *> FName =
+ if (std::optional<const char *> FName =
dwarf::toString(LineTable->Prologue.FileNames[Row.File - 1].Name))
FileName = *FName;
OS << " # debug line " << FileName << ":" << Row.Line;
diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp
index 6d39353dcf72d..d0e8988405f66 100644
--- a/bolt/lib/Core/DebugData.cpp
+++ b/bolt/lib/Core/DebugData.cpp
@@ -49,7 +49,7 @@ findAttributeInfo(const DWARFDie DIE,
const DWARFUnit &U = *DIE.getDwarfUnit();
uint64_t Offset =
AbbrevDecl->getAttributeOffsetFromIndex(Index, DIE.getOffset(), U);
- Optional<DWARFFormValue> Value =
+ std::optional<DWARFFormValue> Value =
AbbrevDecl->getAttributeValueFromOffset(Index, Offset, U);
if (!Value)
return std::nullopt;
@@ -57,7 +57,7 @@ findAttributeInfo(const DWARFDie DIE,
const DWARFAbbreviationDeclaration::AttributeSpec *AttrVal =
AbbrevDecl->attributes().begin() + Index;
uint32_t ValSize = 0;
- Optional<int64_t> ValSizeOpt = AttrVal->getByteSize(U);
+ std::optional<int64_t> ValSizeOpt = AttrVal->getByteSize(U);
if (ValSizeOpt) {
ValSize = static_cast<uint32_t>(*ValSizeOpt);
} else {
@@ -81,7 +81,7 @@ Optional<AttrInfo> findAttributeInfo(const DWARFDie DIE,
DIE.getAbbreviationDeclarationPtr();
if (!AbbrevDecl)
return std::nullopt;
- Optional<uint32_t> Index = AbbrevDecl->findAttributeIndex(Attr);
+ std::optional<uint32_t> Index = AbbrevDecl->findAttributeIndex(Attr);
if (!Index)
return std::nullopt;
return findAttributeInfo(DIE, AbbrevDecl, *Index);
@@ -421,7 +421,7 @@ AddressSectionBuffer DebugAddrWriterDwarf5::finalize() {
// for it.
if (AMIter == AddressMaps.end()) {
AMIter = AddressMaps.insert({CUID, AddressForDWOCU()}).first;
- Optional<uint64_t> BaseOffset = CU->getAddrOffsetSectionBase();
+ std::optional<uint64_t> BaseOffset = CU->getAddrOffsetSectionBase();
if (!BaseOffset)
continue;
// Address base offset is to the first entry.
@@ -1067,7 +1067,7 @@ std::string DebugInfoBinaryPatcher::patchBinary(StringRef BinaryContents) {
void DebugStrOffsetsWriter::initialize(
const DWARFSection &StrOffsetsSection,
- const Optional<StrOffsetsContributionDescriptor> Contr) {
+ const std::optional<StrOffsetsContributionDescriptor> Contr) {
if (!Contr)
return;
diff --git a/bolt/lib/Core/Exceptions.cpp b/bolt/lib/Core/Exceptions.cpp
index 6ec6d05c7a6cc..b1976ed7669b3 100644
--- a/bolt/lib/Core/Exceptions.cpp
+++ b/bolt/lib/Core/Exceptions.cpp
@@ -115,7 +115,7 @@ void BinaryFunction::parseLSDA(ArrayRef<uint8_t> LSDASectionData,
uint8_t LPStartEncoding = Data.getU8(&Offset);
uint64_t LPStart = 0;
// Convert to offset if LPStartEncoding is typed absptr DW_EH_PE_absptr
- if (Optional<uint64_t> MaybeLPStart = Data.getEncodedPointer(
+ if (std::optional<uint64_t> MaybeLPStart = Data.getEncodedPointer(
&Offset, LPStartEncoding, Offset + LSDASectionAddress))
LPStart = (LPStartEncoding && 0xFF == 0) ? *MaybeLPStart
: *MaybeLPStart - Address;
@@ -496,7 +496,7 @@ bool CFIReaderWriter::fillCFIInfoFor(BinaryFunction &Function) const {
return true;
const FDE &CurFDE = *I->second;
- Optional<uint64_t> LSDA = CurFDE.getLSDAAddress();
+ std::optional<uint64_t> LSDA = CurFDE.getLSDAAddress();
Function.setLSDAAddress(LSDA ? *LSDA : 0);
uint64_t Offset = Function.getFirstInstructionOffset();
@@ -785,7 +785,7 @@ Error EHFrameParser::parseCIE(uint64_t StartOffset) {
break;
case 'P': {
uint32_t PersonalityEncoding = Data.getU8(&Offset);
- Optional<uint64_t> Personality =
+ std::optional<uint64_t> Personality =
Data.getEncodedPointer(&Offset, PersonalityEncoding,
EHFrameAddress ? EHFrameAddress + Offset : 0);
// Patch personality address
@@ -817,7 +817,7 @@ Error EHFrameParser::parseCIE(uint64_t StartOffset) {
Error EHFrameParser::parseFDE(uint64_t CIEPointer,
uint64_t StartStructureOffset) {
- Optional<uint64_t> LSDAAddress;
+ std::optional<uint64_t> LSDAAddress;
CIEInfo *Cie = CIEs[StartStructureOffset - CIEPointer];
// The address size is encoded in the CIE we reference.
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index abcb373f4b65f..72eac7b2f7775 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -121,7 +121,7 @@ static std::string
getDWOName(llvm::DWARFUnit &CU,
std::unordered_map<std::string, uint32_t> *NameToIndexMap,
std::unordered_map<uint64_t, std::string> &DWOIdToName) {
- llvm::Optional<uint64_t> DWOId = CU.getDWOId();
+ std::optional<uint64_t> DWOId = CU.getDWOId();
assert(DWOId && "DWO ID not found.");
(void)DWOId;
auto NameIter = DWOIdToName.find(*DWOId);
@@ -198,7 +198,7 @@ void DWARFRewriter::updateDebugInfo() {
LocListWritersByCU[CUIndex] =
std::make_unique<DebugLoclistWriter>(*CU.get(), DwarfVersion, false);
- if (Optional<uint64_t> DWOId = CU->getDWOId()) {
+ if (std::optional<uint64_t> DWOId = CU->getDWOId()) {
assert(LocListWritersByCU.count(*DWOId) == 0 &&
"RangeLists writer for DWO unit already exists.");
auto RangeListsSectionWriter =
@@ -211,7 +211,7 @@ void DWARFRewriter::updateDebugInfo() {
LocListWritersByCU[CUIndex] = std::make_unique<DebugLocWriter>();
}
- if (Optional<uint64_t> DWOId = CU->getDWOId()) {
+ if (std::optional<uint64_t> DWOId = CU->getDWOId()) {
assert(LocListWritersByCU.count(*DWOId) == 0 &&
"LocList writer for DWO unit already exists.");
// Work around some bug in llvm-15. If I pass in directly lld reports
@@ -258,7 +258,7 @@ void DWARFRewriter::updateDebugInfo() {
// its matching split/DWO CU.
Optional<DWARFUnit *> SplitCU;
Optional<uint64_t> RangesBase;
- llvm::Optional<uint64_t> DWOId = Unit->getDWOId();
+ std::optional<uint64_t> DWOId = Unit->getDWOId();
StrOffstsWriter->initialize(Unit->getStringOffsetSection(),
Unit->getStringOffsetsTableContribution());
if (DWOId)
@@ -495,7 +495,7 @@ void DWARFRewriter::updateUnitDebugInfo(
}
case dwarf::DW_TAG_call_site: {
auto patchPC = [&](AttrInfo &AttrVal, StringRef Entry) -> void {
- Optional<uint64_t> Address = AttrVal.V.getAsAddress();
+ std::optional<uint64_t> Address = AttrVal.V.getAsAddress();
const BinaryFunction *Function =
BC.getBinaryFunctionContainingAddress(*Address);
uint64_t UpdatedAddress = *Address;
@@ -539,7 +539,7 @@ void DWARFRewriter::updateUnitDebugInfo(
: Value.getAsSectionOffset().value();
DebugLocationsVector InputLL;
- Optional<object::SectionedAddress> SectionAddress =
+ std::optional<object::SectionedAddress> SectionAddress =
Unit.getBaseAddress();
uint64_t BaseAddress = 0;
if (SectionAddress)
@@ -547,7 +547,7 @@ void DWARFRewriter::updateUnitDebugInfo(
if (Unit.getVersion() >= 5 &&
AttrVal->V.getForm() == dwarf::DW_FORM_loclistx) {
- Optional<uint64_t> LocOffset = Unit.getLoclistOffset(Offset);
+ std::optional<uint64_t> LocOffset = Unit.getLoclistOffset(Offset);
assert(LocOffset && "Location Offset is invalid.");
Offset = *LocOffset;
}
@@ -579,14 +579,14 @@ void DWARFRewriter::updateUnitDebugInfo(
Entry.Value0, Entry.Value0 + Entry.Value1, Entry.Loc});
break;
case dwarf::DW_LLE_base_addressx: {
- Optional<object::SectionedAddress> EntryAddress =
+ std::optional<object::SectionedAddress> EntryAddress =
Unit.getAddrOffsetSectionItem(Entry.Value0);
assert(EntryAddress && "base Address not found.");
BaseAddress = EntryAddress->Address;
break;
}
case dwarf::DW_LLE_startx_length: {
- Optional<object::SectionedAddress> EntryAddress =
+ std::optional<object::SectionedAddress> EntryAddress =
Unit.getAddrOffsetSectionItem(Entry.Value0);
assert(EntryAddress && "Address does not exist.");
InputLL.emplace_back(DebugLocationEntry{
@@ -595,10 +595,10 @@ void DWARFRewriter::updateUnitDebugInfo(
break;
}
case dwarf::DW_LLE_startx_endx: {
- Optional<object::SectionedAddress> StartAddress =
+ std::optional<object::SectionedAddress> StartAddress =
Unit.getAddrOffsetSectionItem(Entry.Value0);
assert(StartAddress && "Start Address does not exist.");
- Optional<object::SectionedAddress> EndAddress =
+ std::optional<object::SectionedAddress> EndAddress =
Unit.getAddrOffsetSectionItem(Entry.Value1);
assert(EndAddress && "Start Address does not exist.");
InputLL.emplace_back(DebugLocationEntry{
@@ -661,7 +661,7 @@ void DWARFRewriter::updateUnitDebugInfo(
Expr.getCode() == dwarf::DW_OP_addrx))
continue;
const uint64_t Index = Expr.getRawOperand(0);
- Optional<object::SectionedAddress> EntryAddress =
+ std::optional<object::SectionedAddress> EntryAddress =
Unit.getAddrOffsetSectionItem(Index);
assert(EntryAddress && "Address is not found.");
assert(Index <= std::numeric_limits<uint32_t>::max() &&
@@ -694,7 +694,7 @@ void DWARFRewriter::updateUnitDebugInfo(
findAttributeInfo(DIE, dwarf::DW_AT_low_pc)) {
AttrOffset = AttrVal->Offset;
Value = AttrVal->V;
- const Optional<uint64_t> Result = Value.getAsAddress();
+ const std::optional<uint64_t> Result = Value.getAsAddress();
if (Result) {
const uint64_t Address = *Result;
uint64_t NewAddress = 0;
@@ -742,7 +742,8 @@ void DWARFRewriter::updateUnitDebugInfo(
continue;
// If input is DWP file we need to keep track of which TU came from each
// CU, so we can write it out correctly.
- if (Optional<uint64_t> Val = SignatureAttrVal->V.getAsReferenceUVal())
+ if (std::optional<uint64_t> Val =
+ SignatureAttrVal->V.getAsReferenceUVal())
TypeSignaturesPerCU[*DIE.getDwarfUnit()->getDWOId()].insert(*Val);
else {
errs() << "BOT-ERROR: DW_AT_signature form is not supported.\n";
@@ -919,9 +920,9 @@ void DWARFRewriter::updateLineTableOffsets(const MCAsmLayout &Layout) {
std::unordered_map<uint64_t, uint64_t> DebugLineOffsetMap;
auto GetStatementListValue = [](DWARFUnit *Unit) {
- Optional<DWARFFormValue> StmtList =
+ std::optional<DWARFFormValue> StmtList =
Unit->getUnitDIE().find(dwarf::DW_AT_stmt_list);
- Optional<uint64_t> Offset = dwarf::toSectionOffset(StmtList);
+ std::optional<uint64_t> Offset = dwarf::toSectionOffset(StmtList);
assert(Offset && "Was not able to retreive value of DW_AT_stmt_list.");
return *Offset;
};
@@ -1412,7 +1413,7 @@ void DWARFRewriter::writeDWP(
}
for (const std::unique_ptr<DWARFUnit> &CU : BC.DwCtx->compile_units()) {
- Optional<uint64_t> DWOId = CU->getDWOId();
+ std::optional<uint64_t> DWOId = CU->getDWOId();
if (!DWOId)
continue;
@@ -1581,7 +1582,7 @@ void DWARFRewriter::writeDWOFiles(
}
for (const std::unique_ptr<DWARFUnit> &CU : BC.DwCtx->compile_units()) {
- Optional<uint64_t> DWOId = CU->getDWOId();
+ std::optional<uint64_t> DWOId = CU->getDWOId();
if (!DWOId)
continue;
diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index af463c218bb9b..d723e48e99bc8 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -315,7 +315,7 @@ Error TpiSource::mergeDebugT(TypeMerger *m) {
// When dealing with PCH.OBJ, some indices were already merged.
unsigned nbHeadIndices = indexMapStorage.size();
- Optional<PCHMergerInfo> pchInfo;
+ std::optional<PCHMergerInfo> pchInfo;
if (auto err = mergeTypeAndIdRecords(m->idTable, m->typeTable,
indexMapStorage, types, pchInfo))
fatal("codeview::mergeTypeAndIdRecords failed: " +
diff --git a/lld/ELF/DWARF.cpp b/lld/ELF/DWARF.cpp
index be4609fa229b1..a56454c53a6d3 100644
--- a/lld/ELF/DWARF.cpp
+++ b/lld/ELF/DWARF.cpp
@@ -127,7 +127,7 @@ LLDDwarfObj<ELFT>::findAux(const InputSectionBase &sec, uint64_t pos,
DataRefImpl d;
d.p = getAddend<ELFT>(rel);
return RelocAddrEntry{secIndex, RelocationRef(d, nullptr),
- val, Optional<object::RelocationRef>(),
+ val, std::optional<object::RelocationRef>(),
0, LLDRelocationResolver<RelTy>::resolve};
}
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index e92216bb5e4d5..d6029aa137092 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2613,10 +2613,10 @@ bool DWARFExpression::ParseDWARFLocationList(
dwarf_cu->GetLocationTable(data);
Log *log = GetLog(LLDBLog::Expressions);
auto lookup_addr =
- [&](uint32_t index) -> llvm::Optional<llvm::object::SectionedAddress> {
+ [&](uint32_t index) -> std::optional<llvm::object::SectionedAddress> {
addr_t address = dwarf_cu->ReadAddressFromDebugAddrSection(index);
if (address == LLDB_INVALID_ADDRESS)
- return llvm::None;
+ return std::nullopt;
return llvm::object::SectionedAddress{address};
};
auto process_list = [&](llvm::Expected<llvm::DWARFLocationExpression> loc) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 21ef765d1bba3..399578b6a3535 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -578,7 +578,7 @@ llvm::Expected<uint64_t> DWARFUnit::GetRnglistOffset(uint32_t Index) {
"DW_FORM_rnglistx cannot be used without "
"DW_AT_rnglists_base for CU at 0x%8.8x",
GetOffset());
- if (llvm::Optional<uint64_t> off = GetRnglistTable()->getOffsetEntry(
+ if (std::optional<uint64_t> off = GetRnglistTable()->getOffsetEntry(
GetRnglistData().GetAsLLVM(), Index))
return *off + m_ranges_base;
return llvm::createStringError(
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 26e322059743b..9fdab3c5273f9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -243,7 +243,7 @@ class DWARFUnit : public lldb_private::UserID {
if (!m_loclist_table_header)
return llvm::None;
- llvm::Optional<uint64_t> Offset = m_loclist_table_header->getOffsetEntry(
+ std::optional<uint64_t> Offset = m_loclist_table_header->getOffsetEntry(
m_dwarf.GetDWARFContext().getOrLoadLocListsData().GetAsLLVM(), Index);
if (!Offset)
return llvm::None;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index a8e9b41c83fe4..d0b2ef66d4010 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -43,7 +43,7 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) {
llvm::Optional<DIERef>
DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) {
- llvm::Optional<uint64_t> cu_offset = entry.getCUOffset();
+ std::optional<uint64_t> cu_offset = entry.getCUOffset();
if (!cu_offset)
return llvm::None;
@@ -52,7 +52,7 @@ DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) {
return llvm::None;
cu = &cu->GetNonSkeletonUnit();
- if (llvm::Optional<uint64_t> die_offset = entry.getDIEUnitOffset())
+ if (std::optional<uint64_t> die_offset = entry.getDIEUnitOffset())
return DIERef(cu->GetSymbolFileDWARF().GetDwoNum(),
DIERef::Section::DebugInfo, cu->GetOffset() + *die_offset);
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
index d15c0ee99f96c..e2e06491e8c17 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
@@ -66,7 +66,7 @@ static void ParseBuildInfo(PdbIndex &index, const CVSymbol &sym,
// S_BUILDINFO just points to an LF_BUILDINFO in the IPI stream. Let's do
// a little extra work to pull out the LF_BUILDINFO.
LazyRandomTypeCollection &types = index.ipi().typeCollection();
- llvm::Optional<CVType> cvt = types.tryGetType(bis.BuildId);
+ std::optional<CVType> cvt = types.tryGetType(bis.BuildId);
if (!cvt || cvt->kind() != LF_BUILDINFO)
return;
diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h
index e288c5191bdb5..2b49c375acb37 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.h
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -634,7 +634,7 @@ unsigned AttributeEncodingVendor(TypeKind E);
unsigned LanguageVendor(SourceLanguage L);
/// @}
-Optional<unsigned> LanguageLowerBound(SourceLanguage L);
+std::optional<unsigned> LanguageLowerBound(SourceLanguage L);
/// The size of a reference determined by the DWARF 32/64-bit format.
inline uint8_t getDwarfOffsetByteSize(DwarfFormat Format) {
@@ -694,9 +694,10 @@ inline uint8_t getUnitLengthFieldByteSize(DwarfFormat Format) {
///
/// \param Form DWARF form to get the fixed byte size for.
/// \param Params DWARF parameters to help interpret forms.
-/// \returns Optional<uint8_t> value with the fixed byte size or None if
+/// \returns std::optional<uint8_t> value with the fixed byte size or None if
/// \p Form doesn't have a fixed byte size.
-Optional<uint8_t> getFixedFormByteSize(dwarf::Form Form, FormParams Params);
+std::optional<uint8_t> getFixedFormByteSize(dwarf::Form Form,
+ FormParams Params);
/// Tells whether the specified form is defined in the specified version,
/// or is an extension if extensions are allowed.
diff --git a/llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
index d474173973b59..fa2277343d5d4 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
@@ -36,8 +36,8 @@ class AppendingTypeTableBuilder : public TypeCollection {
~AppendingTypeTableBuilder();
// TypeCollection overrides
- Optional<TypeIndex> getFirst() override;
- Optional<TypeIndex> getNext(TypeIndex Prev) override;
+ std::optional<TypeIndex> getFirst() override;
+ std::optional<TypeIndex> getNext(TypeIndex Prev) override;
CVType getType(TypeIndex Index) override;
StringRef getTypeName(TypeIndex Index) override;
bool contains(TypeIndex Index) override;
diff --git a/llvm/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h b/llvm/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h
index ef44b622d955a..c629018fd109f 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h
@@ -19,9 +19,9 @@ class SymbolVisitorCallbacks;
class CVSymbolVisitor {
public:
struct FilterOptions {
- llvm::Optional<uint32_t> SymbolOffset;
- llvm::Optional<uint32_t> ParentRecursiveDepth;
- llvm::Optional<uint32_t> ChildRecursiveDepth;
+ std::optional<uint32_t> SymbolOffset;
+ std::optional<uint32_t> ParentRecursiveDepth;
+ std::optional<uint32_t> ChildRecursiveDepth;
};
CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks);
diff --git a/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h b/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
index ccaf6506abde3..5a2d0c6c049a9 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
@@ -10,7 +10,6 @@
#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
#include "llvm/ADT/None.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
@@ -63,7 +62,7 @@ class CodeViewRecordIO {
explicit CodeViewRecordIO(CodeViewRecordStreamer &Streamer)
: Streamer(&Streamer) {}
- Error beginRecord(Optional<uint32_t> MaxLength);
+ Error beginRecord(std::optional<uint32_t> MaxLength);
Error endRecord();
Error mapInteger(TypeIndex &TypeInd, const Twine &Comment = "");
@@ -245,9 +244,9 @@ class CodeViewRecordIO {
struct RecordLimit {
uint32_t BeginOffset;
- Optional<uint32_t> MaxLength;
+ std::optional<uint32_t> MaxLength;
- Optional<uint32_t> bytesRemaining(uint32_t CurrentOffset) const {
+ std::optional<uint32_t> bytesRemaining(uint32_t CurrentOffset) const {
if (!MaxLength)
return std::nullopt;
assert(CurrentOffset >= BeginOffset);
diff --git a/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
index 0f83ae370a1ee..84cef520a2f46 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
@@ -10,7 +10,6 @@
#define LLVM_DEBUGINFO_CODEVIEW_CONTINUATIONRECORDBUILDER_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/DebugInfo/CodeView/CVRecord.h"
#include "llvm/DebugInfo/CodeView/TypeRecordMapping.h"
@@ -26,7 +25,7 @@ enum class ContinuationRecordKind { FieldList, MethodOverloadList };
class ContinuationRecordBuilder {
SmallVector<uint32_t, 4> SegmentOffsets;
- Optional<ContinuationRecordKind> Kind;
+ std::optional<ContinuationRecordKind> Kind;
AppendingBinaryByteStream Buffer;
BinaryStreamWriter SegmentWriter;
TypeRecordMapping Mapping;
@@ -36,7 +35,7 @@ class ContinuationRecordBuilder {
void insertSegmentEnd(uint32_t Offset);
CVType createSegmentRecord(uint32_t OffBegin, uint32_t OffEnd,
- Optional<TypeIndex> RefersTo);
+ std::optional<TypeIndex> RefersTo);
public:
ContinuationRecordBuilder();
diff --git a/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
index d592bde18bae6..18f16bc66a777 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
@@ -49,8 +49,8 @@ class GlobalTypeTableBuilder : public TypeCollection {
~GlobalTypeTableBuilder();
// TypeCollection overrides
- Optional<TypeIndex> getFirst() override;
- Optional<TypeIndex> getNext(TypeIndex Prev) override;
+ std::optional<TypeIndex> getFirst() override;
+ std::optional<TypeIndex> getNext(TypeIndex Prev) override;
CVType getType(TypeIndex Index) override;
StringRef getTypeName(TypeIndex Index) override;
bool contains(TypeIndex Index) override;
diff --git a/llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h b/llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
index ddbb4e3c5e6c8..240f7092140c1 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
@@ -10,7 +10,6 @@
#define LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/CodeView/TypeCollection.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
@@ -69,15 +68,15 @@ class LazyRandomTypeCollection : public TypeCollection {
uint32_t getOffsetOfType(TypeIndex Index);
- Optional<CVType> tryGetType(TypeIndex Index);
+ std::optional<CVType> tryGetType(TypeIndex Index);
CVType getType(TypeIndex Index) override;
StringRef getTypeName(TypeIndex Index) override;
bool contains(TypeIndex Index) override;
uint32_t size() override;
uint32_t capacity() override;
- Optional<TypeIndex> getFirst() override;
- Optional<TypeIndex> getNext(TypeIndex Prev) override;
+ std::optional<TypeIndex> getFirst() override;
+ std::optional<TypeIndex> getNext(TypeIndex Prev) override;
bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override;
private:
diff --git a/llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
index 1965aab9b5cc7..10bc8f60613c8 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
@@ -45,8 +45,8 @@ class MergingTypeTableBuilder : public TypeCollection {
~MergingTypeTableBuilder();
// TypeCollection overrides
- Optional<TypeIndex> getFirst() override;
- Optional<TypeIndex> getNext(TypeIndex Prev) override;
+ std::optional<TypeIndex> getFirst() override;
+ std::optional<TypeIndex> getNext(TypeIndex Prev) override;
CVType getType(TypeIndex Index) override;
StringRef getTypeName(TypeIndex Index) override;
bool contains(TypeIndex Index) override;
diff --git a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h
index 9513e19a330a6..3ddcf9c573909 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h
@@ -11,7 +11,6 @@
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator.h"
#include "llvm/ADT/iterator_range.h"
@@ -324,7 +323,7 @@ struct BinaryAnnotationIterator
return true;
}
- Optional<DecodedAnnotation> Current;
+ std::optional<DecodedAnnotation> Current;
ArrayRef<uint8_t> Data;
ArrayRef<uint8_t> Next;
};
diff --git a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h
index 34368b6185d65..30e9c626c2054 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h
@@ -35,7 +35,7 @@ class SymbolRecordMapping : public SymbolVisitorCallbacks {
#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
private:
- Optional<SymbolKind> Kind;
+ std::optional<SymbolKind> Kind;
CodeViewRecordIO IO;
CodeViewContainer Container;
diff --git a/llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h b/llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
index 53986f9a6db68..df52b374f72df 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H
#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H
-#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/CodeView/CVRecord.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/RecordSerialization.h"
@@ -35,7 +34,7 @@ class SymbolSerializer : public SymbolVisitorCallbacks {
MutableBinaryByteStream Stream;
BinaryStreamWriter Writer;
SymbolRecordMapping Mapping;
- Optional<SymbolKind> CurrentSymbol;
+ std::optional<SymbolKind> CurrentSymbol;
Error writeRecordPrefix(SymbolKind Kind) {
RecordPrefix Prefix;
diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h b/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h
index f643bc4d7451a..dd082a72125a5 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h
@@ -21,8 +21,8 @@ class TypeCollection {
bool empty() { return size() == 0; }
- virtual Optional<TypeIndex> getFirst() = 0;
- virtual Optional<TypeIndex> getNext(TypeIndex Prev) = 0;
+ virtual std::optional<TypeIndex> getFirst() = 0;
+ virtual std::optional<TypeIndex> getNext(TypeIndex Prev) = 0;
virtual CVType getType(TypeIndex Index) = 0;
virtual StringRef getTypeName(TypeIndex Index) = 0;
@@ -32,7 +32,7 @@ class TypeCollection {
virtual bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) = 0;
template <typename TFunc> void ForEachRecord(TFunc Func) {
- Optional<TypeIndex> Next = getFirst();
+ std::optional<TypeIndex> Next = getFirst();
while (Next) {
TypeIndex N = *Next;
diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h b/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h
index 01916bd18fb86..1ebc4d47e0964 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h
@@ -11,7 +11,6 @@
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/CodeView/CVRecord.h"
@@ -22,6 +21,7 @@
#include "llvm/Support/Endian.h"
#include <algorithm>
#include <cstdint>
+#include <optional>
#include <vector>
namespace llvm {
diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h b/llvm/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h
index ed4fc7a756242..26eb7d221679d 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h
@@ -9,12 +9,12 @@
#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORDMAPPING_H
#define LLVM_DEBUGINFO_CODEVIEW_TYPERECORDMAPPING_H
-#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/CodeView/CVRecord.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/CodeViewRecordIO.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
#include "llvm/Support/Error.h"
+#include <optional>
namespace llvm {
class BinaryStreamReader;
@@ -46,8 +46,8 @@ class TypeRecordMapping : public TypeVisitorCallbacks {
#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
private:
- Optional<TypeLeafKind> TypeKind;
- Optional<TypeLeafKind> MemberKind;
+ std::optional<TypeLeafKind> TypeKind;
+ std::optional<TypeLeafKind> MemberKind;
CodeViewRecordIO IO;
};
diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h b/llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h
index 6abf67a27bd1f..86edfc4b055f4 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h
@@ -91,20 +91,20 @@ Error mergeTypeAndIdRecords(MergingTypeTableBuilder &DestIds,
MergingTypeTableBuilder &DestTypes,
SmallVectorImpl<TypeIndex> &SourceToDest,
const CVTypeArray &IdsAndTypes,
- Optional<PCHMergerInfo> &PCHInfo);
+ std::optional<PCHMergerInfo> &PCHInfo);
Error mergeTypeAndIdRecords(GlobalTypeTableBuilder &DestIds,
GlobalTypeTableBuilder &DestTypes,
SmallVectorImpl<TypeIndex> &SourceToDest,
const CVTypeArray &IdsAndTypes,
ArrayRef<GloballyHashedType> Hashes,
- Optional<PCHMergerInfo> &PCHInfo);
+ std::optional<PCHMergerInfo> &PCHInfo);
Error mergeTypeRecords(GlobalTypeTableBuilder &Dest,
SmallVectorImpl<TypeIndex> &SourceToDest,
const CVTypeArray &Types,
ArrayRef<GloballyHashedType> Hashes,
- Optional<PCHMergerInfo> &PCHInfo);
+ std::optional<PCHMergerInfo> &PCHInfo);
Error mergeIdRecords(GlobalTypeTableBuilder &Dest, ArrayRef<TypeIndex> Types,
SmallVectorImpl<TypeIndex> &SourceToDest,
diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeTableCollection.h b/llvm/include/llvm/DebugInfo/CodeView/TypeTableCollection.h
index c3008742d2e13..2a389b9ac34e7 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeTableCollection.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeTableCollection.h
@@ -21,8 +21,8 @@ class TypeTableCollection : public TypeCollection {
public:
explicit TypeTableCollection(ArrayRef<ArrayRef<uint8_t>> Records);
- Optional<TypeIndex> getFirst() override;
- Optional<TypeIndex> getNext(TypeIndex Prev) override;
+ std::optional<TypeIndex> getFirst() override;
+ std::optional<TypeIndex> getNext(TypeIndex Prev) override;
CVType getType(TypeIndex Index) override;
StringRef getTypeName(TypeIndex Index) override;
diff --git a/llvm/include/llvm/DebugInfo/DIContext.h b/llvm/include/llvm/DebugInfo/DIContext.h
index 9b278b6960738..afc2d5176ebcb 100644
--- a/llvm/include/llvm/DebugInfo/DIContext.h
+++ b/llvm/include/llvm/DebugInfo/DIContext.h
@@ -21,6 +21,7 @@
#include <cassert>
#include <cstdint>
#include <memory>
+#include <optional>
#include <string>
#include <tuple>
#include <utility>
@@ -36,11 +37,11 @@ struct DILineInfo {
std::string FileName;
std::string FunctionName;
std::string StartFileName;
- Optional<StringRef> Source;
+ std::optional<StringRef> Source;
uint32_t Line = 0;
uint32_t Column = 0;
uint32_t StartLine = 0;
- Optional<uint64_t> StartAddress;
+ std::optional<uint64_t> StartAddress;
// DWARF-specific.
uint32_t Discriminator = 0;
@@ -125,9 +126,9 @@ struct DILocal {
std::string Name;
std::string DeclFile;
uint64_t DeclLine = 0;
- Optional<int64_t> FrameOffset;
- Optional<uint64_t> Size;
- Optional<uint64_t> TagOffset;
+ std::optional<int64_t> FrameOffset;
+ std::optional<uint64_t> Size;
+ std::optional<uint64_t> TagOffset;
};
/// A DINameKind is passed to name search methods to specify a
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
index 3887656ceef6e..6d7c5773379eb 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_DWARF_DWARFABBREVIATIONDECLARATION_H
#define LLVM_DEBUGINFO_DWARF_DWARFABBREVIATIONDECLARATION_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/BinaryFormat/Dwarf.h"
@@ -31,7 +30,8 @@ class DWARFAbbreviationDeclaration {
: Attr(A), Form(F), Value(Value) {
assert(isImplicitConst());
}
- AttributeSpec(dwarf::Attribute A, dwarf::Form F, Optional<uint8_t> ByteSize)
+ AttributeSpec(dwarf::Attribute A, dwarf::Form F,
+ std::optional<uint8_t> ByteSize)
: Attr(A), Form(F) {
assert(!isImplicitConst());
this->ByteSize.HasByteSize = ByteSize.has_value();
@@ -79,7 +79,7 @@ class DWARFAbbreviationDeclaration {
/// use the DWARFUnit to calculate the size of the Form, like for
/// DW_AT_address and DW_AT_ref_addr, so this isn't just an accessor for
/// the ByteSize member.
- Optional<int64_t> getByteSize(const DWARFUnit &U) const;
+ std::optional<int64_t> getByteSize(const DWARFUnit &U) const;
};
using AttributeSpecVector = SmallVector<AttributeSpec, 8>;
@@ -128,7 +128,7 @@ class DWARFAbbreviationDeclaration {
///
/// \param attr DWARF attribute to search for.
/// \returns Optional index of the attribute if found, None otherwise.
- Optional<uint32_t> findAttributeIndex(dwarf::Attribute attr) const;
+ std::optional<uint32_t> findAttributeIndex(dwarf::Attribute attr) const;
/// Extract a DWARF form value from a DIE specified by DIE offset.
///
@@ -140,9 +140,9 @@ class DWARFAbbreviationDeclaration {
/// \param Attr DWARF attribute to search for.
/// \param U the DWARFUnit the contains the DIE.
/// \returns Optional DWARF form value if the attribute was extracted.
- Optional<DWARFFormValue> getAttributeValue(const uint64_t DIEOffset,
- const dwarf::Attribute Attr,
- const DWARFUnit &U) const;
+ std::optional<DWARFFormValue> getAttributeValue(const uint64_t DIEOffset,
+ const dwarf::Attribute Attr,
+ const DWARFUnit &U) const;
/// Compute an offset from a DIE specified by DIE offset and attribute index.
///
@@ -161,7 +161,7 @@ class DWARFAbbreviationDeclaration {
/// \param Offset offset of the attribute.
/// \param U the DWARFUnit the contains the DIE.
/// \returns Optional DWARF form value if the attribute was extracted.
- Optional<DWARFFormValue>
+ std::optional<DWARFFormValue>
getAttributeValueFromOffset(uint32_t AttrIndex, uint64_t Offset,
const DWARFUnit &U) const;
@@ -171,7 +171,7 @@ class DWARFAbbreviationDeclaration {
// Return an optional byte size of all attribute data in this abbreviation
// if a constant byte size can be calculated given a DWARFUnit. This allows
// DWARF parsing to be faster as many DWARF DIEs have a fixed byte size.
- Optional<size_t> getFixedAttributesByteSize(const DWARFUnit &U) const;
+ std::optional<size_t> getFixedAttributesByteSize(const DWARFUnit &U) const;
private:
void clear();
@@ -206,7 +206,7 @@ class DWARFAbbreviationDeclaration {
AttributeSpecVector AttributeSpecs;
/// If this abbreviation has a fixed byte size then FixedAttributeSize member
/// variable below will have a value.
- Optional<FixedSizeInfo> FixedAttributeSize;
+ std::optional<FixedSizeInfo> FixedAttributeSize;
};
} // end namespace llvm
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
index 355995bf69b9f..aad46b945adf1 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
@@ -53,12 +53,12 @@ class DWARFAcceleratorTable {
/// Returns the Offset of the Compilation Unit associated with this
/// Accelerator Entry or None if the Compilation Unit offset is not recorded
/// in this Accelerator Entry.
- virtual Optional<uint64_t> getCUOffset() const = 0;
+ virtual std::optional<uint64_t> getCUOffset() const = 0;
/// Returns the Tag of the Debug Info Entry associated with this
/// Accelerator Entry or None if the Tag is not recorded in this
/// Accelerator Entry.
- virtual Optional<dwarf::Tag> getTag() const = 0;
+ virtual std::optional<dwarf::Tag> getTag() const = 0;
/// Returns the raw values of fields in the Accelerator Entry. In general,
/// these can only be interpreted with the help of the metadata in the
@@ -99,7 +99,8 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
uint64_t DIEOffsetBase;
SmallVector<std::pair<AtomType, Form>, 3> Atoms;
- Optional<uint64_t> extractOffset(Optional<DWARFFormValue> Value) const;
+ std::optional<uint64_t>
+ extractOffset(std::optional<DWARFFormValue> Value) const;
};
struct Header Hdr;
@@ -122,19 +123,19 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
void extract(const AppleAcceleratorTable &AccelTable, uint64_t *Offset);
public:
- Optional<uint64_t> getCUOffset() const override;
+ std::optional<uint64_t> getCUOffset() const override;
/// Returns the Section Offset of the Debug Info Entry associated with this
/// Accelerator Entry or None if the DIE offset is not recorded in this
/// Accelerator Entry. The returned offset is relative to the start of the
/// Section containing the DIE.
- Optional<uint64_t> getDIESectionOffset() const;
+ std::optional<uint64_t> getDIESectionOffset() const;
- Optional<dwarf::Tag> getTag() const override;
+ std::optional<dwarf::Tag> getTag() const override;
/// Returns the value of the Atom in this Accelerator Entry, if the Entry
/// contains such Atom.
- Optional<DWARFFormValue> lookup(HeaderData::AtomType Atom) const;
+ std::optional<DWARFFormValue> lookup(HeaderData::AtomType Atom) const;
friend class AppleAcceleratorTable;
friend class ValueIterator;
@@ -287,8 +288,8 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
Entry(const NameIndex &NameIdx, const Abbrev &Abbr);
public:
- Optional<uint64_t> getCUOffset() const override;
- Optional<dwarf::Tag> getTag() const override { return tag(); }
+ std::optional<uint64_t> getCUOffset() const override;
+ std::optional<dwarf::Tag> getTag() const override { return tag(); }
/// Returns the Index into the Compilation Unit list of the owning Name
/// Index or None if this Accelerator Entry does not have an associated
@@ -298,14 +299,14 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
/// just a single Compilation Unit are implicitly associated with that unit,
/// so this function will return 0 even without an explicit
/// DW_IDX_compile_unit attribute.
- Optional<uint64_t> getCUIndex() const;
+ std::optional<uint64_t> getCUIndex() const;
/// .debug_names-specific getter, which always succeeds (DWARF v5 index
/// entries always have a tag).
dwarf::Tag tag() const { return Abbr->Tag; }
/// Returns the Offset of the DIE within the containing CU or TU.
- Optional<uint64_t> getDIEUnitOffset() const;
+ std::optional<uint64_t> getDIEUnitOffset() const;
/// Return the Abbreviation that can be used to interpret the raw values of
/// this Accelerator Entry.
@@ -313,7 +314,7 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
/// Returns the value of the Index Attribute in this Accelerator Entry, if
/// the Entry contains such Attribute.
- Optional<DWARFFormValue> lookup(dwarf::Index Index) const;
+ std::optional<DWARFFormValue> lookup(dwarf::Index Index) const;
void dump(ScopedPrinter &W) const;
@@ -406,7 +407,7 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
void dumpAbbreviations(ScopedPrinter &W) const;
bool dumpEntry(ScopedPrinter &W, uint64_t *Offset) const;
void dumpName(ScopedPrinter &W, const NameTableEntry &NTE,
- Optional<uint32_t> Hash) const;
+ std::optional<uint32_t> Hash) const;
void dumpBucket(ScopedPrinter &W, uint32_t Bucket) const;
Expected<AttributeEncoding> extractAttributeEncoding(uint64_t *Offset);
@@ -491,13 +492,13 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
/// (searches all name indices).
bool IsLocal;
- Optional<Entry> CurrentEntry;
+ std::optional<Entry> CurrentEntry;
uint64_t DataOffset = 0; ///< Offset into the section.
std::string Key; ///< The Key we are searching for.
- Optional<uint32_t> Hash; ///< Hash of Key, if it has been computed.
+ std::optional<uint32_t> Hash; ///< Hash of Key, if it has been computed.
bool getEntryAtCurrentOffset();
- Optional<uint64_t> findEntryOffsetInCurrentIndex();
+ std::optional<uint64_t> findEntryOffsetInCurrentIndex();
bool findInCurrentIndex();
void searchFromStartOfCurrentIndex();
void next();
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
index bf591ed554c6a..5dc000163e7d9 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
@@ -46,7 +46,7 @@ class DWARFUnitIndex;
/// information parsing. The actual data is supplied through DWARFObj.
class DWARFContext : public DIContext {
DWARFUnitVector NormalUnits;
- Optional<DenseMap<uint64_t, DWARFTypeUnit*>> NormalTypeUnits;
+ std::optional<DenseMap<uint64_t, DWARFTypeUnit *>> NormalTypeUnits;
std::unique_ptr<DWARFUnitIndex> CUIndex;
std::unique_ptr<DWARFGdbIndex> GdbIndex;
std::unique_ptr<DWARFUnitIndex> TUIndex;
@@ -65,7 +65,7 @@ class DWARFContext : public DIContext {
std::unique_ptr<AppleAcceleratorTable> AppleObjC;
DWARFUnitVector DWOUnits;
- Optional<DenseMap<uint64_t, DWARFTypeUnit*>> DWOTypeUnits;
+ std::optional<DenseMap<uint64_t, DWARFTypeUnit *>> DWOTypeUnits;
std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO;
std::unique_ptr<DWARFDebugMacro> MacinfoDWO;
std::unique_ptr<DWARFDebugMacro> MacroDWO;
@@ -132,10 +132,10 @@ class DWARFContext : public DIContext {
/// Dump a textual representation to \p OS. If any \p DumpOffsets are present,
/// dump only the record at the specified offset.
void dump(raw_ostream &OS, DIDumpOptions DumpOpts,
- std::array<Optional<uint64_t>, DIDT_ID_Count> DumpOffsets);
+ std::array<std::optional<uint64_t>, DIDT_ID_Count> DumpOffsets);
void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override {
- std::array<Optional<uint64_t>, DIDT_ID_Count> DumpOffsets;
+ std::array<std::optional<uint64_t>, DIDT_ID_Count> DumpOffsets;
dump(OS, DumpOpts, DumpOffsets);
}
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
index 49749201af99a..e94fa7bf5590f 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
@@ -81,8 +81,8 @@ class DWARFDataExtractor : public DataExtractor {
/// There is a DWARF encoding that uses a PC-relative adjustment.
/// For these values, \p AbsPosOffset is used to fix them, which should
/// reflect the absolute address of this pointer.
- Optional<uint64_t> getEncodedPointer(uint64_t *Offset, uint8_t Encoding,
- uint64_t AbsPosOffset = 0) const;
+ std::optional<uint64_t> getEncodedPointer(uint64_t *Offset, uint8_t Encoding,
+ uint64_t AbsPosOffset = 0) const;
};
} // end namespace llvm
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
index 882aa69d9ccbe..52a88f2c390aa 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
@@ -59,7 +59,7 @@ class DWARFDebugAbbrev {
mutable DWARFAbbreviationDeclarationSetMap AbbrDeclSets;
mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos;
- mutable Optional<DataExtractor> Data;
+ mutable std::optional<DataExtractor> Data;
public:
DWARFDebugAbbrev();
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h
index 67d9ce1476dd8..9549a57894885 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h
@@ -70,7 +70,7 @@ class DWARFDebugAddrTable {
/// Return the full length of this table, including the length field.
/// Return None if the length cannot be identified reliably.
- Optional<uint64_t> getFullLength() const;
+ std::optional<uint64_t> getFullLength() const;
/// Return the DWARF format of this table.
dwarf::DwarfFormat getFormat() const { return Format; }
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
index 75a1a0b05b2a2..9dfe95aa7131e 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
@@ -67,10 +67,10 @@ class UnwindLocation {
Location Kind; /// The type of the location that describes how to unwind it.
uint32_t RegNum; /// The register number for Kind == RegPlusOffset.
int32_t Offset; /// The offset for Kind == CFAPlusOffset or RegPlusOffset.
- Optional<uint32_t> AddrSpace; /// The address space for Kind == RegPlusOffset
- /// for CFA.
- Optional<DWARFExpression> Expr; /// The DWARF expression for Kind ==
- /// DWARFExpression.
+ std::optional<uint32_t> AddrSpace; /// The address space for Kind ==
+ /// RegPlusOffset for CFA.
+ std::optional<DWARFExpression> Expr; /// The DWARF expression for Kind ==
+ /// DWARFExpression.
bool Dereference; /// If true, the resulting location must be dereferenced
/// after the location value is computed.
@@ -80,8 +80,8 @@ class UnwindLocation {
: Kind(K), RegNum(InvalidRegisterNumber), Offset(0),
AddrSpace(std::nullopt), Dereference(false) {}
- UnwindLocation(Location K, uint32_t Reg, int32_t Off, Optional<uint32_t> AS,
- bool Deref)
+ UnwindLocation(Location K, uint32_t Reg, int32_t Off,
+ std::optional<uint32_t> AS, bool Deref)
: Kind(K), RegNum(Reg), Offset(Off), AddrSpace(AS), Dereference(Deref) {}
UnwindLocation(DWARFExpression E, bool Deref)
@@ -117,10 +117,10 @@ class UnwindLocation {
/// false.
static UnwindLocation
createIsRegisterPlusOffset(uint32_t Reg, int32_t Off,
- Optional<uint32_t> AddrSpace = std::nullopt);
+ std::optional<uint32_t> AddrSpace = std::nullopt);
static UnwindLocation
createAtRegisterPlusOffset(uint32_t Reg, int32_t Off,
- Optional<uint32_t> AddrSpace = std::nullopt);
+ std::optional<uint32_t> AddrSpace = std::nullopt);
/// Create a location whose value is the result of evaluating a DWARF
/// expression. This allows complex expressions to be evaluated in order to
/// unwind a register or CFA value.
@@ -149,7 +149,9 @@ class UnwindLocation {
// DW_CFA_AARCH64_negate_ra_state).
void setConstant(int32_t Value) { Offset = Value; }
- Optional<DWARFExpression> getDWARFExpressionBytes() const { return Expr; }
+ std::optional<DWARFExpression> getDWARFExpressionBytes() const {
+ return Expr;
+ }
/// Dump a location expression as text and use the register information if
/// some is provided.
///
@@ -187,7 +189,7 @@ class RegisterLocations {
///
/// \returns A location if one is available for \a RegNum, or llvm::None
/// otherwise.
- Optional<UnwindLocation> getRegisterLocation(uint32_t RegNum) const {
+ std::optional<UnwindLocation> getRegisterLocation(uint32_t RegNum) const {
auto Pos = Locations.find(RegNum);
if (Pos == Locations.end())
return std::nullopt;
@@ -253,7 +255,7 @@ raw_ostream &operator<<(raw_ostream &OS, const RegisterLocations &RL);
class UnwindRow {
/// The address will be valid when parsing the instructions in a FDE. If
/// invalid, this object represents the initial instructions of a CIE.
- Optional<uint64_t> Address; ///< Address for row in FDE, invalid for CIE.
+ std::optional<uint64_t> Address; ///< Address for row in FDE, invalid for CIE.
UnwindLocation CFAValue; ///< How to unwind the Call Frame Address (CFA).
RegisterLocations RegLocs; ///< How to unwind all registers in this list.
@@ -373,7 +375,7 @@ class UnwindTable {
RowContainer Rows;
/// The end address when data is extracted from a FDE. This value will be
/// invalid when a UnwindTable is extracted from a CIE.
- Optional<uint64_t> EndAddress;
+ std::optional<uint64_t> EndAddress;
/// Parse the information in the CFIProgram and update the CurrRow object
/// that the state machine describes.
@@ -416,7 +418,7 @@ class CFIProgram {
uint8_t Opcode;
Operands Ops;
// Associated DWARF expression in case this instruction refers to one
- Optional<DWARFExpression> Expression;
+ std::optional<DWARFExpression> Expression;
Expected<uint64_t> getOperandAsUnsigned(const CFIProgram &CFIP,
uint32_t OperandIdx) const;
@@ -573,8 +575,8 @@ class CIE : public FrameEntry {
uint8_t SegmentDescriptorSize, uint64_t CodeAlignmentFactor,
int64_t DataAlignmentFactor, uint64_t ReturnAddressRegister,
SmallString<8> AugmentationData, uint32_t FDEPointerEncoding,
- uint32_t LSDAPointerEncoding, Optional<uint64_t> Personality,
- Optional<uint32_t> PersonalityEnc, Triple::ArchType Arch)
+ uint32_t LSDAPointerEncoding, std::optional<uint64_t> Personality,
+ std::optional<uint32_t> PersonalityEnc, Triple::ArchType Arch)
: FrameEntry(FK_CIE, IsDWARF64, Offset, Length, CodeAlignmentFactor,
DataAlignmentFactor, Arch),
Version(Version), Augmentation(std::move(Augmentation)),
@@ -594,8 +596,10 @@ class CIE : public FrameEntry {
int64_t getDataAlignmentFactor() const { return DataAlignmentFactor; }
uint8_t getVersion() const { return Version; }
uint64_t getReturnAddressRegister() const { return ReturnAddressRegister; }
- Optional<uint64_t> getPersonalityAddress() const { return Personality; }
- Optional<uint32_t> getPersonalityEncoding() const { return PersonalityEnc; }
+ std::optional<uint64_t> getPersonalityAddress() const { return Personality; }
+ std::optional<uint32_t> getPersonalityEncoding() const {
+ return PersonalityEnc;
+ }
uint32_t getFDEPointerEncoding() const { return FDEPointerEncoding; }
@@ -618,8 +622,8 @@ class CIE : public FrameEntry {
const SmallString<8> AugmentationData;
const uint32_t FDEPointerEncoding;
const uint32_t LSDAPointerEncoding;
- const Optional<uint64_t> Personality;
- const Optional<uint32_t> PersonalityEnc;
+ const std::optional<uint64_t> Personality;
+ const std::optional<uint32_t> PersonalityEnc;
};
/// DWARF Frame Description Entry (FDE)
@@ -627,11 +631,10 @@ class FDE : public FrameEntry {
public:
FDE(bool IsDWARF64, uint64_t Offset, uint64_t Length, uint64_t CIEPointer,
uint64_t InitialLocation, uint64_t AddressRange, CIE *Cie,
- Optional<uint64_t> LSDAAddress, Triple::ArchType Arch)
+ std::optional<uint64_t> LSDAAddress, Triple::ArchType Arch)
: FrameEntry(FK_FDE, IsDWARF64, Offset, Length,
Cie ? Cie->getCodeAlignmentFactor() : 0,
- Cie ? Cie->getDataAlignmentFactor() : 0,
- Arch),
+ Cie ? Cie->getDataAlignmentFactor() : 0, Arch),
CIEPointer(CIEPointer), InitialLocation(InitialLocation),
AddressRange(AddressRange), LinkedCIE(Cie), LSDAAddress(LSDAAddress) {}
@@ -640,7 +643,7 @@ class FDE : public FrameEntry {
const CIE *getLinkedCIE() const { return LinkedCIE; }
uint64_t getInitialLocation() const { return InitialLocation; }
uint64_t getAddressRange() const { return AddressRange; }
- Optional<uint64_t> getLSDAAddress() const { return LSDAAddress; }
+ std::optional<uint64_t> getLSDAAddress() const { return LSDAAddress; }
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI,
bool IsEH) const override;
@@ -656,7 +659,7 @@ class FDE : public FrameEntry {
const uint64_t InitialLocation;
const uint64_t AddressRange;
const CIE *LinkedCIE;
- const Optional<uint64_t> LSDAAddress;
+ const std::optional<uint64_t> LSDAAddress;
};
} // end namespace dwarf
@@ -686,7 +689,7 @@ class DWARFDebugFrame {
/// Dump the section data into the given stream.
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI,
- Optional<uint64_t> Offset) const;
+ std::optional<uint64_t> Offset) const;
/// Parse the section from raw data. \p Data is assumed to contain the whole
/// frame section contents to be parsed.
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
index 89c042a0287bc..7d59f4257b2e2 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
@@ -45,7 +45,7 @@ class DWARFDebugInfoEntry {
uint64_t getOffset() const { return Offset; }
/// Returns index of the parent die.
- Optional<uint32_t> getParentIdx() const {
+ std::optional<uint32_t> getParentIdx() const {
if (ParentIdx == UINT32_MAX)
return std::nullopt;
@@ -53,7 +53,7 @@ class DWARFDebugInfoEntry {
}
/// Returns index of the sibling die.
- Optional<uint32_t> getSiblingIdx() const {
+ std::optional<uint32_t> getSiblingIdx() const {
if (SiblingIdx == 0)
return std::nullopt;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
index a932662ae04e7..de9902ae2ebcb 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGLINE_H
#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGLINE_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/DIContext.h"
@@ -114,7 +113,7 @@ class DWARFDebugLine {
bool hasFileAtIndex(uint64_t FileIndex) const;
- Optional<uint64_t> getLastValidFileIndex() const;
+ std::optional<uint64_t> getLastValidFileIndex() const;
bool
getFileNameByIndex(uint64_t FileIndex, StringRef CompDir,
@@ -246,7 +245,7 @@ class DWARFDebugLine {
return Prologue.hasFileAtIndex(FileIndex);
}
- Optional<uint64_t> getLastValidFileIndex() const {
+ std::optional<uint64_t> getLastValidFileIndex() const {
return Prologue.getLastValidFileIndex();
}
@@ -294,7 +293,7 @@ class DWARFDebugLine {
private:
uint32_t findRowInSeq(const DWARFDebugLine::Sequence &Seq,
object::SectionedAddress Address) const;
- Optional<StringRef>
+ std::optional<StringRef>
getSourceByIndex(uint64_t FileIndex,
DILineInfoSpecifier::FileLineInfoKind Kind) const;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
index 90e009e514d4a..74638fc180b54 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
#include "llvm/Support/Errc.h"
@@ -66,14 +65,15 @@ class DWARFLocationTable {
/// can attempt to parse another list after the current one (\p Offset will be
/// updated to point past the end of the current list).
bool dumpLocationList(uint64_t *Offset, raw_ostream &OS,
- Optional<object::SectionedAddress> BaseAddr,
+ std::optional<object::SectionedAddress> BaseAddr,
const MCRegisterInfo *MRI, const DWARFObject &Obj,
DWARFUnit *U, DIDumpOptions DumpOpts,
unsigned Indent) const;
Error visitAbsoluteLocationList(
- uint64_t Offset, Optional<object::SectionedAddress> BaseAddr,
- std::function<Optional<object::SectionedAddress>(uint32_t)> LookupAddr,
+ uint64_t Offset, std::optional<object::SectionedAddress> BaseAddr,
+ std::function<std::optional<object::SectionedAddress>(uint32_t)>
+ LookupAddr,
function_ref<bool(Expected<DWARFLocationExpression>)> Callback) const;
const DWARFDataExtractor &getData() { return Data; }
@@ -111,7 +111,7 @@ class DWARFDebugLoc final : public DWARFLocationTable {
/// Print the location lists found within the debug_loc section.
void dump(raw_ostream &OS, const MCRegisterInfo *RegInfo,
const DWARFObject &Obj, DIDumpOptions DumpOpts,
- Optional<uint64_t> Offset) const;
+ std::optional<uint64_t> Offset) const;
Error visitLocationList(
uint64_t *Offset,
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
index 25be64d064bb6..cc32e7f241253 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
@@ -125,8 +125,8 @@ class DWARFDebugMacro {
private:
/// Parse the debug_macinfo/debug_macro section accessible via the 'MacroData'
/// parameter.
- Error parseImpl(Optional<DWARFUnitVector::compile_unit_range> Units,
- Optional<DataExtractor> StringExtractor,
+ Error parseImpl(std::optional<DWARFUnitVector::compile_unit_range> Units,
+ std::optional<DataExtractor> StringExtractor,
DWARFDataExtractor Data, bool IsMacro);
};
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
index f4aeac1bb9db0..02bb5f0a3d950 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
@@ -72,7 +72,7 @@ class DWARFDebugRangeList {
/// list. Has to be passed base address of the compile unit referencing this
/// range list.
DWARFAddressRangesVector
- getAbsoluteRanges(llvm::Optional<object::SectionedAddress> BaseAddr) const;
+ getAbsoluteRanges(std::optional<object::SectionedAddress> BaseAddr) const;
};
} // end namespace llvm
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
index 13f018f53fa14..8ddd9cab23644 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGRNGLISTS_H
#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGRNGLISTS_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
@@ -37,10 +36,11 @@ struct RangeListEntry : public DWARFListEntryBase {
uint64_t Value1;
Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr);
- void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength,
- uint64_t &CurrentBase, DIDumpOptions DumpOpts,
- llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)>
- LookupPooledAddress) const;
+ void
+ dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength,
+ uint64_t &CurrentBase, DIDumpOptions DumpOpts,
+ llvm::function_ref<std::optional<object::SectionedAddress>(uint32_t)>
+ LookupPooledAddress) const;
bool isSentinel() const { return EntryKind == dwarf::DW_RLE_end_of_list; }
};
@@ -48,15 +48,14 @@ struct RangeListEntry : public DWARFListEntryBase {
class DWARFDebugRnglist : public DWARFListType<RangeListEntry> {
public:
/// Build a DWARFAddressRangesVector from a rangelist.
- DWARFAddressRangesVector
- getAbsoluteRanges(Optional<object::SectionedAddress> BaseAddr,
- uint8_t AddressByteSize,
- function_ref<Optional<object::SectionedAddress>(uint32_t)>
- LookupPooledAddress) const;
+ DWARFAddressRangesVector getAbsoluteRanges(
+ std::optional<object::SectionedAddress> BaseAddr, uint8_t AddressByteSize,
+ function_ref<std::optional<object::SectionedAddress>(uint32_t)>
+ LookupPooledAddress) const;
/// Build a DWARFAddressRangesVector from a rangelist.
DWARFAddressRangesVector
- getAbsoluteRanges(llvm::Optional<object::SectionedAddress> BaseAddr,
+ getAbsoluteRanges(std::optional<object::SectionedAddress> BaseAddr,
DWARFUnit &U) const;
};
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
index 149c5ef4e4939..90f59138fc19d 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
@@ -10,7 +10,6 @@
#define LLVM_DEBUGINFO_DWARF_DWARFDIE_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/iterator.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/BinaryFormat/Dwarf.h"
@@ -139,7 +138,7 @@ class DWARFDie {
/// \param Attr the attribute to extract.
/// \returns an optional DWARFFormValue that will have the form value if the
/// attribute was successfully extracted.
- Optional<DWARFFormValue> find(dwarf::Attribute Attr) const;
+ std::optional<DWARFFormValue> find(dwarf::Attribute Attr) const;
/// Extract the first value of any attribute in Attrs from this DIE.
///
@@ -152,7 +151,7 @@ class DWARFDie {
/// \returns an optional that has a valid DWARFFormValue for the first
/// matching attribute in Attrs, or None if none of the attributes in Attrs
/// exist in this DIE.
- Optional<DWARFFormValue> find(ArrayRef<dwarf::Attribute> Attrs) const;
+ std::optional<DWARFFormValue> find(ArrayRef<dwarf::Attribute> Attrs) const;
/// Extract the first value of any attribute in Attrs from this DIE and
/// recurse into any DW_AT_specification or DW_AT_abstract_origin referenced
@@ -163,7 +162,7 @@ class DWARFDie {
/// matching attribute in Attrs, or None if none of the attributes in Attrs
/// exist in this DIE or in any DW_AT_specification or DW_AT_abstract_origin
/// DIEs.
- Optional<DWARFFormValue>
+ std::optional<DWARFFormValue>
findRecursively(ArrayRef<dwarf::Attribute> Attrs) const;
/// Extract the specified attribute from this DIE as the referenced DIE.
@@ -190,8 +189,8 @@ class DWARFDie {
/// or DW_AT_GNU_ranges_base attribute.
///
/// \returns anm optional absolute section offset value for the attribute.
- Optional<uint64_t> getRangesBaseAttribute() const;
- Optional<uint64_t> getLocBaseAttribute() const;
+ std::optional<uint64_t> getRangesBaseAttribute() const;
+ std::optional<uint64_t> getLocBaseAttribute() const;
/// Get the DW_AT_high_pc attribute value as an address.
///
@@ -203,7 +202,7 @@ class DWARFDie {
///
/// \param LowPC the low PC that might be needed to calculate the high PC.
/// \returns an optional address value for the attribute.
- Optional<uint64_t> getHighPC(uint64_t LowPC) const;
+ std::optional<uint64_t> getHighPC(uint64_t LowPC) const;
/// Retrieves DW_AT_low_pc and DW_AT_high_pc from CU.
/// Returns true if both attributes are present.
@@ -285,7 +284,7 @@ class DWARFDie {
/// \param PointerSize the pointer size of the containing CU.
/// \returns if this is a type DIE, or this DIE contains a DW_AT_type, returns
/// the size of the type.
- Optional<uint64_t> getTypeSize(uint64_t PointerSize);
+ std::optional<uint64_t> getTypeSize(uint64_t PointerSize);
class iterator;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
index 0c97893396601..6e5a16f635c82 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_DWARF_DWARFEXPRESSION_H
#define LLVM_DEBUGINFO_DWARF_DWARFEXPRESSION_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator.h"
#include "llvm/BinaryFormat/Dwarf.h"
@@ -102,7 +101,7 @@ class DWARFExpression {
private:
bool extract(DataExtractor Data, uint8_t AddressSize, uint64_t Offset,
- Optional<dwarf::DwarfFormat> Format);
+ std::optional<dwarf::DwarfFormat> Format);
};
/// An iterator to go through the expression operations.
@@ -140,7 +139,7 @@ class DWARFExpression {
};
DWARFExpression(DataExtractor Data, uint8_t AddressSize,
- Optional<dwarf::DwarfFormat> Format = std::nullopt)
+ std::optional<dwarf::DwarfFormat> Format = std::nullopt)
: Data(Data), AddressSize(AddressSize), Format(Format) {
assert(AddressSize == 8 || AddressSize == 4 || AddressSize == 2);
}
@@ -172,7 +171,7 @@ class DWARFExpression {
private:
DataExtractor Data;
uint8_t AddressSize;
- Optional<dwarf::DwarfFormat> Format;
+ std::optional<dwarf::DwarfFormat> Format;
};
inline bool operator==(const DWARFExpression::iterator &LHS,
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
index 4969e671609f5..e9944a1fbee62 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
@@ -11,7 +11,6 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/None.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/DIContext.h"
#include "llvm/Support/DataExtractor.h"
@@ -106,21 +105,21 @@ class DWARFFormValue {
/// getAsFoo functions below return the extracted value as Foo if only
/// DWARFFormValue has form class is suitable for representing Foo.
- Optional<uint64_t> getAsReference() const;
+ std::optional<uint64_t> getAsReference() const;
struct UnitOffset {
DWARFUnit *Unit;
uint64_t Offset;
};
- Optional<UnitOffset> getAsRelativeReference() const;
- Optional<uint64_t> getAsUnsignedConstant() const;
- Optional<int64_t> getAsSignedConstant() const;
+ std::optional<UnitOffset> getAsRelativeReference() const;
+ std::optional<uint64_t> getAsUnsignedConstant() const;
+ std::optional<int64_t> getAsSignedConstant() const;
Expected<const char *> getAsCString() const;
- Optional<uint64_t> getAsAddress() const;
- Optional<object::SectionedAddress> getAsSectionedAddress() const;
- Optional<uint64_t> getAsSectionOffset() const;
- Optional<ArrayRef<uint8_t>> getAsBlock() const;
- Optional<uint64_t> getAsCStringOffset() const;
- Optional<uint64_t> getAsReferenceUVal() const;
+ std::optional<uint64_t> getAsAddress() const;
+ std::optional<object::SectionedAddress> getAsSectionedAddress() const;
+ std::optional<uint64_t> getAsSectionOffset() const;
+ std::optional<ArrayRef<uint8_t>> getAsBlock() const;
+ std::optional<uint64_t> getAsCStringOffset() const;
+ std::optional<uint64_t> getAsReferenceUVal() const;
/// Correctly extract any file paths from a form value.
///
/// These attributes can be in the from DW_AT_decl_file or DW_AT_call_file
@@ -132,7 +131,7 @@ class DWARFFormValue {
///
/// \returns A valid string value on success, or llvm::None if the form class
/// is not FC_Constant, or if the file index is not valid.
- Optional<std::string>
+ std::optional<std::string>
getAsFile(DILineInfoSpecifier::FileLineInfoKind Kind) const;
/// Skip a form's value in \p DebugInfoData at the offset specified by
@@ -174,7 +173,8 @@ namespace dwarf {
/// \param V and optional DWARFFormValue to attempt to extract the value from.
/// \returns an optional value that contains a value if the form value
/// was valid and was a string.
-inline Optional<const char *> toString(const Optional<DWARFFormValue> &V) {
+inline std::optional<const char *>
+toString(const std::optional<DWARFFormValue> &V) {
if (!V)
return std::nullopt;
Expected<const char*> E = V->getAsCString();
@@ -190,7 +190,7 @@ inline Optional<const char *> toString(const Optional<DWARFFormValue> &V) {
/// \param V and optional DWARFFormValue to attempt to extract the value from.
/// \returns an optional value that contains a value if the form value
/// was valid and was a string.
-inline StringRef toStringRef(const Optional<DWARFFormValue> &V,
+inline StringRef toStringRef(const std::optional<DWARFFormValue> &V,
StringRef Default = {}) {
if (!V)
return Default;
@@ -210,7 +210,7 @@ inline StringRef toStringRef(const Optional<DWARFFormValue> &V,
/// \param Default the default value to return in case of failure.
/// \returns the string value or Default if the V doesn't have a value or the
/// form value's encoding wasn't a string.
-inline const char *toString(const Optional<DWARFFormValue> &V,
+inline const char *toString(const std::optional<DWARFFormValue> &V,
const char *Default) {
if (auto E = toString(V))
return *E;
@@ -222,7 +222,8 @@ inline const char *toString(const Optional<DWARFFormValue> &V,
/// \param V and optional DWARFFormValue to attempt to extract the value from.
/// \returns an optional value that contains a value if the form value
/// was valid and has a unsigned constant form.
-inline Optional<uint64_t> toUnsigned(const Optional<DWARFFormValue> &V) {
+inline std::optional<uint64_t>
+toUnsigned(const std::optional<DWARFFormValue> &V) {
if (V)
return V->getAsUnsignedConstant();
return std::nullopt;
@@ -234,7 +235,7 @@ inline Optional<uint64_t> toUnsigned(const Optional<DWARFFormValue> &V) {
/// \param Default the default value to return in case of failure.
/// \returns the extracted unsigned value or Default if the V doesn't have a
/// value or the form value's encoding wasn't an unsigned constant form.
-inline uint64_t toUnsigned(const Optional<DWARFFormValue> &V,
+inline uint64_t toUnsigned(const std::optional<DWARFFormValue> &V,
uint64_t Default) {
return toUnsigned(V).value_or(Default);
}
@@ -244,7 +245,8 @@ inline uint64_t toUnsigned(const Optional<DWARFFormValue> &V,
/// \param V and optional DWARFFormValue to attempt to extract the value from.
/// \returns an optional value that contains a value if the form value
/// was valid and has a reference form.
-inline Optional<uint64_t> toReference(const Optional<DWARFFormValue> &V) {
+inline std::optional<uint64_t>
+toReference(const std::optional<DWARFFormValue> &V) {
if (V)
return V->getAsReference();
return std::nullopt;
@@ -256,7 +258,7 @@ inline Optional<uint64_t> toReference(const Optional<DWARFFormValue> &V) {
/// \param Default the default value to return in case of failure.
/// \returns the extracted reference value or Default if the V doesn't have a
/// value or the form value's encoding wasn't a reference form.
-inline uint64_t toReference(const Optional<DWARFFormValue> &V,
+inline uint64_t toReference(const std::optional<DWARFFormValue> &V,
uint64_t Default) {
return toReference(V).value_or(Default);
}
@@ -266,7 +268,7 @@ inline uint64_t toReference(const Optional<DWARFFormValue> &V,
/// \param V and optional DWARFFormValue to attempt to extract the value from.
/// \returns an optional value that contains a value if the form value
/// was valid and has a signed constant form.
-inline Optional<int64_t> toSigned(const Optional<DWARFFormValue> &V) {
+inline std::optional<int64_t> toSigned(const std::optional<DWARFFormValue> &V) {
if (V)
return V->getAsSignedConstant();
return std::nullopt;
@@ -278,7 +280,8 @@ inline Optional<int64_t> toSigned(const Optional<DWARFFormValue> &V) {
/// \param Default the default value to return in case of failure.
/// \returns the extracted signed integer value or Default if the V doesn't
/// have a value or the form value's encoding wasn't a signed integer form.
-inline int64_t toSigned(const Optional<DWARFFormValue> &V, int64_t Default) {
+inline int64_t toSigned(const std::optional<DWARFFormValue> &V,
+ int64_t Default) {
return toSigned(V).value_or(Default);
}
@@ -287,14 +290,15 @@ inline int64_t toSigned(const Optional<DWARFFormValue> &V, int64_t Default) {
/// \param V and optional DWARFFormValue to attempt to extract the value from.
/// \returns an optional value that contains a value if the form value
/// was valid and has a address form.
-inline Optional<uint64_t> toAddress(const Optional<DWARFFormValue> &V) {
+inline std::optional<uint64_t>
+toAddress(const std::optional<DWARFFormValue> &V) {
if (V)
return V->getAsAddress();
return std::nullopt;
}
-inline Optional<object::SectionedAddress>
-toSectionedAddress(const Optional<DWARFFormValue> &V) {
+inline std::optional<object::SectionedAddress>
+toSectionedAddress(const std::optional<DWARFFormValue> &V) {
if (V)
return V->getAsSectionedAddress();
return std::nullopt;
@@ -306,7 +310,8 @@ toSectionedAddress(const Optional<DWARFFormValue> &V) {
/// \param Default the default value to return in case of failure.
/// \returns the extracted address value or Default if the V doesn't have a
/// value or the form value's encoding wasn't an address form.
-inline uint64_t toAddress(const Optional<DWARFFormValue> &V, uint64_t Default) {
+inline uint64_t toAddress(const std::optional<DWARFFormValue> &V,
+ uint64_t Default) {
return toAddress(V).value_or(Default);
}
@@ -315,7 +320,8 @@ inline uint64_t toAddress(const Optional<DWARFFormValue> &V, uint64_t Default) {
/// \param V and optional DWARFFormValue to attempt to extract the value from.
/// \returns an optional value that contains a value if the form value
/// was valid and has a section offset form.
-inline Optional<uint64_t> toSectionOffset(const Optional<DWARFFormValue> &V) {
+inline std::optional<uint64_t>
+toSectionOffset(const std::optional<DWARFFormValue> &V) {
if (V)
return V->getAsSectionOffset();
return std::nullopt;
@@ -327,7 +333,7 @@ inline Optional<uint64_t> toSectionOffset(const Optional<DWARFFormValue> &V) {
/// \param Default the default value to return in case of failure.
/// \returns the extracted section offset value or Default if the V doesn't
/// have a value or the form value's encoding wasn't a section offset form.
-inline uint64_t toSectionOffset(const Optional<DWARFFormValue> &V,
+inline uint64_t toSectionOffset(const std::optional<DWARFFormValue> &V,
uint64_t Default) {
return toSectionOffset(V).value_or(Default);
}
@@ -337,7 +343,8 @@ inline uint64_t toSectionOffset(const Optional<DWARFFormValue> &V,
/// \param V and optional DWARFFormValue to attempt to extract the value from.
/// \returns an optional value that contains a value if the form value
/// was valid and has a block form.
-inline Optional<ArrayRef<uint8_t>> toBlock(const Optional<DWARFFormValue> &V) {
+inline std::optional<ArrayRef<uint8_t>>
+toBlock(const std::optional<DWARFFormValue> &V) {
if (V)
return V->getAsBlock();
return std::nullopt;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
index e5fe14cfb19e2..d739d6c195df9 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
@@ -112,17 +112,18 @@ class DWARFListTableHeader {
void dump(DataExtractor Data, raw_ostream &OS,
DIDumpOptions DumpOpts = {}) const;
- Optional<uint64_t> getOffsetEntry(DataExtractor Data, uint32_t Index) const {
+ std::optional<uint64_t> getOffsetEntry(DataExtractor Data,
+ uint32_t Index) const {
if (Index >= HeaderData.OffsetEntryCount)
return std::nullopt;
return getOffsetEntry(Data, getHeaderOffset() + getHeaderSize(Format), Format, Index);
}
- static Optional<uint64_t> getOffsetEntry(DataExtractor Data,
- uint64_t OffsetTableOffset,
- dwarf::DwarfFormat Format,
- uint32_t Index) {
+ static std::optional<uint64_t> getOffsetEntry(DataExtractor Data,
+ uint64_t OffsetTableOffset,
+ dwarf::DwarfFormat Format,
+ uint32_t Index) {
uint8_t OffsetByteSize = Format == dwarf::DWARF64 ? 8 : 4;
uint64_t Offset = OffsetTableOffset + OffsetByteSize * Index;
auto R = Data.getUnsigned(&Offset, OffsetByteSize);
@@ -178,13 +179,15 @@ template <typename DWARFListType> class DWARFListTableBase {
uint32_t getOffsetEntryCount() const { return Header.getOffsetEntryCount(); }
dwarf::DwarfFormat getFormat() const { return Header.getFormat(); }
- void dump(DWARFDataExtractor Data, raw_ostream &OS,
- llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)>
- LookupPooledAddress,
- DIDumpOptions DumpOpts = {}) const;
+ void
+ dump(DWARFDataExtractor Data, raw_ostream &OS,
+ llvm::function_ref<std::optional<object::SectionedAddress>(uint32_t)>
+ LookupPooledAddress,
+ DIDumpOptions DumpOpts = {}) const;
/// Return the contents of the offset entry designated by a given index.
- Optional<uint64_t> getOffsetEntry(DataExtractor Data, uint32_t Index) const {
+ std::optional<uint64_t> getOffsetEntry(DataExtractor Data,
+ uint32_t Index) const {
return Header.getOffsetEntry(Data, Index);
}
/// Return the size of the table header including the length but not including
@@ -250,7 +253,7 @@ Error DWARFListType<ListEntryType>::extract(DWARFDataExtractor Data,
template <typename DWARFListType>
void DWARFListTableBase<DWARFListType>::dump(
DWARFDataExtractor Data, raw_ostream &OS,
- llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)>
+ llvm::function_ref<std::optional<object::SectionedAddress>(uint32_t)>
LookupPooledAddress,
DIDumpOptions DumpOpts) const {
Header.dump(Data, OS, DumpOpts);
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFLocationExpression.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFLocationExpression.h
index 35aa1a78e129f..b221f9cc92794 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFLocationExpression.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFLocationExpression.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H
#define LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H
-#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
namespace llvm {
@@ -23,7 +22,7 @@ struct DWARFLocationExpression {
/// The address range in which this expression is valid. None denotes a
/// default entry which is valid in addresses not covered by other location
/// expressions, or everywhere if there are no other expressions.
- Optional<DWARFAddressRange> Range;
+ std::optional<DWARFAddressRange> Range;
/// The expression itself.
SmallVector<uint8_t, 4> Expr;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
index fef59c5e95f8e..c5999a65c2a72 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
@@ -22,7 +22,7 @@ struct RelocAddrEntry {
uint64_t SectionIndex;
object::RelocationRef Reloc;
uint64_t SymbolValue;
- Optional<object::RelocationRef> Reloc2;
+ std::optional<object::RelocationRef> Reloc2;
uint64_t SymbolValue2;
object::RelocationResolver Resolver;
};
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
index 25ca5cc42720b..584cc55856935 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -10,7 +10,6 @@
#define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
@@ -64,7 +63,7 @@ class DWARFUnitHeader {
uint64_t TypeOffset = 0;
// For v5 split or skeleton compile units only.
- Optional<uint64_t> DWOId;
+ std::optional<uint64_t> DWOId;
// Unit type as parsed, or derived from the section kind.
uint8_t UnitType = 0;
@@ -93,7 +92,7 @@ class DWARFUnitHeader {
}
uint64_t getLength() const { return Length; }
uint64_t getAbbrOffset() const { return AbbrOffset; }
- Optional<uint64_t> getDWOId() const { return DWOId; }
+ std::optional<uint64_t> getDWOId() const { return DWOId; }
void setDWOId(uint64_t Id) {
assert((!DWOId || *DWOId == Id) && "setting DWOId to a
diff erent value");
DWOId = Id;
@@ -223,17 +222,18 @@ class DWARFUnit {
const DWARFSection &StringOffsetSection;
const DWARFSection *AddrOffsetSection;
DWARFUnit *SU;
- Optional<uint64_t> AddrOffsetSectionBase;
+ std::optional<uint64_t> AddrOffsetSectionBase;
bool IsLittleEndian;
bool IsDWO;
const DWARFUnitVector &UnitVector;
/// Start, length, and DWARF format of the unit's contribution to the string
/// offsets table (DWARF v5).
- Optional<StrOffsetsContributionDescriptor> StringOffsetsTableContribution;
+ std::optional<StrOffsetsContributionDescriptor>
+ StringOffsetsTableContribution;
mutable const DWARFAbbreviationDeclarationSet *Abbrevs;
- llvm::Optional<object::SectionedAddress> BaseAddr;
+ std::optional<object::SectionedAddress> BaseAddr;
/// The compile unit debug information entry items.
std::vector<DWARFDebugInfoEntry> DieArray;
@@ -287,14 +287,14 @@ class DWARFUnit {
/// Find the unit's contribution to the string offsets table and determine its
/// length and form. The given offset is expected to be derived from the unit
/// DIE's DW_AT_str_offsets_base attribute.
- Expected<Optional<StrOffsetsContributionDescriptor>>
+ Expected<std::optional<StrOffsetsContributionDescriptor>>
determineStringOffsetsTableContribution(DWARFDataExtractor &DA);
/// Find the unit's contribution to the string offsets table and determine its
/// length and form. The given offset is expected to be 0 in a dwo file or,
/// in a dwp file, the start of the unit's contribution to the string offsets
/// table section (as determined by the index table).
- Expected<Optional<StrOffsetsContributionDescriptor>>
+ Expected<std::optional<StrOffsetsContributionDescriptor>>
determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA);
public:
@@ -346,7 +346,7 @@ class DWARFUnit {
AddrOffsetSectionBase = Base;
}
- Optional<uint64_t> getAddrOffsetSectionBase() const {
+ std::optional<uint64_t> getAddrOffsetSectionBase() const {
return AddrOffsetSectionBase;
}
@@ -365,7 +365,7 @@ class DWARFUnit {
return LocSectionBase;
}
- Optional<object::SectionedAddress>
+ std::optional<object::SectionedAddress>
getAddrOffsetSectionItem(uint32_t Index) const;
Expected<uint64_t> getStringOffsetSectionItem(uint32_t Index) const;
@@ -385,7 +385,7 @@ class DWARFUnit {
DWARFDebugRangeList &RangeList) const;
void clear();
- const Optional<StrOffsetsContributionDescriptor> &
+ const std::optional<StrOffsetsContributionDescriptor> &
getStringOffsetsTableContribution() const {
return StringOffsetsTableContribution;
}
@@ -421,7 +421,7 @@ class DWARFUnit {
return false;
}
- llvm::Optional<object::SectionedAddress> getBaseAddress();
+ std::optional<object::SectionedAddress> getBaseAddress();
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) {
extractDIEsIfNeeded(ExtractUnitDIEOnly);
@@ -438,7 +438,7 @@ class DWARFUnit {
}
const char *getCompilationDir();
- Optional<uint64_t> getDWOId() {
+ std::optional<uint64_t> getDWOId() {
extractDIEsIfNeeded(/*CUDieOnly*/ true);
return getHeader().getDWOId();
}
@@ -456,9 +456,9 @@ class DWARFUnit {
/// Return a rangelist's offset based on an index. The index designates
/// an entry in the rangelist table's offset array and is supplied by
/// DW_FORM_rnglistx.
- Optional<uint64_t> getRnglistOffset(uint32_t Index);
+ std::optional<uint64_t> getRnglistOffset(uint32_t Index);
- Optional<uint64_t> getLoclistOffset(uint32_t Index);
+ std::optional<uint64_t> getLoclistOffset(uint32_t Index);
Expected<DWARFAddressRangesVector> collectAddressRanges();
@@ -514,7 +514,7 @@ class DWARFUnit {
/// Return the DIE object for a given offset \p Offset inside the
/// unit's DIE vector.
DWARFDie getDIEForOffset(uint64_t Offset) {
- if (Optional<uint32_t> DieIdx = getDIEIndexForOffset(Offset))
+ if (std::optional<uint32_t> DieIdx = getDIEIndexForOffset(Offset))
return DWARFDie(this, &DieArray[*DieIdx]);
return DWARFDie();
@@ -522,7 +522,7 @@ class DWARFUnit {
/// Return the DIE index for a given offset \p Offset inside the
/// unit's DIE vector.
- Optional<uint32_t> getDIEIndexForOffset(uint64_t Offset) {
+ std::optional<uint32_t> getDIEIndexForOffset(uint64_t Offset) {
extractDIEsIfNeeded(false);
auto It =
llvm::partition_point(DieArray, [=](const DWARFDebugInfoEntry &DIE) {
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h
index 1f1ebe943238a..b9ead366cb232 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_DWARF_DWARFVERIFIER_H
#define LLVM_DEBUGINFO_DWARF_DWARFVERIFIER_H
-#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/DIContext.h"
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
@@ -60,7 +59,7 @@ class DWARFVerifier {
/// This is used for finding overlapping ranges in the DW_AT_ranges
/// attribute of a DIE. It is also used as a set of address ranges that
/// children address ranges must all be contained in.
- Optional<DWARFAddressRange> insert(const DWARFAddressRange &R);
+ std::optional<DWARFAddressRange> insert(const DWARFAddressRange &R);
/// Inserts the address range info. If any of its ranges overlaps with a
/// range in an existing range info, the range info is *not* added and an
diff --git a/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h b/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
index d02184ff62eec..713e3c239e95f 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H
#define LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H
-#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/GSYM/ExtractRanges.h"
#include "llvm/DebugInfo/GSYM/InlineInfo.h"
#include "llvm/DebugInfo/GSYM/LineTable.h"
@@ -89,8 +88,8 @@ class GsymReader;
struct FunctionInfo {
AddressRange Range;
uint32_t Name; ///< String table offset in the string table.
- llvm::Optional<LineTable> OptLineTable;
- llvm::Optional<InlineInfo> Inline;
+ std::optional<LineTable> OptLineTable;
+ std::optional<InlineInfo> Inline;
FunctionInfo(uint64_t Addr = 0, uint64_t Size = 0, uint32_t N = 0)
: Range(Addr, Addr + Size), Name(N) {}
diff --git a/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h b/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
index 29ad1c18e295f..2eac8b43f006c 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
@@ -139,9 +139,9 @@ class GsymCreator {
DenseMap<llvm::gsym::FileEntry, uint32_t> FileEntryToIndex;
std::vector<llvm::gsym::FileEntry> Files;
std::vector<uint8_t> UUID;
- Optional<AddressRanges> ValidTextRanges;
+ std::optional<AddressRanges> ValidTextRanges;
AddressRanges Ranges;
- llvm::Optional<uint64_t> BaseAddress;
+ std::optional<uint64_t> BaseAddress;
bool Finalized = false;
bool Quiet;
@@ -249,7 +249,7 @@ class GsymCreator {
}
/// Get the valid text ranges.
- const Optional<AddressRanges> GetValidTextRanges() const {
+ const std::optional<AddressRanges> GetValidTextRanges() const {
return ValidTextRanges;
}
diff --git a/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h b/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h
index d026d9b85a58d..f2ac33be3bbe1 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h
@@ -138,7 +138,7 @@ class GsymReader {
/// \param Index An index into the file table.
/// \returns An optional FileInfo that will be valid if the file index is
/// valid, or llvm::None if the file index is out of bounds,
- Optional<FileEntry> getFile(uint32_t Index) const {
+ std::optional<FileEntry> getFile(uint32_t Index) const {
if (Index < Files.size())
return Files[Index];
return std::nullopt;
@@ -191,7 +191,7 @@ class GsymReader {
/// \param OS The output stream to dump to.
///
/// \param FE The object to dump.
- void dump(raw_ostream &OS, Optional<FileEntry> FE);
+ void dump(raw_ostream &OS, std::optional<FileEntry> FE);
/// Get the number of addresses in this Gsym file.
uint32_t getNumAddresses() const {
@@ -205,7 +205,7 @@ class GsymReader {
/// \param Index A index into the address table.
/// \returns A resolved virtual address for adddress in the address table
/// or llvm::None if Index is out of bounds.
- Optional<uint64_t> getAddress(size_t Index) const;
+ std::optional<uint64_t> getAddress(size_t Index) const;
protected:
@@ -237,8 +237,8 @@ class GsymReader {
/// \param Index An index into the AddrOffsets array.
/// \returns An virtual address that matches the original object file for the
/// address as the specified index, or llvm::None if Index is out of bounds.
- template <class T> Optional<uint64_t>
- addressForIndex(size_t Index) const {
+ template <class T>
+ std::optional<uint64_t> addressForIndex(size_t Index) const {
ArrayRef<T> AIO = getAddrOffsets<T>();
if (Index < AIO.size())
return AIO[Index] + Hdr->BaseAddress;
@@ -254,7 +254,8 @@ class GsymReader {
/// \returns The matching address offset index. This index will be used to
/// extract the FunctionInfo data's offset from the AddrInfoOffsets array.
template <class T>
- llvm::Optional<uint64_t> getAddressOffsetIndex(const uint64_t AddrOffset) const {
+ std::optional<uint64_t>
+ getAddressOffsetIndex(const uint64_t AddrOffset) const {
ArrayRef<T> AIO = getAddrOffsets<T>();
const auto Begin = AIO.begin();
const auto End = AIO.end();
@@ -301,7 +302,7 @@ class GsymReader {
/// \param Index An index into the address table.
/// \returns An optional GSYM data offset for the offset of the FunctionInfo
/// that needs to be decoded.
- Optional<uint64_t> getAddressInfoOffset(size_t Index) const;
+ std::optional<uint64_t> getAddressInfoOffset(size_t Index) const;
};
} // namespace gsym
diff --git a/llvm/include/llvm/DebugInfo/GSYM/InlineInfo.h b/llvm/include/llvm/DebugInfo/GSYM/InlineInfo.h
index 80385116598ad..03bc85396d99f 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/InlineInfo.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/InlineInfo.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_GSYM_INLINEINFO_H
#define LLVM_DEBUGINFO_GSYM_INLINEINFO_H
-#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/GSYM/ExtractRanges.h"
#include "llvm/DebugInfo/GSYM/LineEntry.h"
#include "llvm/DebugInfo/GSYM/LookupResult.h"
@@ -133,7 +132,7 @@ struct InlineInfo {
///
/// \returns optional vector of InlineInfo objects that describe the
/// inline call stack for a given address, false otherwise.
- llvm::Optional<InlineArray> getInlineStack(uint64_t Addr) const;
+ std::optional<InlineArray> getInlineStack(uint64_t Addr) const;
/// Decode an InlineInfo object from a binary data stream.
///
diff --git a/llvm/include/llvm/DebugInfo/GSYM/LineTable.h b/llvm/include/llvm/DebugInfo/GSYM/LineTable.h
index c0121a8787be8..a27019fc769da 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/LineTable.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/LineTable.h
@@ -170,7 +170,7 @@ class LineTable {
///
/// \returns An optional line entry with the first line entry if the line
/// table isn't empty, or llvm::None if the line table is emtpy.
- Optional<LineEntry> first() const {
+ std::optional<LineEntry> first() const {
if (Lines.empty())
return std::nullopt;
return Lines.front();
@@ -179,7 +179,7 @@ class LineTable {
///
/// \returns An optional line entry with the last line entry if the line
/// table isn't empty, or llvm::None if the line table is emtpy.
- Optional<LineEntry> last() const {
+ std::optional<LineEntry> last() const {
if (Lines.empty())
return std::nullopt;
return Lines.back();
diff --git a/llvm/include/llvm/DebugInfo/PDB/DIA/DIADataStream.h b/llvm/include/llvm/DebugInfo/PDB/DIA/DIADataStream.h
index f05b58c555074..d331ba68557ad 100644
--- a/llvm/include/llvm/DebugInfo/PDB/DIA/DIADataStream.h
+++ b/llvm/include/llvm/DebugInfo/PDB/DIA/DIADataStream.h
@@ -20,7 +20,7 @@ class DIADataStream : public IPDBDataStream {
uint32_t getRecordCount() const override;
std::string getName() const override;
- llvm::Optional<RecordType> getItemAtIndex(uint32_t Index) const override;
+ std::optional<RecordType> getItemAtIndex(uint32_t Index) const override;
bool getNext(RecordType &Record) override;
void reset() override;
diff --git a/llvm/include/llvm/DebugInfo/PDB/IPDBDataStream.h b/llvm/include/llvm/DebugInfo/PDB/IPDBDataStream.h
index 4d0589a879159..fb18396cafe31 100644
--- a/llvm/include/llvm/DebugInfo/PDB/IPDBDataStream.h
+++ b/llvm/include/llvm/DebugInfo/PDB/IPDBDataStream.h
@@ -9,9 +9,9 @@
#ifndef LLVM_DEBUGINFO_PDB_IPDBDATASTREAM_H
#define LLVM_DEBUGINFO_PDB_IPDBDATASTREAM_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include <cstdint>
+#include <optional>
#include <string>
namespace llvm {
@@ -28,7 +28,7 @@ class IPDBDataStream {
virtual uint32_t getRecordCount() const = 0;
virtual std::string getName() const = 0;
- virtual Optional<RecordType> getItemAtIndex(uint32_t Index) const = 0;
+ virtual std::optional<RecordType> getItemAtIndex(uint32_t Index) const = 0;
virtual bool getNext(RecordType &Record) = 0;
virtual void reset() = 0;
};
diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h b/llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
index 2f99aa942a056..9a84fc3e7c55c 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_PDB_NATIVE_DBISTREAMBUILDER_H
#define LLVM_DEBUGINFO_PDB_NATIVE_DBISTREAMBUILDER_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/COFF.h"
@@ -105,7 +104,7 @@ class DbiStreamBuilder {
msf::MSFBuilder &Msf;
BumpPtrAllocator &Allocator;
- Optional<PdbRaw_DbiVer> VerHeader;
+ std::optional<PdbRaw_DbiVer> VerHeader;
uint32_t Age;
uint16_t BuildNumber;
uint16_t PdbDllVersion;
@@ -120,7 +119,7 @@ class DbiStreamBuilder {
std::vector<std::unique_ptr<DbiModuleDescriptorBuilder>> ModiList;
- Optional<codeview::DebugFrameDataSubsection> NewFpoData;
+ std::optional<codeview::DebugFrameDataSubsection> NewFpoData;
std::vector<object::FpoData> OldFpoData;
StringMap<uint32_t> SourceFileNames;
@@ -130,7 +129,7 @@ class DbiStreamBuilder {
MutableBinaryByteStream FileInfoBuffer;
std::vector<SectionContrib> SectionContribs;
std::vector<SecMapEntry> SectionMap;
- std::array<Optional<DebugStream>, (int)DbgHeaderType::Max> DbgStreams;
+ std::array<std::optional<DebugStream>, (int)DbgHeaderType::Max> DbgStreams;
};
} // namespace pdb
}
diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/HashTable.h b/llvm/include/llvm/DebugInfo/PDB/Native/HashTable.h
index 69fcb4aa99941..eb03397ba6940 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Native/HashTable.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Native/HashTable.h
@@ -218,7 +218,7 @@ class HashTable {
const_iterator find_as(const Key &K, TraitsT &Traits) const {
uint32_t H = Traits.hashLookupKey(K) % capacity();
uint32_t I = H;
- Optional<uint32_t> FirstUnused;
+ std::optional<uint32_t> FirstUnused;
do {
if (isPresent(I)) {
if (Traits.storageKeyToLookupKey(Buckets[I].first) == K)
@@ -271,7 +271,7 @@ class HashTable {
/// from a real key to an internal key.
template <typename Key, typename TraitsT>
bool set_as_internal(const Key &K, ValueT V, TraitsT &Traits,
- Optional<uint32_t> InternalKey) {
+ std::optional<uint32_t> InternalKey) {
auto Entry = find_as(K, Traits);
if (Entry != end()) {
assert(isPresent(Entry.index()));
diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h b/llvm/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h
index 2d5088a3bd42d..4b77e321353f8 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_PDB_NATIVE_INFOSTREAMBUILDER_H
#define LLVM_DEBUGINFO_PDB_NATIVE_INFOSTREAMBUILDER_H
-#include "llvm/ADT/Optional.h"
#include "llvm/Support/Error.h"
#include "llvm/DebugInfo/CodeView/GUID.h"
@@ -46,7 +45,7 @@ class InfoStreamBuilder {
bool hashPDBContentsToGUID() const { return HashPDBContentsToGUID; }
uint32_t getAge() const { return Age; }
codeview::GUID getGuid() const { return Guid; }
- Optional<uint32_t> getSignature() const { return Signature; }
+ std::optional<uint32_t> getSignature() const { return Signature; }
uint32_t finalize();
@@ -61,7 +60,7 @@ class InfoStreamBuilder {
std::vector<PdbRaw_FeatureSig> Features;
PdbRaw_ImplVer Ver;
uint32_t Age;
- Optional<uint32_t> Signature;
+ std::optional<uint32_t> Signature;
codeview::GUID Guid;
bool HashPDBContentsToGUID = false;
diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h b/llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h
index c0d7229605409..834cd96b77b46 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_PDB_NATIVE_INPUTFILE_H
#define LLVM_DEBUGINFO_PDB_NATIVE_INPUTFILE_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/iterator.h"
@@ -149,7 +148,7 @@ class SymbolGroupIterator
bool isEnd() const;
uint32_t Index = 0;
- Optional<object::section_iterator> SectionIter;
+ std::optional<object::section_iterator> SectionIter;
SymbolGroup Value;
};
diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/LinePrinter.h b/llvm/include/llvm/DebugInfo/PDB/Native/LinePrinter.h
index 0db21309f593d..bb029e534c74e 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Native/LinePrinter.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Native/LinePrinter.h
@@ -30,10 +30,10 @@ struct FilterOptions {
std::list<std::string> IncludeCompilands;
uint32_t PaddingThreshold;
uint32_t SizeThreshold;
- llvm::Optional<uint32_t> DumpModi;
- llvm::Optional<uint32_t> ParentRecurseDepth;
- llvm::Optional<uint32_t> ChildrenRecurseDepth;
- llvm::Optional<uint32_t> SymbolOffset;
+ std::optional<uint32_t> DumpModi;
+ std::optional<uint32_t> ParentRecurseDepth;
+ std::optional<uint32_t> ChildrenRecurseDepth;
+ std::optional<uint32_t> SymbolOffset;
bool JustMyCode;
};
diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h b/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h
index 429c06f29ac7f..01f13ce1073e1 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEENUM_H
#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEENUM_H
-#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
@@ -65,9 +64,9 @@ class NativeTypeEnum : public NativeRawSymbol {
protected:
codeview::TypeIndex Index;
- Optional<codeview::EnumRecord> Record;
+ std::optional<codeview::EnumRecord> Record;
NativeTypeEnum *UnmodifiedType = nullptr;
- Optional<codeview::ModifierRecord> Modifiers;
+ std::optional<codeview::ModifierRecord> Modifiers;
};
} // namespace pdb
diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h b/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h
index 1f357754ac0f5..184e00086849c 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H
#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H
-#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
@@ -52,7 +51,7 @@ class NativeTypePointer : public NativeRawSymbol {
protected:
bool isMemberPointer() const;
codeview::TypeIndex TI;
- Optional<codeview::PointerRecord> Record;
+ std::optional<codeview::PointerRecord> Record;
};
} // namespace pdb
diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h b/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h
index a1dd39c0b4be4..79924a78cd218 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEUDT_H
#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEUDT_H
-#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
@@ -64,11 +63,11 @@ class NativeTypeUDT : public NativeRawSymbol {
protected:
codeview::TypeIndex Index;
- Optional<codeview::ClassRecord> Class;
- Optional<codeview::UnionRecord> Union;
+ std::optional<codeview::ClassRecord> Class;
+ std::optional<codeview::UnionRecord> Union;
NativeTypeUDT *UnmodifiedType = nullptr;
codeview::TagRecord *Tag = nullptr;
- Optional<codeview::ModifierRecord> Modifiers;
+ std::optional<codeview::ModifierRecord> Modifiers;
};
} // namespace pdb
diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h b/llvm/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h
index 9f320358144c4..855b5fe1f9311 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h
@@ -9,7 +9,6 @@
#ifndef LLVM_DEBUGINFO_PDB_NATIVE_TPISTREAMBUILDER_H
#define LLVM_DEBUGINFO_PDB_NATIVE_TPISTREAMBUILDER_H
-#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/CodeView/CVRecord.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
@@ -46,7 +45,7 @@ class TpiStreamBuilder {
TpiStreamBuilder &operator=(const TpiStreamBuilder &) = delete;
void setVersionHeader(PdbRaw_TpiVer Version);
- void addTypeRecord(ArrayRef<uint8_t> Type, Optional<uint32_t> Hash);
+ void addTypeRecord(ArrayRef<uint8_t> Type, std::optional<uint32_t> Hash);
void addTypeRecords(ArrayRef<uint8_t> Types, ArrayRef<uint16_t> Sizes,
ArrayRef<uint32_t> Hashes);
diff --git a/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h b/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
index 91748e15ba659..f799b0a4cde0a 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
@@ -14,7 +14,6 @@
#ifndef LLVM_DEBUGINFO_SYMBOLIZE_DIPRINTER_H
#define LLVM_DEBUGINFO_SYMBOLIZE_DIPRINTER_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/JSON.h"
#include <memory>
@@ -34,7 +33,7 @@ class SourceCode;
struct Request {
StringRef ModuleName;
- Optional<uint64_t> Address;
+ std::optional<uint64_t> Address;
};
class DIPrinter {
diff --git a/llvm/include/llvm/DebugInfo/Symbolize/Markup.h b/llvm/include/llvm/DebugInfo/Symbolize/Markup.h
index 0061d59976934..c6242267f1e25 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/Markup.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/Markup.h
@@ -16,7 +16,6 @@
#ifndef LLVM_DEBUGINFO_SYMBOLIZE_MARKUP_H
#define LLVM_DEBUGINFO_SYMBOLIZE_MARKUP_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
@@ -80,17 +79,17 @@ class MarkupParser {
/// previous call.
///
/// \returns the next markup node or None if none remain.
- Optional<MarkupNode> nextNode();
+ std::optional<MarkupNode> nextNode();
bool isSGR(const MarkupNode &Node) const {
return SGRSyntax.match(Node.Text);
}
private:
- Optional<MarkupNode> parseElement(StringRef Line);
+ std::optional<MarkupNode> parseElement(StringRef Line);
void parseTextOutsideMarkup(StringRef Text);
- Optional<StringRef> parseMultiLineBegin(StringRef Line);
- Optional<StringRef> parseMultiLineEnd(StringRef Line);
+ std::optional<StringRef> parseMultiLineBegin(StringRef Line);
+ std::optional<StringRef> parseMultiLineEnd(StringRef Line);
// Tags of elements that can span multiple lines.
const StringSet<> MultilineTags;
diff --git a/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h b/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
index 27c07f7942c7a..534255640075a 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
@@ -33,7 +33,7 @@ class LLVMSymbolizer;
class MarkupFilter {
public:
MarkupFilter(raw_ostream &OS, LLVMSymbolizer &Symbolizer,
- Optional<bool> ColorsEnabled = std::nullopt);
+ std::optional<bool> ColorsEnabled = std::nullopt);
/// Filters a line containing symbolizer markup and writes the human-readable
/// results to the output stream.
@@ -110,16 +110,16 @@ class MarkupFilter {
void printRawElement(const MarkupNode &Element);
void printValue(Twine Value);
- Optional<Module> parseModule(const MarkupNode &Element) const;
- Optional<MMap> parseMMap(const MarkupNode &Element) const;
+ std::optional<Module> parseModule(const MarkupNode &Element) const;
+ std::optional<MMap> parseMMap(const MarkupNode &Element) const;
- Optional<uint64_t> parseAddr(StringRef Str) const;
- Optional<uint64_t> parseModuleID(StringRef Str) const;
- Optional<uint64_t> parseSize(StringRef Str) const;
- Optional<SmallVector<uint8_t>> parseBuildID(StringRef Str) const;
- Optional<std::string> parseMode(StringRef Str) const;
- Optional<PCType> parsePCType(StringRef Str) const;
- Optional<uint64_t> parseFrameNumber(StringRef Str) const;
+ std::optional<uint64_t> parseAddr(StringRef Str) const;
+ std::optional<uint64_t> parseModuleID(StringRef Str) const;
+ std::optional<uint64_t> parseSize(StringRef Str) const;
+ std::optional<SmallVector<uint8_t>> parseBuildID(StringRef Str) const;
+ std::optional<std::string> parseMode(StringRef Str) const;
+ std::optional<PCType> parsePCType(StringRef Str) const;
+ std::optional<uint64_t> parseFrameNumber(StringRef Str) const;
bool checkTag(const MarkupNode &Node) const;
bool checkNumFields(const MarkupNode &Element, size_t Size) const;
@@ -147,10 +147,10 @@ class MarkupFilter {
// A module info line currently being built. This incorporates as much mmap
// information as possible before being emitted.
- Optional<ModuleInfoLine> MIL;
+ std::optional<ModuleInfoLine> MIL;
// SGR state.
- Optional<raw_ostream::Colors> Color;
+ std::optional<raw_ostream::Colors> Color;
bool Bold = false;
// Map from Module ID to Module.
diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp
index f6ea91a7b5917..a9bbe41125b18 100644
--- a/llvm/lib/BinaryFormat/Dwarf.cpp
+++ b/llvm/lib/BinaryFormat/Dwarf.cpp
@@ -365,7 +365,8 @@ unsigned llvm::dwarf::LanguageVendor(dwarf::SourceLanguage Lang) {
}
}
-Optional<unsigned> llvm::dwarf::LanguageLowerBound(dwarf::SourceLanguage Lang) {
+std::optional<unsigned>
+llvm::dwarf::LanguageLowerBound(dwarf::SourceLanguage Lang) {
switch (Lang) {
default:
return std::nullopt;
@@ -691,8 +692,8 @@ StringRef llvm::dwarf::IndexString(unsigned Idx) {
}
}
-Optional<uint8_t> llvm::dwarf::getFixedFormByteSize(dwarf::Form Form,
- FormParams Params) {
+std::optional<uint8_t> llvm::dwarf::getFixedFormByteSize(dwarf::Form Form,
+ FormParams Params) {
switch (Form) {
case DW_FORM_addr:
if (Params)
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index b9e44d023294e..a3777438bba38 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -730,7 +730,7 @@ void CodeViewDebug::emitTypeInformation() {
TypeRecordMapping typeMapping(CVMCOS);
Pipeline.addCallbackToPipeline(typeMapping);
- Optional<TypeIndex> B = Table.getFirst();
+ std::optional<TypeIndex> B = Table.getFirst();
while (B) {
// This will fail if the record data is invalid.
CVType Record = Table.getType(*B);
diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
index 617ddbd66e4e4..f324eada6a074 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -425,7 +425,7 @@ void DIEInteger::emitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
///
unsigned DIEInteger::sizeOf(const dwarf::FormParams &FormParams,
dwarf::Form Form) const {
- if (Optional<uint8_t> FixedSize =
+ if (std::optional<uint8_t> FixedSize =
dwarf::getFixedFormByteSize(Form, FormParams))
return *FixedSize;
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index e067828ed0795..b559f14fdc561 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -225,7 +225,8 @@ static void analyzeImportedModule(
SysRoot = CU.getSysRoot();
if (!SysRoot.empty() && Path.startswith(SysRoot))
return;
- Optional<const char*> Name = dwarf::toString(DIE.find(dwarf::DW_AT_name));
+ std::optional<const char *> Name =
+ dwarf::toString(DIE.find(dwarf::DW_AT_name));
if (!Name)
return;
auto &Entry = (*ParseableSwiftInterfaces)[*Name];
@@ -498,7 +499,7 @@ unsigned DWARFLinker::shouldKeepSubprogramDIE(
Flags |= TF_Keep;
- Optional<uint64_t> HighPc = DIE.getHighPC(*LowPc);
+ std::optional<uint64_t> HighPc = DIE.getHighPC(*LowPc);
if (!HighPc) {
reportWarning("Function without high_pc. Range will be discarded.\n", File,
&DIE);
@@ -882,7 +883,7 @@ void DWARFLinker::assignAbbrev(DIEAbbrev &Abbrev) {
unsigned DWARFLinker::DIECloner::cloneStringAttribute(
DIE &Die, AttributeSpec AttrSpec, const DWARFFormValue &Val,
const DWARFUnit &, OffsetsStringPool &StringPool, AttributesInfo &Info) {
- Optional<const char *> String = dwarf::toString(Val);
+ std::optional<const char *> String = dwarf::toString(Val);
if (!String)
return 0;
@@ -1107,7 +1108,7 @@ unsigned DWARFLinker::DIECloner::cloneAddressAttribute(
dwarf::Form Form = AttrSpec.Form;
uint64_t Addr = 0;
if (Form == dwarf::DW_FORM_addrx) {
- if (Optional<uint64_t> AddrOffsetSectionBase =
+ if (std::optional<uint64_t> AddrOffsetSectionBase =
Unit.getOrigUnit().getAddrOffsetSectionBase()) {
uint64_t StartOffset =
*AddrOffsetSectionBase +
@@ -1943,7 +1944,7 @@ uint32_t DWARFLinker::DIECloner::hashFullyQualifiedName(DWARFDie DIE,
const char *Name = nullptr;
DWARFUnit *OrigUnit = &U.getOrigUnit();
CompileUnit *CU = &U;
- Optional<DWARFFormValue> Ref;
+ std::optional<DWARFFormValue> Ref;
while (true) {
if (const char *CurrentName = DIE.getName(DINameKind::ShortName))
diff --git a/llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp b/llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp
index 1cb20c0bb948d..77d914aec79ab 100644
--- a/llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp
@@ -52,7 +52,7 @@ void CompileUnit::markEverythingAsKept() {
DIE.getTag() != dwarf::DW_TAG_constant)
continue;
- Optional<DWARFFormValue> Value;
+ std::optional<DWARFFormValue> Value;
if (!(Value = DIE.find(dwarf::DW_AT_location))) {
if ((Value = DIE.find(dwarf::DW_AT_const_value)) &&
!inFunctionScope(*this, I.ParentIdx))
diff --git a/llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp b/llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
index f0ffb41142f6e..dc32e83369272 100644
--- a/llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
+++ b/llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
@@ -29,14 +29,14 @@ AppendingTypeTableBuilder::AppendingTypeTableBuilder(BumpPtrAllocator &Storage)
AppendingTypeTableBuilder::~AppendingTypeTableBuilder() = default;
-Optional<TypeIndex> AppendingTypeTableBuilder::getFirst() {
+std::optional<TypeIndex> AppendingTypeTableBuilder::getFirst() {
if (empty())
return std::nullopt;
return TypeIndex(TypeIndex::FirstNonSimpleIndex);
}
-Optional<TypeIndex> AppendingTypeTableBuilder::getNext(TypeIndex Prev) {
+std::optional<TypeIndex> AppendingTypeTableBuilder::getNext(TypeIndex Prev) {
if (++Prev == nextTypeIndex())
return std::nullopt;
return Prev;
diff --git a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
index 5da300f710d5d..689c643a7006c 100644
--- a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
+++ b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
@@ -157,7 +157,7 @@ Error CVTypeVisitor::visitTypeStream(CVTypeRange Types) {
}
Error CVTypeVisitor::visitTypeStream(TypeCollection &Types) {
- Optional<TypeIndex> I = Types.getFirst();
+ std::optional<TypeIndex> I = Types.getFirst();
while (I) {
CVType Type = Types.getType(*I);
if (auto EC = visitTypeRecord(Type, *I))
diff --git a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
index a66f9af988358..55fafa8472d78 100644
--- a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
+++ b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
@@ -17,7 +17,7 @@
using namespace llvm;
using namespace llvm::codeview;
-Error CodeViewRecordIO::beginRecord(Optional<uint32_t> MaxLength) {
+Error CodeViewRecordIO::beginRecord(std::optional<uint32_t> MaxLength) {
RecordLimit Limit;
Limit.MaxLength = MaxLength;
Limit.BeginOffset = getCurrentOffset();
@@ -67,9 +67,9 @@ uint32_t CodeViewRecordIO::maxFieldLength() const {
// ever be at most 1 sub-record deep (in a FieldList), but this works for
// the general case.
uint32_t Offset = getCurrentOffset();
- Optional<uint32_t> Min = Limits.front().bytesRemaining(Offset);
+ std::optional<uint32_t> Min = Limits.front().bytesRemaining(Offset);
for (auto X : makeArrayRef(Limits).drop_front()) {
- Optional<uint32_t> ThisMin = X.bytesRemaining(Offset);
+ std::optional<uint32_t> ThisMin = X.bytesRemaining(Offset);
if (ThisMin)
Min = Min ? std::min(*Min, *ThisMin) : *ThisMin;
}
diff --git a/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp b/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
index a3dbb3954d5ce..fa59e7f9dba1b 100644
--- a/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
+++ b/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
@@ -147,7 +147,7 @@ void ContinuationRecordBuilder::insertSegmentEnd(uint32_t Offset) {
}
CVType ContinuationRecordBuilder::createSegmentRecord(
- uint32_t OffBegin, uint32_t OffEnd, Optional<TypeIndex> RefersTo) {
+ uint32_t OffBegin, uint32_t OffEnd, std::optional<TypeIndex> RefersTo) {
assert(OffEnd - OffBegin <= USHRT_MAX);
MutableArrayRef<uint8_t> Data = Buffer.data();
@@ -228,7 +228,7 @@ std::vector<CVType> ContinuationRecordBuilder::end(TypeIndex Index) {
uint32_t End = SegmentWriter.getOffset();
- Optional<TypeIndex> RefersTo;
+ std::optional<TypeIndex> RefersTo;
for (uint32_t Offset : reverse(SO)) {
Types.push_back(createSegmentRecord(Offset, End, RefersTo));
diff --git a/llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp b/llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
index 24e8b583201b9..1428d3038e779 100644
--- a/llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
+++ b/llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
@@ -32,14 +32,14 @@ GlobalTypeTableBuilder::GlobalTypeTableBuilder(BumpPtrAllocator &Storage)
GlobalTypeTableBuilder::~GlobalTypeTableBuilder() = default;
-Optional<TypeIndex> GlobalTypeTableBuilder::getFirst() {
+std::optional<TypeIndex> GlobalTypeTableBuilder::getFirst() {
if (empty())
return std::nullopt;
return TypeIndex(TypeIndex::FirstNonSimpleIndex);
}
-Optional<TypeIndex> GlobalTypeTableBuilder::getNext(TypeIndex Prev) {
+std::optional<TypeIndex> GlobalTypeTableBuilder::getNext(TypeIndex Prev) {
if (++Prev == nextTypeIndex())
return std::nullopt;
return Prev;
diff --git a/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp b/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
index 5e6a2e05d9374..28771bd805fc4 100644
--- a/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
+++ b/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
@@ -98,7 +98,7 @@ CVType LazyRandomTypeCollection::getType(TypeIndex Index) {
return Records[Index.toArrayIndex()].Type;
}
-Optional<CVType> LazyRandomTypeCollection::tryGetType(TypeIndex Index) {
+std::optional<CVType> LazyRandomTypeCollection::tryGetType(TypeIndex Index) {
if (Index.isSimple())
return std::nullopt;
@@ -202,7 +202,7 @@ Error LazyRandomTypeCollection::visitRangeForType(TypeIndex TI) {
return Error::success();
}
-Optional<TypeIndex> LazyRandomTypeCollection::getFirst() {
+std::optional<TypeIndex> LazyRandomTypeCollection::getFirst() {
TypeIndex TI = TypeIndex::fromArrayIndex(0);
if (auto EC = ensureTypeExists(TI)) {
consumeError(std::move(EC));
@@ -211,7 +211,7 @@ Optional<TypeIndex> LazyRandomTypeCollection::getFirst() {
return TI;
}
-Optional<TypeIndex> LazyRandomTypeCollection::getNext(TypeIndex Prev) {
+std::optional<TypeIndex> LazyRandomTypeCollection::getNext(TypeIndex Prev) {
// We can't be sure how long this type stream is, given that the initial count
// given to the constructor is just a hint. So just try to make sure the next
// record exists, and if anything goes wrong, we must be at the end.
diff --git a/llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp b/llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
index 70a1878d13b1e..24fe29192809a 100644
--- a/llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
+++ b/llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
@@ -33,14 +33,14 @@ MergingTypeTableBuilder::MergingTypeTableBuilder(BumpPtrAllocator &Storage)
MergingTypeTableBuilder::~MergingTypeTableBuilder() = default;
-Optional<TypeIndex> MergingTypeTableBuilder::getFirst() {
+std::optional<TypeIndex> MergingTypeTableBuilder::getFirst() {
if (empty())
return std::nullopt;
return TypeIndex(TypeIndex::FirstNonSimpleIndex);
}
-Optional<TypeIndex> MergingTypeTableBuilder::getNext(TypeIndex Prev) {
+std::optional<TypeIndex> MergingTypeTableBuilder::getNext(TypeIndex Prev) {
if (++Prev == nextTypeIndex())
return std::nullopt;
return Prev;
diff --git a/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp b/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
index 7f4511258c643..876def851e29d 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
@@ -236,7 +236,7 @@ Error TypeRecordMapping::visitTypeBegin(CVType &CVR) {
// FieldList and MethodList records can be any length because they can be
// split with continuation records. All other record types cannot be
// longer than the maximum record length.
- Optional<uint32_t> MaxLen;
+ std::optional<uint32_t> MaxLen;
if (CVR.kind() != TypeLeafKind::LF_FIELDLIST &&
CVR.kind() != TypeLeafKind::LF_METHODLIST)
MaxLen = MaxRecordLength - sizeof(RecordPrefix);
diff --git a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
index fdc649439682d..37b1c001c0bd5 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
@@ -79,7 +79,7 @@ class TypeStreamMerger {
Error mergeTypesAndIds(MergingTypeTableBuilder &DestIds,
MergingTypeTableBuilder &DestTypes,
const CVTypeArray &IdsAndTypes,
- Optional<PCHMergerInfo> &PCHInfo);
+ std::optional<PCHMergerInfo> &PCHInfo);
Error mergeIdRecords(MergingTypeTableBuilder &Dest,
ArrayRef<TypeIndex> TypeSourceToDest,
const CVTypeArray &Ids);
@@ -91,14 +91,14 @@ class TypeStreamMerger {
GlobalTypeTableBuilder &DestTypes,
const CVTypeArray &IdsAndTypes,
ArrayRef<GloballyHashedType> Hashes,
- Optional<PCHMergerInfo> &PCHInfo);
+ std::optional<PCHMergerInfo> &PCHInfo);
Error mergeIdRecords(GlobalTypeTableBuilder &Dest,
ArrayRef<TypeIndex> TypeSourceToDest,
const CVTypeArray &Ids,
ArrayRef<GloballyHashedType> Hashes);
Error mergeTypeRecords(GlobalTypeTableBuilder &Dest, const CVTypeArray &Types,
ArrayRef<GloballyHashedType> Hashes,
- Optional<PCHMergerInfo> &PCHInfo);
+ std::optional<PCHMergerInfo> &PCHInfo);
private:
Error doit(const CVTypeArray &Types);
@@ -198,7 +198,7 @@ class TypeStreamMerger {
/// its type indices.
SmallVector<uint8_t, 256> RemapStorage;
- Optional<PCHMergerInfo> PCHInfo;
+ std::optional<PCHMergerInfo> PCHInfo;
};
} // end anonymous namespace
@@ -258,10 +258,9 @@ Error TypeStreamMerger::mergeIdRecords(MergingTypeTableBuilder &Dest,
return doit(Ids);
}
-Error TypeStreamMerger::mergeTypesAndIds(MergingTypeTableBuilder &DestIds,
- MergingTypeTableBuilder &DestTypes,
- const CVTypeArray &IdsAndTypes,
- Optional<PCHMergerInfo> &PCHInfo) {
+Error TypeStreamMerger::mergeTypesAndIds(
+ MergingTypeTableBuilder &DestIds, MergingTypeTableBuilder &DestTypes,
+ const CVTypeArray &IdsAndTypes, std::optional<PCHMergerInfo> &PCHInfo) {
DestIdStream = &DestIds;
DestTypeStream = &DestTypes;
UseGlobalHashes = false;
@@ -271,10 +270,10 @@ Error TypeStreamMerger::mergeTypesAndIds(MergingTypeTableBuilder &DestIds,
}
// Global hashing entry points
-Error TypeStreamMerger::mergeTypeRecords(GlobalTypeTableBuilder &Dest,
- const CVTypeArray &Types,
- ArrayRef<GloballyHashedType> Hashes,
- Optional<PCHMergerInfo> &PCHInfo) {
+Error TypeStreamMerger::mergeTypeRecords(
+ GlobalTypeTableBuilder &Dest, const CVTypeArray &Types,
+ ArrayRef<GloballyHashedType> Hashes,
+ std::optional<PCHMergerInfo> &PCHInfo) {
DestGlobalTypeStream = &Dest;
UseGlobalHashes = true;
GlobalHashes = Hashes;
@@ -295,11 +294,10 @@ Error TypeStreamMerger::mergeIdRecords(GlobalTypeTableBuilder &Dest,
return doit(Ids);
}
-Error TypeStreamMerger::mergeTypesAndIds(GlobalTypeTableBuilder &DestIds,
- GlobalTypeTableBuilder &DestTypes,
- const CVTypeArray &IdsAndTypes,
- ArrayRef<GloballyHashedType> Hashes,
- Optional<PCHMergerInfo> &PCHInfo) {
+Error TypeStreamMerger::mergeTypesAndIds(
+ GlobalTypeTableBuilder &DestIds, GlobalTypeTableBuilder &DestTypes,
+ const CVTypeArray &IdsAndTypes, ArrayRef<GloballyHashedType> Hashes,
+ std::optional<PCHMergerInfo> &PCHInfo) {
DestGlobalIdStream = &DestIds;
DestGlobalTypeStream = &DestTypes;
UseGlobalHashes = true;
@@ -448,7 +446,7 @@ Error llvm::codeview::mergeIdRecords(MergingTypeTableBuilder &Dest,
Error llvm::codeview::mergeTypeAndIdRecords(
MergingTypeTableBuilder &DestIds, MergingTypeTableBuilder &DestTypes,
SmallVectorImpl<TypeIndex> &SourceToDest, const CVTypeArray &IdsAndTypes,
- Optional<PCHMergerInfo> &PCHInfo) {
+ std::optional<PCHMergerInfo> &PCHInfo) {
TypeStreamMerger M(SourceToDest);
return M.mergeTypesAndIds(DestIds, DestTypes, IdsAndTypes, PCHInfo);
}
@@ -456,7 +454,8 @@ Error llvm::codeview::mergeTypeAndIdRecords(
Error llvm::codeview::mergeTypeAndIdRecords(
GlobalTypeTableBuilder &DestIds, GlobalTypeTableBuilder &DestTypes,
SmallVectorImpl<TypeIndex> &SourceToDest, const CVTypeArray &IdsAndTypes,
- ArrayRef<GloballyHashedType> Hashes, Optional<PCHMergerInfo> &PCHInfo) {
+ ArrayRef<GloballyHashedType> Hashes,
+ std::optional<PCHMergerInfo> &PCHInfo) {
TypeStreamMerger M(SourceToDest);
return M.mergeTypesAndIds(DestIds, DestTypes, IdsAndTypes, Hashes, PCHInfo);
}
@@ -465,7 +464,7 @@ Error llvm::codeview::mergeTypeRecords(GlobalTypeTableBuilder &Dest,
SmallVectorImpl<TypeIndex> &SourceToDest,
const CVTypeArray &Types,
ArrayRef<GloballyHashedType> Hashes,
- Optional<PCHMergerInfo> &PCHInfo) {
+ std::optional<PCHMergerInfo> &PCHInfo) {
TypeStreamMerger M(SourceToDest);
return M.mergeTypeRecords(Dest, Types, Hashes, PCHInfo);
}
diff --git a/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp b/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
index 4cd19add06168..50ac6fc5906d3 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
@@ -21,13 +21,13 @@ TypeTableCollection::TypeTableCollection(ArrayRef<ArrayRef<uint8_t>> Records)
Names.resize(Records.size());
}
-Optional<TypeIndex> TypeTableCollection::getFirst() {
+std::optional<TypeIndex> TypeTableCollection::getFirst() {
if (empty())
return std::nullopt;
return TypeIndex::fromArrayIndex(0);
}
-Optional<TypeIndex> TypeTableCollection::getNext(TypeIndex Prev) {
+std::optional<TypeIndex> TypeTableCollection::getNext(TypeIndex Prev) {
assert(contains(Prev));
++Prev;
if (Prev.toArrayIndex() == size())
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
index fb2aa7b61983c..2b5995cb7f53f 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
@@ -69,7 +69,7 @@ DWARFAbbreviationDeclaration::extract(DataExtractor Data,
AttributeSpecs.push_back(AttributeSpec(A, F, V));
continue;
}
- Optional<uint8_t> ByteSize;
+ std::optional<uint8_t> ByteSize;
// If this abbrevation still has a fixed byte size, then update the
// FixedAttributeSize as needed.
switch (F) {
@@ -138,7 +138,7 @@ void DWARFAbbreviationDeclaration::dump(raw_ostream &OS) const {
OS << '\n';
}
-Optional<uint32_t>
+std::optional<uint32_t>
DWARFAbbreviationDeclaration::findAttributeIndex(dwarf::Attribute Attr) const {
for (uint32_t i = 0, e = AttributeSpecs.size(); i != e; ++i) {
if (AttributeSpecs[i].Attr == Attr)
@@ -164,7 +164,7 @@ uint64_t DWARFAbbreviationDeclaration::getAttributeOffsetFromIndex(
return Offset;
}
-Optional<DWARFFormValue>
+std::optional<DWARFFormValue>
DWARFAbbreviationDeclaration::getAttributeValueFromOffset(
uint32_t AttrIndex, uint64_t Offset, const DWARFUnit &U) const {
assert(AttributeSpecs.size() > AttrIndex &&
@@ -183,13 +183,13 @@ DWARFAbbreviationDeclaration::getAttributeValueFromOffset(
return std::nullopt;
}
-Optional<DWARFFormValue>
+std::optional<DWARFFormValue>
DWARFAbbreviationDeclaration::getAttributeValue(const uint64_t DIEOffset,
const dwarf::Attribute Attr,
const DWARFUnit &U) const {
// Check if this abbreviation has this attribute without needing to skip
// any data so we can return quickly if it doesn't.
- Optional<uint32_t> MatchAttrIndex = findAttributeIndex(Attr);
+ std::optional<uint32_t> MatchAttrIndex = findAttributeIndex(Attr);
if (!MatchAttrIndex)
return std::nullopt;
@@ -210,20 +210,20 @@ size_t DWARFAbbreviationDeclaration::FixedSizeInfo::getByteSize(
return ByteSize;
}
-Optional<int64_t> DWARFAbbreviationDeclaration::AttributeSpec::getByteSize(
+std::optional<int64_t> DWARFAbbreviationDeclaration::AttributeSpec::getByteSize(
const DWARFUnit &U) const {
if (isImplicitConst())
return 0;
if (ByteSize.HasByteSize)
return ByteSize.ByteSize;
- Optional<int64_t> S;
+ std::optional<int64_t> S;
auto FixedByteSize = dwarf::getFixedFormByteSize(Form, U.getFormParams());
if (FixedByteSize)
S = *FixedByteSize;
return S;
}
-Optional<size_t> DWARFAbbreviationDeclaration::getFixedAttributesByteSize(
+std::optional<size_t> DWARFAbbreviationDeclaration::getFixedAttributesByteSize(
const DWARFUnit &U) const {
if (FixedAttributeSize)
return FixedAttributeSize->getByteSize(U);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index 0e85160b57379..889d3f0915b04 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -143,8 +143,8 @@ void AppleAcceleratorTable::Header::dump(ScopedPrinter &W) const {
W.printNumber("HeaderData length", HeaderDataLength);
}
-Optional<uint64_t> AppleAcceleratorTable::HeaderData::extractOffset(
- Optional<DWARFFormValue> Value) const {
+std::optional<uint64_t> AppleAcceleratorTable::HeaderData::extractOffset(
+ std::optional<DWARFFormValue> Value) const {
if (!Value)
return std::nullopt;
@@ -185,7 +185,7 @@ bool AppleAcceleratorTable::dumpName(ScopedPrinter &W,
W.startLine() << format("Atom[%d]: ", i);
if (Atom.extractValue(AccelSection, DataOffset, FormParams)) {
Atom.dump(W.getOStream());
- if (Optional<uint64_t> Val = Atom.getAsUnsignedConstant()) {
+ if (std::optional<uint64_t> Val = Atom.getAsUnsignedConstant()) {
StringRef Str = dwarf::AtomValueString(HdrData.Atoms[i].first, *Val);
if (!Str.empty())
W.getOStream() << " (" << Str << ")";
@@ -272,7 +272,7 @@ void AppleAcceleratorTable::Entry::extract(
Atom.extractValue(AccelTable.AccelSection, Offset, FormParams);
}
-Optional<DWARFFormValue>
+std::optional<DWARFFormValue>
AppleAcceleratorTable::Entry::lookup(HeaderData::AtomType Atom) const {
assert(HdrData && "Dereferencing end iterator?");
assert(HdrData->Atoms.size() == Values.size());
@@ -283,19 +283,20 @@ AppleAcceleratorTable::Entry::lookup(HeaderData::AtomType Atom) const {
return std::nullopt;
}
-Optional<uint64_t> AppleAcceleratorTable::Entry::getDIESectionOffset() const {
+std::optional<uint64_t>
+AppleAcceleratorTable::Entry::getDIESectionOffset() const {
return HdrData->extractOffset(lookup(dwarf::DW_ATOM_die_offset));
}
-Optional<uint64_t> AppleAcceleratorTable::Entry::getCUOffset() const {
+std::optional<uint64_t> AppleAcceleratorTable::Entry::getCUOffset() const {
return HdrData->extractOffset(lookup(dwarf::DW_ATOM_cu_offset));
}
-Optional<dwarf::Tag> AppleAcceleratorTable::Entry::getTag() const {
- Optional<DWARFFormValue> Tag = lookup(dwarf::DW_ATOM_die_tag);
+std::optional<dwarf::Tag> AppleAcceleratorTable::Entry::getTag() const {
+ std::optional<DWARFFormValue> Tag = lookup(dwarf::DW_ATOM_die_tag);
if (!Tag)
return std::nullopt;
- if (Optional<uint64_t> Value = Tag->getAsUnsignedConstant())
+ if (std::optional<uint64_t> Value = Tag->getAsUnsignedConstant())
return dwarf::Tag(*Value);
return std::nullopt;
}
@@ -534,7 +535,7 @@ DWARFDebugNames::Entry::Entry(const NameIndex &NameIdx, const Abbrev &Abbr)
Values.emplace_back(Attr.Form);
}
-Optional<DWARFFormValue>
+std::optional<DWARFFormValue>
DWARFDebugNames::Entry::lookup(dwarf::Index Index) const {
assert(Abbr->Attributes.size() == Values.size());
for (auto Tuple : zip_first(Abbr->Attributes, Values)) {
@@ -544,14 +545,14 @@ DWARFDebugNames::Entry::lookup(dwarf::Index Index) const {
return std::nullopt;
}
-Optional<uint64_t> DWARFDebugNames::Entry::getDIEUnitOffset() const {
- if (Optional<DWARFFormValue> Off = lookup(dwarf::DW_IDX_die_offset))
+std::optional<uint64_t> DWARFDebugNames::Entry::getDIEUnitOffset() const {
+ if (std::optional<DWARFFormValue> Off = lookup(dwarf::DW_IDX_die_offset))
return Off->getAsReferenceUVal();
return std::nullopt;
}
-Optional<uint64_t> DWARFDebugNames::Entry::getCUIndex() const {
- if (Optional<DWARFFormValue> Off = lookup(dwarf::DW_IDX_compile_unit))
+std::optional<uint64_t> DWARFDebugNames::Entry::getCUIndex() const {
+ if (std::optional<DWARFFormValue> Off = lookup(dwarf::DW_IDX_compile_unit))
return Off->getAsUnsignedConstant();
// In a per-CU index, the entries without a DW_IDX_compile_unit attribute
// implicitly refer to the single CU.
@@ -560,8 +561,8 @@ Optional<uint64_t> DWARFDebugNames::Entry::getCUIndex() const {
return std::nullopt;
}
-Optional<uint64_t> DWARFDebugNames::Entry::getCUOffset() const {
- Optional<uint64_t> Index = getCUIndex();
+std::optional<uint64_t> DWARFDebugNames::Entry::getCUOffset() const {
+ std::optional<uint64_t> Index = getCUIndex();
if (!Index || *Index >= NameIdx->getCUCount())
return std::nullopt;
return NameIdx->getCUOffset(*Index);
@@ -683,7 +684,7 @@ bool DWARFDebugNames::NameIndex::dumpEntry(ScopedPrinter &W,
void DWARFDebugNames::NameIndex::dumpName(ScopedPrinter &W,
const NameTableEntry &NTE,
- Optional<uint32_t> Hash) const {
+ std::optional<uint32_t> Hash) const {
DictScope NameScope(W, ("Name " + Twine(NTE.getIndex())).str());
if (Hash)
W.printHex("Hash", *Hash);
@@ -793,7 +794,7 @@ LLVM_DUMP_METHOD void DWARFDebugNames::dump(raw_ostream &OS) const {
NI.dump(W);
}
-Optional<uint64_t>
+std::optional<uint64_t>
DWARFDebugNames::ValueIterator::findEntryOffsetInCurrentIndex() {
const Header &Hdr = CurrentIndex->Hdr;
if (Hdr.BucketCount == 0) {
@@ -837,7 +838,7 @@ bool DWARFDebugNames::ValueIterator::getEntryAtCurrentOffset() {
}
bool DWARFDebugNames::ValueIterator::findInCurrentIndex() {
- Optional<uint64_t> Offset = findEntryOffsetInCurrentIndex();
+ std::optional<uint64_t> Offset = findEntryOffsetInCurrentIndex();
if (!Offset)
return false;
DataOffset = *Offset;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index e1d74310a51a4..d7118b835a0da 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -103,7 +103,7 @@ static void dumpUUID(raw_ostream &OS, const ObjectFile &Obj) {
}
using ContributionCollection =
- std::vector<Optional<StrOffsetsContributionDescriptor>>;
+ std::vector<std::optional<StrOffsetsContributionDescriptor>>;
// Collect all the contributions to the string offsets table from all units,
// sort them by their starting offsets and remove duplicates.
@@ -117,8 +117,8 @@ collectContributionData(DWARFContext::unit_iterator_range Units) {
// the start of the contributions vector. This way they are reported
// first.
llvm::sort(Contributions,
- [](const Optional<StrOffsetsContributionDescriptor> &L,
- const Optional<StrOffsetsContributionDescriptor> &R) {
+ [](const std::optional<StrOffsetsContributionDescriptor> &L,
+ const std::optional<StrOffsetsContributionDescriptor> &R) {
if (L && R)
return L->Base < R->Base;
return R.has_value();
@@ -129,8 +129,8 @@ collectContributionData(DWARFContext::unit_iterator_range Units) {
// to report them more than once.
Contributions.erase(
std::unique(Contributions.begin(), Contributions.end(),
- [](const Optional<StrOffsetsContributionDescriptor> &L,
- const Optional<StrOffsetsContributionDescriptor> &R) {
+ [](const std::optional<StrOffsetsContributionDescriptor> &L,
+ const std::optional<StrOffsetsContributionDescriptor> &R) {
if (L && R)
return L->Base == R->Base && L->Size == R->Size;
return false;
@@ -245,7 +245,7 @@ static void dumpAddrSection(raw_ostream &OS, DWARFDataExtractor &AddrData,
// Dump the .debug_rnglists or .debug_rnglists.dwo section (DWARF v5).
static void dumpRnglistsSection(
raw_ostream &OS, DWARFDataExtractor &rnglistData,
- llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)>
+ llvm::function_ref<std::optional<object::SectionedAddress>(uint32_t)>
LookupPooledAddress,
DIDumpOptions DumpOpts) {
uint64_t Offset = 0;
@@ -312,7 +312,7 @@ static void dumpLoclistsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
DWARFDataExtractor Data,
const MCRegisterInfo *MRI,
const DWARFObject &Obj,
- Optional<uint64_t> DumpOffset) {
+ std::optional<uint64_t> DumpOffset) {
uint64_t Offset = 0;
while (Data.isValidOffset(Offset)) {
@@ -351,7 +351,7 @@ static void dumpPubTableSection(raw_ostream &OS, DIDumpOptions DumpOpts,
void DWARFContext::dump(
raw_ostream &OS, DIDumpOptions DumpOpts,
- std::array<Optional<uint64_t>, DIDT_ID_Count> DumpOffsets) {
+ std::array<std::optional<uint64_t>, DIDT_ID_Count> DumpOffsets) {
uint64_t DumpType = DumpOpts.DumpType;
StringRef Extension = sys::path::extension(DObj->getFileName());
@@ -368,7 +368,7 @@ void DWARFContext::dump(
bool Explicit = DumpType != DIDT_All && !IsDWO;
bool ExplicitDWO = Explicit && IsDWO;
auto shouldDump = [&](bool Explicit, const char *Name, unsigned ID,
- StringRef Section) -> Optional<uint64_t> * {
+ StringRef Section) -> std::optional<uint64_t> * {
unsigned Mask = 1U << ID;
bool Should = (DumpType & Mask) && (Explicit || !Section.empty());
if (!Should)
@@ -459,7 +459,7 @@ void DWARFContext::dump(
}
}
- if (const Optional<uint64_t> *Off =
+ if (const std::optional<uint64_t> *Off =
shouldDump(Explicit, ".debug_frame", DIDT_ID_DebugFrame,
DObj->getFrameSection().Data)) {
if (Expected<const DWARFDebugFrame *> DF = getDebugFrame())
@@ -468,7 +468,7 @@ void DWARFContext::dump(
RecoverableErrorHandler(DF.takeError());
}
- if (const Optional<uint64_t> *Off =
+ if (const std::optional<uint64_t> *Off =
shouldDump(Explicit, ".eh_frame", DIDT_ID_DebugFrame,
DObj->getEHFrameSection().Data)) {
if (Expected<const DWARFDebugFrame *> DF = getEHFrame())
@@ -519,7 +519,7 @@ void DWARFContext::dump(
auto DumpLineSection = [&](DWARFDebugLine::SectionParser Parser,
DIDumpOptions DumpOpts,
- Optional<uint64_t> DumpOffset) {
+ std::optional<uint64_t> DumpOffset) {
while (!Parser.done()) {
if (DumpOffset && Parser.getOffset() != *DumpOffset) {
Parser.skip(DumpOpts.WarningHandler, DumpOpts.WarningHandler);
@@ -612,7 +612,8 @@ void DWARFContext::dump(
}
}
- auto LookupPooledAddress = [&](uint32_t Index) -> Optional<SectionedAddress> {
+ auto LookupPooledAddress =
+ [&](uint32_t Index) -> std::optional<SectionedAddress> {
const auto &CUs = compile_units();
auto I = CUs.begin();
if (I == CUs.end())
@@ -712,7 +713,7 @@ DWARFTypeUnit *DWARFContext::getTypeUnitForHash(uint16_t Version, uint64_t Hash,
struct UnitContainers {
const DWARFUnitVector &Units;
- Optional<DenseMap<uint64_t, DWARFTypeUnit *>> ⤅
+ std::optional<DenseMap<uint64_t, DWARFTypeUnit *>> ⤅
};
UnitContainers Units = IsDWO ? UnitContainers{DWOUnits, DWOTypeUnits}
: UnitContainers{NormalUnits, NormalTypeUnits};
@@ -744,8 +745,8 @@ DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash(uint64_t Hash) {
for (const auto &DWOCU : dwo_compile_units()) {
// Might not have parsed DWO ID yet.
if (!DWOCU->getDWOId()) {
- if (Optional<uint64_t> DWOId =
- toUnsigned(DWOCU->getUnitDIE().find(DW_AT_GNU_dwo_id)))
+ if (std::optional<uint64_t> DWOId =
+ toUnsigned(DWOCU->getUnitDIE().find(DW_AT_GNU_dwo_id)))
DWOCU->setDWOId(*DWOId);
else
// No DWO ID?
@@ -1111,7 +1112,7 @@ static bool getFunctionNameAndStartLineForAddress(
DWARFCompileUnit *CU, uint64_t Address, FunctionNameKind Kind,
DILineInfoSpecifier::FileLineInfoKind FileNameKind,
std::string &FunctionName, std::string &StartFile, uint32_t &StartLine,
- Optional<uint64_t> &StartAddress) {
+ std::optional<uint64_t> &StartAddress) {
// The address may correspond to instruction in some inlined function,
// so we have to build the chain of inlined functions and take the
// name of the topmost function in it.
@@ -1141,9 +1142,9 @@ static bool getFunctionNameAndStartLineForAddress(
return FoundResult;
}
-static Optional<int64_t>
+static std::optional<int64_t>
getExpressionFrameOffset(ArrayRef<uint8_t> Expr,
- Optional<unsigned> FrameBaseReg) {
+ std::optional<unsigned> FrameBaseReg) {
if (!Expr.empty() &&
(Expr[0] == DW_OP_fbreg ||
(FrameBaseReg && Expr[0] == DW_OP_breg0 + *FrameBaseReg))) {
@@ -1168,9 +1169,9 @@ void DWARFContext::addLocalsForDie(DWARFCompileUnit *CU, DWARFDie Subprogram,
if (const char *Name = Subprogram.getSubroutineName(DINameKind::ShortName))
Local.FunctionName = Name;
- Optional<unsigned> FrameBaseReg;
+ std::optional<unsigned> FrameBaseReg;
if (auto FrameBase = Subprogram.find(DW_AT_frame_base))
- if (Optional<ArrayRef<uint8_t>> Expr = FrameBase->getAsBlock())
+ if (std::optional<ArrayRef<uint8_t>> Expr = FrameBase->getAsBlock())
if (!Expr->empty() && (*Expr)[0] >= DW_OP_reg0 &&
(*Expr)[0] <= DW_OP_reg31) {
FrameBaseReg = (*Expr)[0] - DW_OP_reg0;
@@ -1179,7 +1180,7 @@ void DWARFContext::addLocalsForDie(DWARFCompileUnit *CU, DWARFDie Subprogram,
if (Expected<std::vector<DWARFLocationExpression>> Loc =
Die.getLocations(DW_AT_location)) {
for (const auto &Entry : *Loc) {
- if (Optional<int64_t> FrameOffset =
+ if (std::optional<int64_t> FrameOffset =
getExpressionFrameOffset(Entry.Expr, FrameBaseReg)) {
Local.FrameOffset = *FrameOffset;
break;
@@ -1198,7 +1199,7 @@ void DWARFContext::addLocalsForDie(DWARFCompileUnit *CU, DWARFDie Subprogram,
Die.getAttributeValueAsReferencedDie(DW_AT_abstract_origin))
Die = Origin;
if (auto NameAttr = Die.find(DW_AT_name))
- if (Optional<const char *> Name = dwarf::toString(*NameAttr))
+ if (std::optional<const char *> Name = dwarf::toString(*NameAttr))
Local.Name = *Name;
if (auto Type = Die.getAttributeValueAsReferencedDie(DW_AT_type))
Local.Size = Type.getTypeSize(getCUAddrSize());
@@ -1285,7 +1286,7 @@ DILineInfoTable DWARFContext::getLineInfoForAddressRange(
uint32_t StartLine = 0;
std::string StartFileName;
std::string FunctionName(DILineInfo::BadString);
- Optional<uint64_t> StartAddress;
+ std::optional<uint64_t> StartAddress;
getFunctionNameAndStartLineForAddress(CU, Address.Address, Spec.FNKind,
Spec.FLIKind, FunctionName,
StartFileName, StartLine, StartAddress);
@@ -1846,9 +1847,9 @@ class DWARFObjInMemory final : public DWARFObject {
if (Supports && Supports(Reloc.getType())) {
auto I = Map->try_emplace(
Reloc.getOffset(),
- RelocAddrEntry{SymInfoOrErr->SectionIndex, Reloc,
- SymInfoOrErr->Address,
- Optional<object::RelocationRef>(), 0, Resolver});
+ RelocAddrEntry{
+ SymInfoOrErr->SectionIndex, Reloc, SymInfoOrErr->Address,
+ std::optional<object::RelocationRef>(), 0, Resolver});
// If we didn't successfully insert that's because we already had a
// relocation for that offset. Store it as a second relocation in the
// same RelocAddrEntry instead.
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
index ff6ed2b667561..97434b3cfab82 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
@@ -68,7 +68,7 @@ uint64_t DWARFDataExtractor::getRelocatedValue(uint32_t Size, uint64_t *Off,
return R;
}
-Optional<uint64_t>
+std::optional<uint64_t>
DWARFDataExtractor::getEncodedPointer(uint64_t *Offset, uint8_t Encoding,
uint64_t PCRelOffset) const {
if (Encoding == dwarf::DW_EH_PE_omit)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
index fa13491e83b9d..98eaf1a095d9f 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
@@ -177,9 +177,8 @@ Expected<uint64_t> DWARFDebugAddrTable::getAddrEntry(uint32_t Index) const {
Index, Offset);
}
-Optional<uint64_t> DWARFDebugAddrTable::getFullLength() const {
+std::optional<uint64_t> DWARFDebugAddrTable::getFullLength() const {
if (Length == 0)
return std::nullopt;
return Length + dwarf::getUnitLengthFieldByteSize(Format);
}
-
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
index e9b657ea8271b..2540291d0038a 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
@@ -63,13 +63,13 @@ UnwindLocation UnwindLocation::createAtCFAPlusOffset(int32_t Offset) {
UnwindLocation
UnwindLocation::createIsRegisterPlusOffset(uint32_t RegNum, int32_t Offset,
- Optional<uint32_t> AddrSpace) {
+ std::optional<uint32_t> AddrSpace) {
return {RegPlusOffset, RegNum, Offset, AddrSpace, false};
}
UnwindLocation
UnwindLocation::createAtRegisterPlusOffset(uint32_t RegNum, int32_t Offset,
- Optional<uint32_t> AddrSpace) {
+ std::optional<uint32_t> AddrSpace) {
return {RegPlusOffset, RegNum, Offset, AddrSpace, true};
}
@@ -571,7 +571,7 @@ Error UnwindTable::parseRows(const CFIProgram &CFIP, UnwindRow &Row,
llvm::Expected<uint64_t> RegNum = Inst.getOperandAsUnsigned(CFIP, 0);
if (!RegNum)
return RegNum.takeError();
- if (Optional<UnwindLocation> O =
+ if (std::optional<UnwindLocation> O =
InitialLocs->getRegisterLocation(*RegNum))
Row.getRegisterLocations().setRegisterLocation(*RegNum, *O);
else
@@ -1089,8 +1089,8 @@ Error DWARFDebugFrame::parse(DWARFDataExtractor Data) {
StringRef AugmentationData("");
uint32_t FDEPointerEncoding = DW_EH_PE_absptr;
uint32_t LSDAPointerEncoding = DW_EH_PE_omit;
- Optional<uint64_t> Personality;
- Optional<uint32_t> PersonalityEncoding;
+ std::optional<uint64_t> Personality;
+ std::optional<uint32_t> PersonalityEncoding;
if (IsEH) {
std::optional<uint64_t> AugmentationLength;
uint64_t StartAugmentationOffset;
@@ -1170,7 +1170,7 @@ Error DWARFDebugFrame::parse(DWARFDataExtractor Data) {
uint64_t CIEPointer = Id;
uint64_t InitialLocation = 0;
uint64_t AddressRange = 0;
- Optional<uint64_t> LSDAAddress;
+ std::optional<uint64_t> LSDAAddress;
CIE *Cie = CIEs[IsEH ? (StartStructureOffset - CIEPointer) : CIEPointer];
if (IsEH) {
@@ -1244,7 +1244,7 @@ FrameEntry *DWARFDebugFrame::getEntryAtOffset(uint64_t Offset) const {
void DWARFDebugFrame::dump(raw_ostream &OS, DIDumpOptions DumpOpts,
const MCRegisterInfo *MRI,
- Optional<uint64_t> Offset) const {
+ std::optional<uint64_t> Offset) const {
if (Offset) {
if (auto *Entry = getEntryAtOffset(*Offset))
Entry->dump(OS, DumpOpts, MRI, IsEH);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
index 7dbeebc2770f8..4cd22cda374a0 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
@@ -67,7 +67,8 @@ bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint64_t *OffsetPtr,
}
// See if all attributes in this DIE have fixed byte sizes. If so, we can
// just add this size to the offset to skip to the next DIE.
- if (Optional<size_t> FixedSize = AbbrevDecl->getFixedAttributesByteSize(U)) {
+ if (std::optional<size_t> FixedSize =
+ AbbrevDecl->getFixedAttributesByteSize(U)) {
*OffsetPtr += *FixedSize;
return true;
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 2bce28fe8a03f..5e56330ee732c 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -79,7 +79,8 @@ bool DWARFDebugLine::Prologue::hasFileAtIndex(uint64_t FileIndex) const {
return FileIndex != 0 && FileIndex <= FileNames.size();
}
-Optional<uint64_t> DWARFDebugLine::Prologue::getLastValidFileIndex() const {
+std::optional<uint64_t>
+DWARFDebugLine::Prologue::getLastValidFileIndex() const {
if (FileNames.empty())
return std::nullopt;
uint16_t DwarfVersion = getVersion();
@@ -717,8 +718,8 @@ DWARFDebugLine::ParsingState::handleSpecialOpcode(uint8_t Opcode,
/// Parse a ULEB128 using the specified \p Cursor. \returns the parsed value on
/// success, or None if \p Cursor is in a failing state.
template <typename T>
-static Optional<T> parseULEB128(DWARFDataExtractor &Data,
- DataExtractor::Cursor &Cursor) {
+static std::optional<T> parseULEB128(DWARFDataExtractor &Data,
+ DataExtractor::Cursor &Cursor) {
T Value = Data.getULEB128(Cursor);
if (Cursor)
return Value;
@@ -1005,7 +1006,7 @@ Error DWARFDebugLine::LineTable::parse(
// Takes a single unsigned LEB128 operand, multiplies it by the
// min_inst_length field of the prologue, and adds the
// result to the address register of the state machine.
- if (Optional<uint64_t> Operand =
+ if (std::optional<uint64_t> Operand =
parseULEB128<uint64_t>(TableData, Cursor)) {
uint64_t AddrOffset =
State.advanceAddr(*Operand, Opcode, OpcodeOffset);
@@ -1030,7 +1031,7 @@ Error DWARFDebugLine::LineTable::parse(
case DW_LNS_set_file:
// Takes a single unsigned LEB128 operand and stores it in the file
// register of the state machine.
- if (Optional<uint16_t> File =
+ if (std::optional<uint16_t> File =
parseULEB128<uint16_t>(TableData, Cursor)) {
State.Row.File = *File;
if (Verbose)
@@ -1041,7 +1042,7 @@ Error DWARFDebugLine::LineTable::parse(
case DW_LNS_set_column:
// Takes a single unsigned LEB128 operand and stores it in the
// column register of the state machine.
- if (Optional<uint16_t> Column =
+ if (std::optional<uint16_t> Column =
parseULEB128<uint16_t>(TableData, Cursor)) {
State.Row.Column = *Column;
if (Verbose)
@@ -1117,7 +1118,8 @@ Error DWARFDebugLine::LineTable::parse(
case DW_LNS_set_isa:
// Takes a single unsigned LEB128 operand and stores it in the
// ISA register of the state machine.
- if (Optional<uint8_t> Isa = parseULEB128<uint8_t>(TableData, Cursor)) {
+ if (std::optional<uint8_t> Isa =
+ parseULEB128<uint8_t>(TableData, Cursor)) {
State.Row.Isa = *Isa;
if (Verbose)
*OS << " (" << (uint64_t)State.Row.Isa << ")";
@@ -1135,7 +1137,7 @@ Error DWARFDebugLine::LineTable::parse(
uint8_t OpcodeLength = Prologue.StandardOpcodeLengths[Opcode - 1];
std::vector<uint64_t> Operands;
for (uint8_t I = 0; I < OpcodeLength; ++I) {
- if (Optional<uint64_t> Value =
+ if (std::optional<uint64_t> Value =
parseULEB128<uint64_t>(TableData, Cursor))
Operands.push_back(*Value);
else
@@ -1330,8 +1332,9 @@ bool DWARFDebugLine::LineTable::lookupAddressRangeImpl(
return true;
}
-Optional<StringRef> DWARFDebugLine::LineTable::getSourceByIndex(uint64_t FileIndex,
- FileLineInfoKind Kind) const {
+std::optional<StringRef>
+DWARFDebugLine::LineTable::getSourceByIndex(uint64_t FileIndex,
+ FileLineInfoKind Kind) const {
if (Kind == FileLineInfoKind::None || !Prologue.hasFileAtIndex(FileIndex))
return std::nullopt;
const FileNameEntry &Entry = Prologue.getFileNameEntry(FileIndex);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
index 6a44052e3474d..58c3889f2cc44 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
@@ -30,16 +30,17 @@ class DWARFObject;
namespace {
class DWARFLocationInterpreter {
- Optional<object::SectionedAddress> Base;
- std::function<Optional<object::SectionedAddress>(uint32_t)> LookupAddr;
+ std::optional<object::SectionedAddress> Base;
+ std::function<std::optional<object::SectionedAddress>(uint32_t)> LookupAddr;
public:
DWARFLocationInterpreter(
- Optional<object::SectionedAddress> Base,
- std::function<Optional<object::SectionedAddress>(uint32_t)> LookupAddr)
+ std::optional<object::SectionedAddress> Base,
+ std::function<std::optional<object::SectionedAddress>(uint32_t)>
+ LookupAddr)
: Base(Base), LookupAddr(std::move(LookupAddr)) {}
- Expected<Optional<DWARFLocationExpression>>
+ Expected<std::optional<DWARFLocationExpression>>
Interpret(const DWARFLocationEntry &E);
};
} // namespace
@@ -48,7 +49,7 @@ static Error createResolverError(uint32_t Index, unsigned Kind) {
return make_error<ResolverError>(Index, (dwarf::LoclistEntries)Kind);
}
-Expected<Optional<DWARFLocationExpression>>
+Expected<std::optional<DWARFLocationExpression>>
DWARFLocationInterpreter::Interpret(const DWARFLocationEntry &E) {
switch (E.Kind) {
case dwarf::DW_LLE_end_of_list:
@@ -60,10 +61,10 @@ DWARFLocationInterpreter::Interpret(const DWARFLocationEntry &E) {
return std::nullopt;
}
case dwarf::DW_LLE_startx_endx: {
- Optional<SectionedAddress> LowPC = LookupAddr(E.Value0);
+ std::optional<SectionedAddress> LowPC = LookupAddr(E.Value0);
if (!LowPC)
return createResolverError(E.Value0, E.Kind);
- Optional<SectionedAddress> HighPC = LookupAddr(E.Value1);
+ std::optional<SectionedAddress> HighPC = LookupAddr(E.Value1);
if (!HighPC)
return createResolverError(E.Value1, E.Kind);
return DWARFLocationExpression{
@@ -71,7 +72,7 @@ DWARFLocationInterpreter::Interpret(const DWARFLocationEntry &E) {
E.Loc};
}
case dwarf::DW_LLE_startx_length: {
- Optional<SectionedAddress> LowPC = LookupAddr(E.Value0);
+ std::optional<SectionedAddress> LowPC = LookupAddr(E.Value0);
if (!LowPC)
return createResolverError(E.Value0, E.Kind);
return DWARFLocationExpression{DWARFAddressRange{LowPC->Address,
@@ -120,21 +121,19 @@ static void dumpExpression(raw_ostream &OS, DIDumpOptions DumpOpts,
DWARFExpression(Extractor, AddressSize).print(OS, DumpOpts, MRI, U);
}
-bool DWARFLocationTable::dumpLocationList(uint64_t *Offset, raw_ostream &OS,
- Optional<SectionedAddress> BaseAddr,
- const MCRegisterInfo *MRI,
- const DWARFObject &Obj, DWARFUnit *U,
- DIDumpOptions DumpOpts,
- unsigned Indent) const {
+bool DWARFLocationTable::dumpLocationList(
+ uint64_t *Offset, raw_ostream &OS, std::optional<SectionedAddress> BaseAddr,
+ const MCRegisterInfo *MRI, const DWARFObject &Obj, DWARFUnit *U,
+ DIDumpOptions DumpOpts, unsigned Indent) const {
DWARFLocationInterpreter Interp(
- BaseAddr, [U](uint32_t Index) -> Optional<SectionedAddress> {
+ BaseAddr, [U](uint32_t Index) -> std::optional<SectionedAddress> {
if (U)
return U->getAddrOffsetSectionItem(Index);
return std::nullopt;
});
OS << format("0x%8.8" PRIx64 ": ", *Offset);
Error E = visitLocationList(Offset, [&](const DWARFLocationEntry &E) {
- Expected<Optional<DWARFLocationExpression>> Loc = Interp.Interpret(E);
+ Expected<std::optional<DWARFLocationExpression>> Loc = Interp.Interpret(E);
if (!Loc || DumpOpts.DisplayRawContents)
dumpRawEntry(E, OS, Indent, DumpOpts, Obj);
if (Loc && *Loc) {
@@ -170,12 +169,12 @@ bool DWARFLocationTable::dumpLocationList(uint64_t *Offset, raw_ostream &OS,
}
Error DWARFLocationTable::visitAbsoluteLocationList(
- uint64_t Offset, Optional<SectionedAddress> BaseAddr,
- std::function<Optional<SectionedAddress>(uint32_t)> LookupAddr,
+ uint64_t Offset, std::optional<SectionedAddress> BaseAddr,
+ std::function<std::optional<SectionedAddress>(uint32_t)> LookupAddr,
function_ref<bool(Expected<DWARFLocationExpression>)> Callback) const {
DWARFLocationInterpreter Interp(BaseAddr, std::move(LookupAddr));
return visitLocationList(&Offset, [&](const DWARFLocationEntry &E) {
- Expected<Optional<DWARFLocationExpression>> Loc = Interp.Interpret(E);
+ Expected<std::optional<DWARFLocationExpression>> Loc = Interp.Interpret(E);
if (!Loc)
return Callback(Loc.takeError());
if (*Loc)
@@ -186,7 +185,7 @@ Error DWARFLocationTable::visitAbsoluteLocationList(
void DWARFDebugLoc::dump(raw_ostream &OS, const MCRegisterInfo *MRI,
const DWARFObject &Obj, DIDumpOptions DumpOpts,
- Optional<uint64_t> DumpOffset) const {
+ std::optional<uint64_t> DumpOffset) const {
auto BaseAddr = std::nullopt;
unsigned Indent = 12;
if (DumpOffset) {
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
index 80daea64814a7..4d52046ba9ba9 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
@@ -105,8 +105,8 @@ void DWARFDebugMacro::dump(raw_ostream &OS) const {
}
Error DWARFDebugMacro::parseImpl(
- Optional<DWARFUnitVector::compile_unit_range> Units,
- Optional<DataExtractor> StringExtractor, DWARFDataExtractor Data,
+ std::optional<DWARFUnitVector::compile_unit_range> Units,
+ std::optional<DataExtractor> StringExtractor, DWARFDataExtractor Data,
bool IsMacro) {
uint64_t Offset = 0;
MacroList *M = nullptr;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
index cad3dcab8a7ea..db01719bed599 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
@@ -85,7 +85,7 @@ void DWARFDebugRangeList::dump(raw_ostream &OS) const {
}
DWARFAddressRangesVector DWARFDebugRangeList::getAbsoluteRanges(
- llvm::Optional<object::SectionedAddress> BaseAddr) const {
+ std::optional<object::SectionedAddress> BaseAddr) const {
DWARFAddressRangesVector Res;
// debug_addr can't use the max integer tombstone because that's used for the
// base address specifier entry - so use max-1.
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
index d12acca1962e6..b428c2adfe0b3 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
@@ -86,15 +86,15 @@ Error RangeListEntry::extract(DWARFDataExtractor Data, uint64_t *OffsetPtr) {
}
DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges(
- llvm::Optional<object::SectionedAddress> BaseAddr, DWARFUnit &U) const {
+ std::optional<object::SectionedAddress> BaseAddr, DWARFUnit &U) const {
return getAbsoluteRanges(
BaseAddr, U.getAddressByteSize(),
[&](uint32_t Index) { return U.getAddrOffsetSectionItem(Index); });
}
DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges(
- Optional<object::SectionedAddress> BaseAddr, uint8_t AddressByteSize,
- function_ref<Optional<object::SectionedAddress>(uint32_t)>
+ std::optional<object::SectionedAddress> BaseAddr, uint8_t AddressByteSize,
+ function_ref<std::optional<object::SectionedAddress>(uint32_t)>
LookupPooledAddress) const {
DWARFAddressRangesVector Res;
uint64_t Tombstone = dwarf::computeTombstoneAddress(AddressByteSize);
@@ -175,7 +175,7 @@ DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges(
void RangeListEntry::dump(
raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength,
uint64_t &CurrentBase, DIDumpOptions DumpOpts,
- llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)>
+ llvm::function_ref<std::optional<object::SectionedAddress>(uint32_t)>
LookupPooledAddress) const {
auto PrintRawEntry = [](raw_ostream &OS, const RangeListEntry &Entry,
uint8_t AddrSize, DIDumpOptions DumpOpts) {
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index d6f0ee4312e8a..9c94b5121a5bc 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -137,7 +137,7 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
if (Attr == DW_AT_decl_file || Attr == DW_AT_call_file) {
Color = HighlightColor::String;
if (const auto *LT = U->getContext().getLineTableForUnit(U)) {
- if (Optional<uint64_t> Val = FormValue.getAsUnsignedConstant()) {
+ if (std::optional<uint64_t> Val = FormValue.getAsUnsignedConstant()) {
if (LT->getFileNameByIndex(
*Val, U->getCompilationDir(),
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath,
@@ -147,13 +147,13 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
}
}
}
- } else if (Optional<uint64_t> Val = FormValue.getAsUnsignedConstant())
+ } else if (std::optional<uint64_t> Val = FormValue.getAsUnsignedConstant())
Name = AttributeValueString(Attr, *Val);
if (!Name.empty())
WithColor(OS, Color) << Name;
else if (Attr == DW_AT_decl_line || Attr == DW_AT_call_line) {
- if (Optional<uint64_t> Val = FormValue.getAsUnsignedConstant())
+ if (std::optional<uint64_t> Val = FormValue.getAsUnsignedConstant())
OS << *Val;
else
FormValue.dump(OS, DumpOpts);
@@ -207,7 +207,7 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
OS << '"';
}
} else if (Attr == DW_AT_APPLE_property_attribute) {
- if (Optional<uint64_t> OptVal = FormValue.getAsUnsignedConstant())
+ if (std::optional<uint64_t> OptVal = FormValue.getAsUnsignedConstant())
dumpApplePropertyAttribute(OS, *OptVal);
} else if (Attr == DW_AT_ranges) {
const DWARFObject &Obj = Die.getDwarfUnit()->getContext().getDWARFObj();
@@ -249,7 +249,7 @@ bool DWARFDie::isSubroutineDIE() const {
return Tag == DW_TAG_subprogram || Tag == DW_TAG_inlined_subroutine;
}
-Optional<DWARFFormValue> DWARFDie::find(dwarf::Attribute Attr) const {
+std::optional<DWARFFormValue> DWARFDie::find(dwarf::Attribute Attr) const {
if (!isValid())
return std::nullopt;
auto AbbrevDecl = getAbbreviationDeclarationPtr();
@@ -258,7 +258,7 @@ Optional<DWARFFormValue> DWARFDie::find(dwarf::Attribute Attr) const {
return std::nullopt;
}
-Optional<DWARFFormValue>
+std::optional<DWARFFormValue>
DWARFDie::find(ArrayRef<dwarf::Attribute> Attrs) const {
if (!isValid())
return std::nullopt;
@@ -272,7 +272,7 @@ DWARFDie::find(ArrayRef<dwarf::Attribute> Attrs) const {
return std::nullopt;
}
-Optional<DWARFFormValue>
+std::optional<DWARFFormValue>
DWARFDie::findRecursively(ArrayRef<dwarf::Attribute> Attrs) const {
SmallVector<DWARFDie, 3> Worklist;
Worklist.push_back(*this);
@@ -307,7 +307,7 @@ DWARFDie::findRecursively(ArrayRef<dwarf::Attribute> Attrs) const {
DWARFDie
DWARFDie::getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const {
- if (Optional<DWARFFormValue> F = find(Attr))
+ if (std::optional<DWARFFormValue> F = find(Attr))
return getAttributeValueAsReferencedDie(*F);
return DWARFDie();
}
@@ -328,7 +328,7 @@ DWARFDie::getAttributeValueAsReferencedDie(const DWARFFormValue &V) const {
DWARFDie DWARFDie::resolveTypeUnitReference() const {
if (auto Attr = find(DW_AT_signature)) {
- if (Optional<uint64_t> Sig = Attr->getAsReferenceUVal()) {
+ if (std::optional<uint64_t> Sig = Attr->getAsReferenceUVal()) {
if (DWARFTypeUnit *TU = U->getContext().getTypeUnitForHash(
U->getVersion(), *Sig, U->isDWOUnit()))
return TU->getDIEForOffset(TU->getTypeOffset() + TU->getOffset());
@@ -337,15 +337,15 @@ DWARFDie DWARFDie::resolveTypeUnitReference() const {
return *this;
}
-Optional<uint64_t> DWARFDie::getRangesBaseAttribute() const {
+std::optional<uint64_t> DWARFDie::getRangesBaseAttribute() const {
return toSectionOffset(find({DW_AT_rnglists_base, DW_AT_GNU_ranges_base}));
}
-Optional<uint64_t> DWARFDie::getLocBaseAttribute() const {
+std::optional<uint64_t> DWARFDie::getLocBaseAttribute() const {
return toSectionOffset(find(DW_AT_loclists_base));
}
-Optional<uint64_t> DWARFDie::getHighPC(uint64_t LowPC) const {
+std::optional<uint64_t> DWARFDie::getHighPC(uint64_t LowPC) const {
uint64_t Tombstone = dwarf::computeTombstoneAddress(U->getAddressByteSize());
if (LowPC == Tombstone)
return std::nullopt;
@@ -385,7 +385,7 @@ Expected<DWARFAddressRangesVector> DWARFDie::getAddressRanges() const {
if (getLowAndHighPC(LowPC, HighPC, Index))
return DWARFAddressRangesVector{{LowPC, HighPC, Index}};
- Optional<DWARFFormValue> Value = find(DW_AT_ranges);
+ std::optional<DWARFFormValue> Value = find(DW_AT_ranges);
if (Value) {
if (Value->getForm() == DW_FORM_rnglistx)
return U->findRnglistFromIndex(*Value->getAsSectionOffset());
@@ -409,12 +409,12 @@ bool DWARFDie::addressRangeContainsAddress(const uint64_t Address) const {
Expected<DWARFLocationExpressionsVector>
DWARFDie::getLocations(dwarf::Attribute Attr) const {
- Optional<DWARFFormValue> Location = find(Attr);
+ std::optional<DWARFFormValue> Location = find(Attr);
if (!Location)
return createStringError(inconvertibleErrorCode(), "No %s",
dwarf::AttributeString(Attr).data());
- if (Optional<uint64_t> Off = Location->getAsSectionOffset()) {
+ if (std::optional<uint64_t> Off = Location->getAsSectionOffset()) {
uint64_t Offset = *Off;
if (Location->getForm() == DW_FORM_loclistx) {
@@ -427,7 +427,7 @@ DWARFDie::getLocations(dwarf::Attribute Attr) const {
return U->findLoclistFromOffset(Offset);
}
- if (Optional<ArrayRef<uint8_t>> Expr = Location->getAsBlock()) {
+ if (std::optional<ArrayRef<uint8_t>> Expr = Location->getAsBlock()) {
return DWARFLocationExpressionsVector{
DWARFLocationExpression{std::nullopt, to_vector<4>(*Expr)}};
}
@@ -492,9 +492,9 @@ void DWARFDie::getCallerFrame(uint32_t &CallFile, uint32_t &CallLine,
CallDiscriminator = toUnsigned(find(DW_AT_GNU_discriminator), 0);
}
-Optional<uint64_t> DWARFDie::getTypeSize(uint64_t PointerSize) {
+std::optional<uint64_t> DWARFDie::getTypeSize(uint64_t PointerSize) {
if (auto SizeAttr = find(DW_AT_byte_size))
- if (Optional<uint64_t> Size = SizeAttr->getAsUnsignedConstant())
+ if (std::optional<uint64_t> Size = SizeAttr->getAsUnsignedConstant())
return Size;
switch (getTag()) {
@@ -521,7 +521,7 @@ Optional<uint64_t> DWARFDie::getTypeSize(uint64_t PointerSize) {
DWARFDie BaseType = getAttributeValueAsReferencedDie(DW_AT_type);
if (!BaseType)
return std::nullopt;
- Optional<uint64_t> BaseSize = BaseType.getTypeSize(PointerSize);
+ std::optional<uint64_t> BaseSize = BaseType.getTypeSize(PointerSize);
if (!BaseSize)
return std::nullopt;
uint64_t Size = *BaseSize;
@@ -530,11 +530,11 @@ Optional<uint64_t> DWARFDie::getTypeSize(uint64_t PointerSize) {
continue;
if (auto ElemCountAttr = Child.find(DW_AT_count))
- if (Optional<uint64_t> ElemCount =
+ if (std::optional<uint64_t> ElemCount =
ElemCountAttr->getAsUnsignedConstant())
Size *= *ElemCount;
if (auto UpperBoundAttr = Child.find(DW_AT_upper_bound))
- if (Optional<int64_t> UpperBound =
+ if (std::optional<int64_t> UpperBound =
UpperBoundAttr->getAsSignedConstant()) {
int64_t LowerBound = 0;
if (auto LowerBoundAttr = Child.find(DW_AT_lower_bound))
@@ -592,7 +592,7 @@ void DWARFDie::dump(raw_ostream &OS, unsigned Indent,
if (DumpOpts.Verbose) {
OS << format(" [%u] %c", abbrCode,
AbbrevDecl->hasChildren() ? '*' : ' ');
- if (Optional<uint32_t> ParentIdx = Die->getParentIdx())
+ if (std::optional<uint32_t> ParentIdx = Die->getParentIdx())
OS << format(" (0x%8.8" PRIx64 ")",
U->getDIEAtIndex(*ParentIdx).getOffset());
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp b/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
index b9d5ddd8ab9d9..061b656bf9aaa 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
@@ -119,7 +119,7 @@ static DWARFExpression::Operation::Description getOpDesc(unsigned OpCode) {
bool DWARFExpression::Operation::extract(DataExtractor Data,
uint8_t AddressSize, uint64_t Offset,
- Optional<DwarfFormat> Format) {
+ std::optional<DwarfFormat> Format) {
EndOffset = Offset;
Opcode = Data.getU8(&Offset);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
index 99b92f11cfdb8..5be55f26688b9 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -173,7 +173,7 @@ bool DWARFFormValue::skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
case DW_FORM_GNU_ref_alt:
case DW_FORM_GNU_strp_alt:
case DW_FORM_implicit_const:
- if (Optional<uint8_t> FixedSize =
+ if (std::optional<uint8_t> FixedSize =
dwarf::getFixedFormByteSize(Form, Params)) {
*OffsetPtr += *FixedSize;
return true;
@@ -427,7 +427,8 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
OS << "<invalid dwarf unit>";
break;
}
- Optional<object::SectionedAddress> A = U->getAddrOffsetSectionItem(UValue);
+ std::optional<object::SectionedAddress> A =
+ U->getAddrOffsetSectionItem(UValue);
if (!A || DumpOpts.Verbose)
AddrOS << format("indexed (%8.8x) address = ", (uint32_t)UValue);
if (A)
@@ -443,7 +444,8 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
}
uint32_t Index = UValue >> 32;
uint32_t Offset = UValue & 0xffffffff;
- Optional<object::SectionedAddress> A = U->getAddrOffsetSectionItem(Index);
+ std::optional<object::SectionedAddress> A =
+ U->getAddrOffsetSectionItem(Index);
if (!A || DumpOpts.Verbose)
AddrOS << format("indexed (%8.8x) + 0x%x address = ", Index, Offset);
if (A) {
@@ -666,13 +668,13 @@ Expected<const char *> DWARFFormValue::getAsCString() const {
inconvertibleErrorCode());
}
-Optional<uint64_t> DWARFFormValue::getAsAddress() const {
+std::optional<uint64_t> DWARFFormValue::getAsAddress() const {
if (auto SA = getAsSectionedAddress())
return SA->Address;
return std::nullopt;
}
-Optional<object::SectionedAddress>
+std::optional<object::SectionedAddress>
DWARFFormValue::getAsSectionedAddress() const {
if (!isFormClass(FC_Address))
return std::nullopt;
@@ -682,7 +684,8 @@ DWARFFormValue::getAsSectionedAddress() const {
uint32_t Index = AddrOffset ? (Value.uval >> 32) : Value.uval;
if (!U)
return std::nullopt;
- Optional<object::SectionedAddress> SA = U->getAddrOffsetSectionItem(Index);
+ std::optional<object::SectionedAddress> SA =
+ U->getAddrOffsetSectionItem(Index);
if (!SA)
return std::nullopt;
if (AddrOffset)
@@ -692,13 +695,14 @@ DWARFFormValue::getAsSectionedAddress() const {
return {{Value.uval, Value.SectionIndex}};
}
-Optional<uint64_t> DWARFFormValue::getAsReference() const {
+std::optional<uint64_t> DWARFFormValue::getAsReference() const {
if (auto R = getAsRelativeReference())
return R->Unit ? R->Unit->getOffset() + R->Offset : R->Offset;
return std::nullopt;
}
-Optional<DWARFFormValue::UnitOffset> DWARFFormValue::getAsRelativeReference() const {
+std::optional<DWARFFormValue::UnitOffset>
+DWARFFormValue::getAsRelativeReference() const {
if (!isFormClass(FC_Reference))
return std::nullopt;
switch (Form) {
@@ -719,20 +723,20 @@ Optional<DWARFFormValue::UnitOffset> DWARFFormValue::getAsRelativeReference() co
}
}
-Optional<uint64_t> DWARFFormValue::getAsSectionOffset() const {
+std::optional<uint64_t> DWARFFormValue::getAsSectionOffset() const {
if (!isFormClass(FC_SectionOffset))
return std::nullopt;
return Value.uval;
}
-Optional<uint64_t> DWARFFormValue::getAsUnsignedConstant() const {
+std::optional<uint64_t> DWARFFormValue::getAsUnsignedConstant() const {
if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) ||
Form == DW_FORM_sdata)
return std::nullopt;
return Value.uval;
}
-Optional<int64_t> DWARFFormValue::getAsSignedConstant() const {
+std::optional<int64_t> DWARFFormValue::getAsSignedConstant() const {
if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) ||
(Form == DW_FORM_udata &&
uint64_t(std::numeric_limits<int64_t>::max()) < Value.uval))
@@ -751,26 +755,26 @@ Optional<int64_t> DWARFFormValue::getAsSignedConstant() const {
}
}
-Optional<ArrayRef<uint8_t>> DWARFFormValue::getAsBlock() const {
+std::optional<ArrayRef<uint8_t>> DWARFFormValue::getAsBlock() const {
if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc) &&
Form != DW_FORM_data16)
return std::nullopt;
return makeArrayRef(Value.data, Value.uval);
}
-Optional<uint64_t> DWARFFormValue::getAsCStringOffset() const {
+std::optional<uint64_t> DWARFFormValue::getAsCStringOffset() const {
if (!isFormClass(FC_String) && Form == DW_FORM_string)
return std::nullopt;
return Value.uval;
}
-Optional<uint64_t> DWARFFormValue::getAsReferenceUVal() const {
+std::optional<uint64_t> DWARFFormValue::getAsReferenceUVal() const {
if (!isFormClass(FC_Reference))
return std::nullopt;
return Value.uval;
}
-Optional<std::string>
+std::optional<std::string>
DWARFFormValue::getAsFile(DILineInfoSpecifier::FileLineInfoKind Kind) const {
if (U == nullptr || !isFormClass(FC_Constant))
return std::nullopt;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
index aca0932e0f617..6a1423d37d9f2 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
@@ -19,19 +19,19 @@ void DWARFTypePrinter::appendArrayType(const DWARFDie &D) {
for (const DWARFDie &C : D.children()) {
if (C.getTag() != DW_TAG_subrange_type)
continue;
- Optional<uint64_t> LB;
- Optional<uint64_t> Count;
- Optional<uint64_t> UB;
- Optional<unsigned> DefaultLB;
- if (Optional<DWARFFormValue> L = C.find(DW_AT_lower_bound))
+ std::optional<uint64_t> LB;
+ std::optional<uint64_t> Count;
+ std::optional<uint64_t> UB;
+ std::optional<unsigned> DefaultLB;
+ if (std::optional<DWARFFormValue> L = C.find(DW_AT_lower_bound))
LB = L->getAsUnsignedConstant();
- if (Optional<DWARFFormValue> CountV = C.find(DW_AT_count))
+ if (std::optional<DWARFFormValue> CountV = C.find(DW_AT_count))
Count = CountV->getAsUnsignedConstant();
- if (Optional<DWARFFormValue> UpperV = C.find(DW_AT_upper_bound))
+ if (std::optional<DWARFFormValue> UpperV = C.find(DW_AT_upper_bound))
UB = UpperV->getAsUnsignedConstant();
- if (Optional<DWARFFormValue> LV =
+ if (std::optional<DWARFFormValue> LV =
D.getDwarfUnit()->getUnitDIE().find(DW_AT_language))
- if (Optional<uint64_t> LC = LV->getAsUnsignedConstant())
+ if (std::optional<uint64_t> LC = LV->getAsUnsignedConstant())
if ((DefaultLB =
LanguageLowerBound(static_cast<dwarf::SourceLanguage>(*LC))))
if (LB && *LB == *DefaultLB)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 77b2b68ef62fc..522357b7edc1b 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -204,7 +204,7 @@ DWARFDataExtractor DWARFUnit::getDebugInfoExtractor() const {
getAddressByteSize());
}
-Optional<object::SectionedAddress>
+std::optional<object::SectionedAddress>
DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const {
if (!AddrOffsetSectionBase) {
auto R = Context.info_section_units();
@@ -499,7 +499,8 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
return Error::success();
DWARFDie UnitDie(this, &DieArray[0]);
- if (Optional<uint64_t> DWOId = toUnsigned(UnitDie.find(DW_AT_GNU_dwo_id)))
+ if (std::optional<uint64_t> DWOId =
+ toUnsigned(UnitDie.find(DW_AT_GNU_dwo_id)))
Header.setDWOId(*DWOId);
if (!IsDWO) {
assert(AddrOffsetSectionBase == std::nullopt);
@@ -828,7 +829,7 @@ void DWARFUnit::updateVariableDieMap(DWARFDie Die) {
// exact address.
uint64_t GVSize = 1;
if (DWARFDie BaseType = Die.getAttributeValueAsReferencedDie(DW_AT_type))
- if (Optional<uint64_t> Size = Die.getTypeSize(getAddressByteSize()))
+ if (std::optional<uint64_t> Size = Die.getTypeSize(getAddressByteSize()))
GVSize = *Size;
if (Address != UINT64_MAX)
@@ -898,7 +899,7 @@ DWARFUnit::getParentEntry(const DWARFDebugInfoEntry *Die) const {
return nullptr;
assert(Die >= DieArray.data() && Die < DieArray.data() + DieArray.size());
- if (Optional<uint32_t> ParentIdx = Die->getParentIdx()) {
+ if (std::optional<uint32_t> ParentIdx = Die->getParentIdx()) {
assert(*ParentIdx < DieArray.size() &&
"ParentIdx is out of DieArray boundaries");
return getDebugInfoEntry(*ParentIdx);
@@ -920,7 +921,7 @@ DWARFUnit::getSiblingEntry(const DWARFDebugInfoEntry *Die) const {
return nullptr;
assert(Die >= DieArray.data() && Die < DieArray.data() + DieArray.size());
- if (Optional<uint32_t> SiblingIdx = Die->getSiblingIdx()) {
+ if (std::optional<uint32_t> SiblingIdx = Die->getSiblingIdx()) {
assert(*SiblingIdx < DieArray.size() &&
"SiblingIdx is out of DieArray boundaries");
return &DieArray[*SiblingIdx];
@@ -942,7 +943,7 @@ DWARFUnit::getPreviousSiblingEntry(const DWARFDebugInfoEntry *Die) const {
return nullptr;
assert(Die >= DieArray.data() && Die < DieArray.data() + DieArray.size());
- Optional<uint32_t> ParentIdx = Die->getParentIdx();
+ std::optional<uint32_t> ParentIdx = Die->getParentIdx();
if (!ParentIdx)
// Die is a root die, there is no previous sibling.
return nullptr;
@@ -1009,7 +1010,7 @@ DWARFUnit::getLastChildEntry(const DWARFDebugInfoEntry *Die) const {
if (!Die->hasChildren())
return nullptr;
- if (Optional<uint32_t> SiblingIdx = Die->getSiblingIdx()) {
+ if (std::optional<uint32_t> SiblingIdx = Die->getSiblingIdx()) {
assert(*SiblingIdx < DieArray.size() &&
"SiblingIdx is out of DieArray boundaries");
assert(DieArray[*SiblingIdx - 1].getTag() == dwarf::DW_TAG_null &&
@@ -1044,12 +1045,13 @@ const DWARFAbbreviationDeclarationSet *DWARFUnit::getAbbreviations() const {
return Abbrevs;
}
-llvm::Optional<object::SectionedAddress> DWARFUnit::getBaseAddress() {
+std::optional<object::SectionedAddress> DWARFUnit::getBaseAddress() {
if (BaseAddr)
return BaseAddr;
DWARFDie UnitDie = getUnitDIE();
- Optional<DWARFFormValue> PC = UnitDie.find({DW_AT_low_pc, DW_AT_entry_pc});
+ std::optional<DWARFFormValue> PC =
+ UnitDie.find({DW_AT_low_pc, DW_AT_entry_pc});
BaseAddr = toSectionedAddress(PC);
return BaseAddr;
}
@@ -1133,7 +1135,7 @@ parseDWARFStringOffsetsTableHeader(DWARFDataExtractor &DA,
return Desc.validateContributionSize(DA);
}
-Expected<Optional<StrOffsetsContributionDescriptor>>
+Expected<std::optional<StrOffsetsContributionDescriptor>>
DWARFUnit::determineStringOffsetsTableContribution(DWARFDataExtractor &DA) {
assert(!IsDWO);
auto OptOffset = toSectionOffset(getUnitDIE().find(DW_AT_str_offsets_base));
@@ -1146,8 +1148,8 @@ DWARFUnit::determineStringOffsetsTableContribution(DWARFDataExtractor &DA) {
return *DescOrError;
}
-Expected<Optional<StrOffsetsContributionDescriptor>>
-DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor & DA) {
+Expected<std::optional<StrOffsetsContributionDescriptor>>
+DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA) {
assert(IsDWO);
uint64_t Offset = 0;
auto IndexEntry = Header.getIndexEntry();
@@ -1183,19 +1185,19 @@ DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor & DA) {
return *DescOrError;
}
-Optional<uint64_t> DWARFUnit::getRnglistOffset(uint32_t Index) {
+std::optional<uint64_t> DWARFUnit::getRnglistOffset(uint32_t Index) {
DataExtractor RangesData(RangeSection->Data, IsLittleEndian,
getAddressByteSize());
DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
IsLittleEndian, 0);
- if (Optional<uint64_t> Off = llvm::DWARFListTableHeader::getOffsetEntry(
+ if (std::optional<uint64_t> Off = llvm::DWARFListTableHeader::getOffsetEntry(
RangesData, RangeSectionBase, getFormat(), Index))
return *Off + RangeSectionBase;
return std::nullopt;
}
-Optional<uint64_t> DWARFUnit::getLoclistOffset(uint32_t Index) {
- if (Optional<uint64_t> Off = llvm::DWARFListTableHeader::getOffsetEntry(
+std::optional<uint64_t> DWARFUnit::getLoclistOffset(uint32_t Index) {
+ if (std::optional<uint64_t> Off = llvm::DWARFListTableHeader::getOffsetEntry(
LocTable->getData(), LocSectionBase, getFormat(), Index))
return *Off + LocSectionBase;
return std::nullopt;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index 26e92781c5fdd..20cd0560333eb 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -43,7 +43,7 @@ namespace llvm {
class DWARFDebugInfoEntry;
}
-Optional<DWARFAddressRange>
+std::optional<DWARFAddressRange>
DWARFVerifier::DieRangeInfo::insert(const DWARFAddressRange &R) {
auto Begin = Ranges.begin();
auto End = Ranges.end();
@@ -284,11 +284,10 @@ unsigned DWARFVerifier::verifyDebugInfoCallSite(const DWARFDie &Die) {
return 1;
}
- Optional<DWARFFormValue> CallAttr =
- Curr.find({DW_AT_call_all_calls, DW_AT_call_all_source_calls,
- DW_AT_call_all_tail_calls, DW_AT_GNU_all_call_sites,
- DW_AT_GNU_all_source_call_sites,
- DW_AT_GNU_all_tail_call_sites});
+ std::optional<DWARFFormValue> CallAttr = Curr.find(
+ {DW_AT_call_all_calls, DW_AT_call_all_source_calls,
+ DW_AT_call_all_tail_calls, DW_AT_GNU_all_call_sites,
+ DW_AT_GNU_all_source_call_sites, DW_AT_GNU_all_tail_call_sites});
if (!CallAttr) {
error() << "Subprogram with call site entry has no DW_AT_call attribute:";
Curr.dump(OS);
@@ -679,7 +678,8 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
if (LT) {
if (!LT->hasFileAtIndex(*FileIdx)) {
bool IsZeroIndexed = LT->Prologue.getVersion() >= 5;
- if (Optional<uint64_t> LastFileIdx = LT->getLastValidFileIndex()) {
+ if (std::optional<uint64_t> LastFileIdx =
+ LT->getLastValidFileIndex()) {
ReportError("DIE has " + AttributeString(Attr) +
" with an invalid file index " +
llvm::formatv("{0}", *FileIdx) +
@@ -732,7 +732,7 @@ unsigned DWARFVerifier::verifyDebugInfoForm(const DWARFDie &Die,
case DW_FORM_ref8:
case DW_FORM_ref_udata: {
// Verify all CU relative references are valid CU offsets.
- Optional<uint64_t> RefVal = AttrValue.Value.getAsReference();
+ std::optional<uint64_t> RefVal = AttrValue.Value.getAsReference();
assert(RefVal);
if (RefVal) {
auto CUSize = DieCU->getNextUnitOffset() - DieCU->getOffset();
@@ -756,7 +756,7 @@ unsigned DWARFVerifier::verifyDebugInfoForm(const DWARFDie &Die,
case DW_FORM_ref_addr: {
// Verify all absolute DIE references have valid offsets in the
// .debug_info section.
- Optional<uint64_t> RefVal = AttrValue.Value.getAsReference();
+ std::optional<uint64_t> RefVal = AttrValue.Value.getAsReference();
assert(RefVal);
if (RefVal) {
if (*RefVal >= DieCU->getInfoSection().Data.size()) {
diff --git a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
index b7e03e9885a37..d266960ae3024 100644
--- a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
+++ b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
@@ -429,7 +429,7 @@ Error DwarfTransformer::convert(uint32_t NumThreads) {
size_t NumBefore = Gsym.getNumFunctionInfos();
auto getDie = [&](DWARFUnit &DwarfUnit) -> DWARFDie {
DWARFDie ReturnDie = DwarfUnit.getUnitDIE(false);
- if (llvm::Optional<uint64_t> DWOId = DwarfUnit.getDWOId()) {
+ if (std::optional<uint64_t> DWOId = DwarfUnit.getDWOId()) {
DWARFUnit *DWOCU = DwarfUnit.getNonSkeletonUnitDIE(false).getDwarfUnit();
if (!DWOCU->isDWOUnit()) {
std::string DWOName = dwarf::toString(
diff --git a/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp b/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp
index b7d711d0f875a..51058fc09cf19 100644
--- a/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp
+++ b/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp
@@ -227,7 +227,7 @@ llvm::Expected<LookupResult> FunctionInfo::lookup(DataExtractor &Data,
return LR;
}
- Optional<FileEntry> LineEntryFile = GR.getFile(LineEntry->File);
+ std::optional<FileEntry> LineEntryFile = GR.getFile(LineEntry->File);
if (!LineEntryFile)
return createStringError(std::errc::invalid_argument,
"failed to extract file[%" PRIu32 "]",
diff --git a/llvm/lib/DebugInfo/GSYM/GsymReader.cpp b/llvm/lib/DebugInfo/GSYM/GsymReader.cpp
index 352af91fa9574..6afaeea8f598e 100644
--- a/llvm/lib/DebugInfo/GSYM/GsymReader.cpp
+++ b/llvm/lib/DebugInfo/GSYM/GsymReader.cpp
@@ -206,7 +206,7 @@ const Header &GsymReader::getHeader() const {
return *Hdr;
}
-Optional<uint64_t> GsymReader::getAddress(size_t Index) const {
+std::optional<uint64_t> GsymReader::getAddress(size_t Index) const {
switch (Hdr->AddrOffSize) {
case 1: return addressForIndex<uint8_t>(Index);
case 2: return addressForIndex<uint16_t>(Index);
@@ -216,7 +216,7 @@ Optional<uint64_t> GsymReader::getAddress(size_t Index) const {
return std::nullopt;
}
-Optional<uint64_t> GsymReader::getAddressInfoOffset(size_t Index) const {
+std::optional<uint64_t> GsymReader::getAddressInfoOffset(size_t Index) const {
const auto NumAddrInfoOffsets = AddrInfoOffsets.size();
if (Index < NumAddrInfoOffsets)
return AddrInfoOffsets[Index];
@@ -227,7 +227,7 @@ Expected<uint64_t>
GsymReader::getAddressIndex(const uint64_t Addr) const {
if (Addr >= Hdr->BaseAddress) {
const uint64_t AddrOffset = Addr - Hdr->BaseAddress;
- Optional<uint64_t> AddrOffsetIndex;
+ std::optional<uint64_t> AddrOffsetIndex;
switch (Hdr->AddrOffSize) {
case 1:
AddrOffsetIndex = getAddressOffsetIndex<uint8_t>(AddrOffset);
@@ -262,7 +262,7 @@ llvm::Expected<FunctionInfo> GsymReader::getFunctionInfo(uint64_t Addr) const {
assert(*AddressIndex < AddrInfoOffsets.size());
auto AddrInfoOffset = AddrInfoOffsets[*AddressIndex];
DataExtractor Data(MemBuffer->getBuffer().substr(AddrInfoOffset), Endian, 4);
- if (Optional<uint64_t> OptAddr = getAddress(*AddressIndex)) {
+ if (std::optional<uint64_t> OptAddr = getAddress(*AddressIndex)) {
auto ExpectedFI = FunctionInfo::decode(Data, *OptAddr);
if (ExpectedFI) {
if (ExpectedFI->Range.contains(Addr) || ExpectedFI->Range.size() == 0)
@@ -284,7 +284,7 @@ llvm::Expected<LookupResult> GsymReader::lookup(uint64_t Addr) const {
assert(*AddressIndex < AddrInfoOffsets.size());
auto AddrInfoOffset = AddrInfoOffsets[*AddressIndex];
DataExtractor Data(MemBuffer->getBuffer().substr(AddrInfoOffset), Endian, 4);
- if (Optional<uint64_t> OptAddr = getAddress(*AddressIndex))
+ if (std::optional<uint64_t> OptAddr = getAddress(*AddressIndex))
return FunctionInfo::lookup(Data, *this, *OptAddr, Addr);
return createStringError(std::errc::invalid_argument,
"failed to extract address[%" PRIu64 "]",
@@ -382,7 +382,7 @@ void GsymReader::dump(raw_ostream &OS, const InlineInfo &II, uint32_t Indent) {
dump(OS, ChildII, Indent + 2);
}
-void GsymReader::dump(raw_ostream &OS, Optional<FileEntry> FE) {
+void GsymReader::dump(raw_ostream &OS, std::optional<FileEntry> FE) {
if (FE) {
// IF we have the file from index 0, then don't print anything
if (FE->Dir == 0 && FE->Base == 0)
diff --git a/llvm/lib/DebugInfo/GSYM/InlineInfo.cpp b/llvm/lib/DebugInfo/GSYM/InlineInfo.cpp
index 54cbab88ae3e8..f775ab8fb65c7 100644
--- a/llvm/lib/DebugInfo/GSYM/InlineInfo.cpp
+++ b/llvm/lib/DebugInfo/GSYM/InlineInfo.cpp
@@ -53,7 +53,8 @@ static bool getInlineStackHelper(const InlineInfo &II, uint64_t Addr,
return false;
}
-llvm::Optional<InlineInfo::InlineArray> InlineInfo::getInlineStack(uint64_t Addr) const {
+std::optional<InlineInfo::InlineArray>
+InlineInfo::getInlineStack(uint64_t Addr) const {
InlineArray Result;
if (getInlineStackHelper(*this, Addr, Result))
return Result;
@@ -134,7 +135,7 @@ static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset,
Done = lookup(GR, Data, Offset, ChildBaseAddr, Addr, SrcLocs, Err);
}
- Optional<FileEntry> CallFile = GR.getFile(Inline.CallFile);
+ std::optional<FileEntry> CallFile = GR.getFile(Inline.CallFile);
if (!CallFile) {
Err = createStringError(std::errc::invalid_argument,
"failed to extract file[%" PRIu32 "]",
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVELFReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVELFReader.cpp
index 51ac39fefd3b0..37bd53576483e 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVELFReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVELFReader.cpp
@@ -398,7 +398,7 @@ void LVELFReader::processOneAttribute(const DWARFDie &Die, LVOffset *OffsetPtr,
// For toolchains that support the removal of unused code, the linker
// marks functions that have been removed, by setting the value for the
// low_pc to the max address.
- if (Optional<uint64_t> Value = FormValue.getAsAddress()) {
+ if (std::optional<uint64_t> Value = FormValue.getAsAddress()) {
CurrentLowPC = Value.value();
} else {
uint64_t UValue = FormValue.getRawUValue();
@@ -424,10 +424,10 @@ void LVELFReader::processOneAttribute(const DWARFDie &Die, LVOffset *OffsetPtr,
case dwarf::DW_AT_high_pc:
if (options().getGeneralCollectRanges()) {
FoundHighPC = true;
- if (Optional<uint64_t> Address = FormValue.getAsAddress())
+ if (std::optional<uint64_t> Address = FormValue.getAsAddress())
// High PC is an address.
CurrentHighPC = *Address;
- if (Optional<uint64_t> Offset = FormValue.getAsUnsignedConstant())
+ if (std::optional<uint64_t> Offset = FormValue.getAsUnsignedConstant())
// High PC is an offset from LowPC.
CurrentHighPC = CurrentLowPC + *Offset;
// Store the real upper limit for the address range.
@@ -628,7 +628,7 @@ LVScope *LVELFReader::processOneDie(const DWARFDie &InputDIE, LVScope *Parent,
!CurrentScope->getLinkageNameIndex() &&
CurrentScope->getHasReferenceSpecification()) {
// Get the linkage name in order to search for a possible comdat.
- Optional<DWARFFormValue> LinkageDIE =
+ std::optional<DWARFFormValue> LinkageDIE =
DIE.findRecursively(dwarf::DW_AT_linkage_name);
if (LinkageDIE.has_value()) {
StringRef Name(dwarf::toStringRef(LinkageDIE));
@@ -899,7 +899,7 @@ Error LVELFReader::createScopes() {
DWARFDie UnitDie = CU->getUnitDIE();
SmallString<16> DWOAlternativeLocation;
if (UnitDie) {
- Optional<const char *> DWOFileName =
+ std::optional<const char *> DWOFileName =
CU->getVersion() >= 5
? dwarf::toString(UnitDie.find(dwarf::DW_AT_dwo_name))
: dwarf::toString(UnitDie.find(dwarf::DW_AT_GNU_dwo_name));
@@ -1002,13 +1002,13 @@ void LVELFReader::processLocationList(dwarf::Attribute Attr,
FormValue.isFormClass(DWARFFormValue::FC_SectionOffset)) {
uint64_t Offset = *FormValue.getAsSectionOffset();
if (FormValue.getForm() == dwarf::DW_FORM_loclistx) {
- Optional<uint64_t> LoclistOffset = U->getLoclistOffset(Offset);
+ std::optional<uint64_t> LoclistOffset = U->getLoclistOffset(Offset);
if (!LoclistOffset)
return;
Offset = *LoclistOffset;
}
uint64_t BaseAddr = 0;
- if (Optional<SectionedAddress> BA = U->getBaseAddress())
+ if (std::optional<SectionedAddress> BA = U->getBaseAddress())
BaseAddr = BA->Address;
LVAddress LowPC = 0;
LVAddress HighPC = 0;
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp
index 247406c49efc0..ee4078a20b729 100644
--- a/llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp
@@ -24,7 +24,7 @@ std::string DIADataStream::getName() const {
return invokeBstrMethod(*StreamData, &IDiaEnumDebugStreamData::get_name);
}
-llvm::Optional<DIADataStream::RecordType>
+std::optional<DIADataStream::RecordType>
DIADataStream::getItemAtIndex(uint32_t Index) const {
RecordType Record;
DWORD RecordSize = 0;
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
index 3a719bd07c8a3..fdb8c1bf2ad54 100644
--- a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
@@ -86,7 +86,7 @@ Error DbiStreamBuilder::addDbgStream(pdb::DbgHeaderType Type,
assert(Type != DbgHeaderType::NewFPO &&
"NewFPO data should be written via addFrameData()!");
- DbgStreams[(int)Type].emplace();
+ DbgStreams[(int)Type] = DebugStream{};
DbgStreams[(int)Type]->Size = Data.size();
DbgStreams[(int)Type]->WriteFn = [Data](BinaryStreamWriter &Writer) {
return Writer.writeArray(Data);
@@ -286,7 +286,7 @@ Error DbiStreamBuilder::finalize() {
Error DbiStreamBuilder::finalizeMsfLayout() {
if (NewFpoData) {
- DbgStreams[(int)DbgHeaderType::NewFPO].emplace();
+ DbgStreams[(int)DbgHeaderType::NewFPO] = DebugStream{};
DbgStreams[(int)DbgHeaderType::NewFPO]->Size =
NewFpoData->calculateSerializedSize();
DbgStreams[(int)DbgHeaderType::NewFPO]->WriteFn =
@@ -296,7 +296,7 @@ Error DbiStreamBuilder::finalizeMsfLayout() {
}
if (!OldFpoData.empty()) {
- DbgStreams[(int)DbgHeaderType::FPO].emplace();
+ DbgStreams[(int)DbgHeaderType::FPO] = DebugStream{};
DbgStreams[(int)DbgHeaderType::FPO]->Size =
sizeof(object::FpoData) * OldFpoData.size();
DbgStreams[(int)DbgHeaderType::FPO]->WriteFn =
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeEnumTypes.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeEnumTypes.cpp
index 6912b8dc838e6..2c3b19c7e5677 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeEnumTypes.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeEnumTypes.cpp
@@ -27,7 +27,7 @@ NativeEnumTypes::NativeEnumTypes(NativeSession &PDBSession,
LazyRandomTypeCollection &Types,
std::vector<codeview::TypeLeafKind> Kinds)
: Index(0), Session(PDBSession) {
- Optional<TypeIndex> TI = Types.getFirst();
+ std::optional<TypeIndex> TI = Types.getFirst();
while (TI) {
CVType CVT = Types.getType(*TI);
TypeLeafKind K = CVT.kind();
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeInlineSiteSymbol.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeInlineSiteSymbol.cpp
index 7eede122f669d..dba00b451ef63 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeInlineSiteSymbol.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeInlineSiteSymbol.cpp
@@ -40,7 +40,7 @@ void NativeInlineSiteSymbol::dump(raw_ostream &OS, int Indent,
dumpSymbolField(OS, "name", getName(), Indent);
}
-static Optional<InlineeSourceLine>
+static std::optional<InlineeSourceLine>
findInlineeByTypeIndex(TypeIndex Id, ModuleDebugStreamRef &ModS) {
for (const auto &SS : ModS.getSubsectionsArray()) {
if (SS.kind() != DebugSubsectionKind::InlineeLines)
@@ -104,11 +104,11 @@ void NativeInlineSiteSymbol::getLineOffset(uint32_t OffsetInFunc,
LineOffset = 0;
FileOffset = 0;
uint32_t CodeOffset = 0;
- Optional<uint32_t> CodeOffsetBase;
- Optional<uint32_t> CodeOffsetEnd;
- Optional<int32_t> CurLineOffset;
- Optional<int32_t> NextLineOffset;
- Optional<uint32_t> NextFileOffset;
+ std::optional<uint32_t> CodeOffsetBase;
+ std::optional<uint32_t> CodeOffsetEnd;
+ std::optional<int32_t> CurLineOffset;
+ std::optional<int32_t> NextLineOffset;
+ std::optional<uint32_t> NextFileOffset;
auto UpdateCodeOffset = [&](uint32_t Delta) {
if (!CodeOffsetBase)
CodeOffsetBase = CodeOffset;
@@ -209,7 +209,7 @@ NativeInlineSiteSymbol::findInlineeLinesByVA(uint64_t VA,
getLineOffset(VA - ParentAddr, SrcLineOffset, SrcFileOffset);
// Get line info from inlinee line table.
- Optional<InlineeSourceLine> Inlinee =
+ std::optional<InlineeSourceLine> Inlinee =
findInlineeByTypeIndex(Sym.Inlinee, ModS.get());
if (!Inlinee)
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
index 641043a8e186e..27df769ee6f21 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
@@ -354,7 +354,7 @@ Error PDBFileBuilder::commit(StringRef Filename, codeview::GUID *Guid) {
} else {
H->Age = Info->getAge();
H->Guid = Info->getGuid();
- Optional<uint32_t> Sig = Info->getSignature();
+ std::optional<uint32_t> Sig = Info->getSignature();
H->Signature = Sig ? *Sig : time(nullptr);
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
index 986e45e050c76..1c94194de3a27 100644
--- a/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
@@ -55,7 +55,7 @@ void TpiStreamBuilder::updateTypeIndexOffsets(ArrayRef<uint16_t> Sizes) {
}
void TpiStreamBuilder::addTypeRecord(ArrayRef<uint8_t> Record,
- Optional<uint32_t> Hash) {
+ std::optional<uint32_t> Hash) {
assert(((Record.size() & 3) == 0) &&
"The type record's size is not a multiple of 4 bytes which will "
"cause misalignment in the output TPI stream!");
diff --git a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
index 8557c755c5f7e..bfd6f7c02ca3b 100644
--- a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
@@ -31,8 +31,8 @@ namespace symbolize {
class SourceCode {
std::unique_ptr<MemoryBuffer> MemBuf;
- Optional<StringRef> load(StringRef FileName,
- const Optional<StringRef> &EmbeddedSource) {
+ std::optional<StringRef>
+ load(StringRef FileName, const std::optional<StringRef> &EmbeddedSource) {
if (Lines <= 0)
return std::nullopt;
@@ -48,7 +48,7 @@ class SourceCode {
}
}
- Optional<StringRef> pruneSource(const Optional<StringRef> &Source) {
+ std::optional<StringRef> pruneSource(const std::optional<StringRef> &Source) {
if (!Source)
return std::nullopt;
size_t FirstLinePos = StringRef::npos, Pos = 0;
@@ -71,11 +71,11 @@ class SourceCode {
const int Lines;
const int64_t FirstLine;
const int64_t LastLine;
- const Optional<StringRef> PrunedSource;
+ const std::optional<StringRef> PrunedSource;
- SourceCode(
- StringRef FileName, int64_t Line, int Lines,
- const Optional<StringRef> &EmbeddedSource = Optional<StringRef>())
+ SourceCode(StringRef FileName, int64_t Line, int Lines,
+ const std::optional<StringRef> &EmbeddedSource =
+ std::optional<StringRef>())
: Line(Line), Lines(Lines),
FirstLine(std::max(static_cast<int64_t>(1), Line - Lines / 2)),
LastLine(FirstLine + Lines - 1),
diff --git a/llvm/lib/DebugInfo/Symbolize/Markup.cpp b/llvm/lib/DebugInfo/Symbolize/Markup.cpp
index a6541162f4684..ae3e24c0d5008 100644
--- a/llvm/lib/DebugInfo/Symbolize/Markup.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Markup.cpp
@@ -42,7 +42,7 @@ void MarkupParser::parseLine(StringRef Line) {
this->Line = Line;
}
-Optional<MarkupNode> MarkupParser::nextNode() {
+std::optional<MarkupNode> MarkupParser::nextNode() {
// Pull something out of the buffer if possible.
if (!Buffer.empty()) {
if (NextIdx < Buffer.size())
@@ -57,7 +57,7 @@ Optional<MarkupNode> MarkupParser::nextNode() {
return std::nullopt;
if (!InProgressMultiline.empty()) {
- if (Optional<StringRef> MultilineEnd = parseMultiLineEnd(Line)) {
+ if (std::optional<StringRef> MultilineEnd = parseMultiLineEnd(Line)) {
llvm::append_range(InProgressMultiline, *MultilineEnd);
assert(FinishedMultiline.empty() &&
"At most one multi-line element can be finished at a time.");
@@ -74,7 +74,7 @@ Optional<MarkupNode> MarkupParser::nextNode() {
}
// Find the first valid markup element, if any.
- if (Optional<MarkupNode> Element = parseElement(Line)) {
+ if (std::optional<MarkupNode> Element = parseElement(Line)) {
parseTextOutsideMarkup(takeTo(Line, Element->Text.begin()));
Buffer.push_back(std::move(*Element));
advanceTo(Line, Element->Text.end());
@@ -83,7 +83,7 @@ Optional<MarkupNode> MarkupParser::nextNode() {
// Since there were no valid elements remaining, see if the line opens a
// multi-line element.
- if (Optional<StringRef> MultilineBegin = parseMultiLineBegin(Line)) {
+ if (std::optional<StringRef> MultilineBegin = parseMultiLineBegin(Line)) {
// Emit any text before the element.
parseTextOutsideMarkup(takeTo(Line, MultilineBegin->begin()));
@@ -111,7 +111,7 @@ void MarkupParser::flush() {
// Finds and returns the next valid markup element in the given line. Returns
// None if the line contains no valid elements.
-Optional<MarkupNode> MarkupParser::parseElement(StringRef Line) {
+std::optional<MarkupNode> MarkupParser::parseElement(StringRef Line) {
while (true) {
// Find next element using begin and end markers.
size_t BeginPos = Line.find("{{{");
@@ -169,7 +169,7 @@ void MarkupParser::parseTextOutsideMarkup(StringRef Text) {
// Given that a line doesn't contain any valid markup, see if it ends with the
// start of a multi-line element. If so, returns the beginning.
-Optional<StringRef> MarkupParser::parseMultiLineBegin(StringRef Line) {
+std::optional<StringRef> MarkupParser::parseMultiLineBegin(StringRef Line) {
// A multi-line begin marker must be the last one on the line.
size_t BeginPos = Line.rfind("{{{");
if (BeginPos == StringRef::npos)
@@ -194,7 +194,7 @@ Optional<StringRef> MarkupParser::parseMultiLineBegin(StringRef Line) {
// See if the line begins with the ending of an in-progress multi-line element.
// If so, return the ending.
-Optional<StringRef> MarkupParser::parseMultiLineEnd(StringRef Line) {
+std::optional<StringRef> MarkupParser::parseMultiLineEnd(StringRef Line) {
size_t EndPos = Line.find("}}}");
if (EndPos == StringRef::npos)
return std::nullopt;
diff --git a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
index c3b1e4d5b271f..86fa52654a027 100644
--- a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
@@ -37,7 +37,7 @@ using namespace llvm;
using namespace llvm::symbolize;
MarkupFilter::MarkupFilter(raw_ostream &OS, LLVMSymbolizer &Symbolizer,
- Optional<bool> ColorsEnabled)
+ std::optional<bool> ColorsEnabled)
: OS(OS), Symbolizer(Symbolizer),
ColorsEnabled(
ColorsEnabled.value_or(WithColor::defaultAutoDetectFunction()(OS))) {}
@@ -51,7 +51,7 @@ void MarkupFilter::filter(StringRef Line) {
// See if the line is a contextual (i.e. contains a contextual element).
// In this case, anything after the contextual element is elided, or the whole
// line may be elided.
- while (Optional<MarkupNode> Node = Parser.nextNode()) {
+ while (std::optional<MarkupNode> Node = Parser.nextNode()) {
// If this was a contextual line, then summarily stop processing.
if (tryContextualElement(*Node, DeferredNodes))
return;
@@ -67,7 +67,7 @@ void MarkupFilter::filter(StringRef Line) {
void MarkupFilter::finish() {
Parser.flush();
- while (Optional<MarkupNode> Node = Parser.nextNode())
+ while (std::optional<MarkupNode> Node = Parser.nextNode())
filterNode(*Node);
endAnyModuleInfoLine();
resetColor();
@@ -96,7 +96,7 @@ bool MarkupFilter::tryMMap(const MarkupNode &Node,
const SmallVector<MarkupNode> &DeferredNodes) {
if (Node.Tag != "mmap")
return false;
- Optional<MMap> ParsedMMap = parseMMap(Node);
+ std::optional<MMap> ParsedMMap = parseMMap(Node);
if (!ParsedMMap)
return true;
@@ -148,7 +148,7 @@ bool MarkupFilter::tryModule(const MarkupNode &Node,
const SmallVector<MarkupNode> &DeferredNodes) {
if (Node.Tag != "module")
return false;
- Optional<Module> ParsedModule = parseModule(Node);
+ std::optional<Module> ParsedModule = parseModule(Node);
if (!ParsedModule)
return true;
@@ -243,7 +243,7 @@ bool MarkupFilter::tryPC(const MarkupNode &Node) {
if (!checkNumFieldsAtMost(Node, 2))
return true;
- Optional<uint64_t> Addr = parseAddr(Node.Fields[0]);
+ std::optional<uint64_t> Addr = parseAddr(Node.Fields[0]);
if (!Addr)
return true;
@@ -251,7 +251,7 @@ bool MarkupFilter::tryPC(const MarkupNode &Node) {
// locations.
PCType Type = PCType::PreciseCode;
if (Node.Fields.size() == 2) {
- Optional<PCType> ParsedType = parsePCType(Node.Fields[1]);
+ std::optional<PCType> ParsedType = parsePCType(Node.Fields[1]);
if (!ParsedType)
return true;
Type = *ParsedType;
@@ -297,18 +297,18 @@ bool MarkupFilter::tryBackTrace(const MarkupNode &Node) {
if (!checkNumFieldsAtMost(Node, 3))
return true;
- Optional<uint64_t> FrameNumber = parseFrameNumber(Node.Fields[0]);
+ std::optional<uint64_t> FrameNumber = parseFrameNumber(Node.Fields[0]);
if (!FrameNumber)
return true;
- Optional<uint64_t> Addr = parseAddr(Node.Fields[1]);
+ std::optional<uint64_t> Addr = parseAddr(Node.Fields[1]);
if (!Addr)
return true;
// Backtrace addresses are assumed to be return addresses by default.
PCType Type = PCType::ReturnAddress;
if (Node.Fields.size() == 3) {
- Optional<PCType> ParsedType = parsePCType(Node.Fields[2]);
+ std::optional<PCType> ParsedType = parsePCType(Node.Fields[2]);
if (!ParsedType)
return true;
Type = *ParsedType;
@@ -375,7 +375,7 @@ bool MarkupFilter::tryData(const MarkupNode &Node) {
return false;
if (!checkNumFields(Node, 1))
return true;
- Optional<uint64_t> Addr = parseAddr(Node.Fields[0]);
+ std::optional<uint64_t> Addr = parseAddr(Node.Fields[0]);
if (!Addr)
return true;
@@ -499,7 +499,7 @@ void MarkupFilter::printValue(Twine Value) {
return std::nullopt; \
TYPE NAME = std::move(*NAME##Opt)
-Optional<MarkupFilter::Module>
+std::optional<MarkupFilter::Module>
MarkupFilter::parseModule(const MarkupNode &Element) const {
if (!checkNumFieldsAtLeast(Element, 3))
return std::nullopt;
@@ -518,7 +518,7 @@ MarkupFilter::parseModule(const MarkupNode &Element) const {
return Module{ID, Name.str(), std::move(BuildID)};
}
-Optional<MarkupFilter::MMap>
+std::optional<MarkupFilter::MMap>
MarkupFilter::parseMMap(const MarkupNode &Element) const {
if (!checkNumFieldsAtLeast(Element, 3))
return std::nullopt;
@@ -547,7 +547,7 @@ MarkupFilter::parseMMap(const MarkupNode &Element) const {
}
// Parse an address (%p in the spec).
-Optional<uint64_t> MarkupFilter::parseAddr(StringRef Str) const {
+std::optional<uint64_t> MarkupFilter::parseAddr(StringRef Str) const {
if (Str.empty()) {
reportTypeError(Str, "address");
return std::nullopt;
@@ -567,7 +567,7 @@ Optional<uint64_t> MarkupFilter::parseAddr(StringRef Str) const {
}
// Parse a module ID (%i in the spec).
-Optional<uint64_t> MarkupFilter::parseModuleID(StringRef Str) const {
+std::optional<uint64_t> MarkupFilter::parseModuleID(StringRef Str) const {
uint64_t ID;
if (Str.getAsInteger(0, ID)) {
reportTypeError(Str, "module ID");
@@ -577,7 +577,7 @@ Optional<uint64_t> MarkupFilter::parseModuleID(StringRef Str) const {
}
// Parse a size (%i in the spec).
-Optional<uint64_t> MarkupFilter::parseSize(StringRef Str) const {
+std::optional<uint64_t> MarkupFilter::parseSize(StringRef Str) const {
uint64_t ID;
if (Str.getAsInteger(0, ID)) {
reportTypeError(Str, "size");
@@ -587,7 +587,7 @@ Optional<uint64_t> MarkupFilter::parseSize(StringRef Str) const {
}
// Parse a frame number (%i in the spec).
-Optional<uint64_t> MarkupFilter::parseFrameNumber(StringRef Str) const {
+std::optional<uint64_t> MarkupFilter::parseFrameNumber(StringRef Str) const {
uint64_t ID;
if (Str.getAsInteger(10, ID)) {
reportTypeError(Str, "frame number");
@@ -597,7 +597,8 @@ Optional<uint64_t> MarkupFilter::parseFrameNumber(StringRef Str) const {
}
// Parse a build ID (%x in the spec).
-Optional<SmallVector<uint8_t>> MarkupFilter::parseBuildID(StringRef Str) const {
+std::optional<SmallVector<uint8_t>>
+MarkupFilter::parseBuildID(StringRef Str) const {
std::string Bytes;
if (Str.empty() || Str.size() % 2 || !tryGetFromHex(Str, Bytes)) {
reportTypeError(Str, "build ID");
@@ -609,7 +610,7 @@ Optional<SmallVector<uint8_t>> MarkupFilter::parseBuildID(StringRef Str) const {
}
// Parses the mode string for an mmap element.
-Optional<std::string> MarkupFilter::parseMode(StringRef Str) const {
+std::optional<std::string> MarkupFilter::parseMode(StringRef Str) const {
if (Str.empty()) {
reportTypeError(Str, "mode");
return std::nullopt;
@@ -634,9 +635,10 @@ Optional<std::string> MarkupFilter::parseMode(StringRef Str) const {
return Str.lower();
}
-Optional<MarkupFilter::PCType> MarkupFilter::parsePCType(StringRef Str) const {
- Optional<MarkupFilter::PCType> Type =
- StringSwitch<Optional<MarkupFilter::PCType>>(Str)
+std::optional<MarkupFilter::PCType>
+MarkupFilter::parsePCType(StringRef Str) const {
+ std::optional<MarkupFilter::PCType> Type =
+ StringSwitch<std::optional<MarkupFilter::PCType>>(Str)
.Case("ra", MarkupFilter::PCType::ReturnAddress)
.Case("pc", MarkupFilter::PCType::PreciseCode)
.Default(std::nullopt);
diff --git a/llvm/lib/ProfileData/InstrProfCorrelator.cpp b/llvm/lib/ProfileData/InstrProfCorrelator.cpp
index 6c460a5f9c317..38ae5d8f821c0 100644
--- a/llvm/lib/ProfileData/InstrProfCorrelator.cpp
+++ b/llvm/lib/ProfileData/InstrProfCorrelator.cpp
@@ -264,11 +264,11 @@ void DwarfInstrProfCorrelator<IntPtrT>::correlateProfileDataImpl(
if (!isDIEOfProbe(Die))
return;
Optional<const char *> FunctionName;
- Optional<uint64_t> CFGHash;
+ std::optional<uint64_t> CFGHash;
Optional<uint64_t> CounterPtr = getLocation(Die);
auto FnDie = Die.getParent();
auto FunctionPtr = dwarf::toAddress(FnDie.find(dwarf::DW_AT_low_pc));
- Optional<uint64_t> NumCounters;
+ std::optional<uint64_t> NumCounters;
for (const DWARFDie &Child : Die.children()) {
if (Child.getTag() != dwarf::DW_TAG_LLVM_annotation)
continue;
diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
index ac140338020ae..d4fa73fc0f9ae 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -980,7 +980,7 @@ bool DwarfLinkerForBinary::AddressManager::isLiveVariable(
const DWARFDie &DIE, CompileUnit::DIEInfo &MyInfo) {
const auto *Abbrev = DIE.getAbbreviationDeclarationPtr();
- Optional<uint32_t> LocationIdx =
+ std::optional<uint32_t> LocationIdx =
Abbrev->findAttributeIndex(dwarf::DW_AT_location);
if (!LocationIdx)
return false;
@@ -999,7 +999,8 @@ bool DwarfLinkerForBinary::AddressManager::isLiveSubprogram(
const DWARFDie &DIE, CompileUnit::DIEInfo &MyInfo) {
const auto *Abbrev = DIE.getAbbreviationDeclarationPtr();
- Optional<uint32_t> LowPcIdx = Abbrev->findAttributeIndex(dwarf::DW_AT_low_pc);
+ std::optional<uint32_t> LowPcIdx =
+ Abbrev->findAttributeIndex(dwarf::DW_AT_low_pc);
if (!LowPcIdx)
return false;
@@ -1015,8 +1016,8 @@ bool DwarfLinkerForBinary::AddressManager::isLiveSubprogram(
}
if (Form == dwarf::DW_FORM_addrx) {
- Optional<DWARFFormValue> AddrValue = DIE.find(dwarf::DW_AT_low_pc);
- if (Optional<uint64_t> AddrOffsetSectionBase =
+ std::optional<DWARFFormValue> AddrValue = DIE.find(dwarf::DW_AT_low_pc);
+ if (std::optional<uint64_t> AddrOffsetSectionBase =
DIE.getDwarfUnit()->getAddrOffsetSectionBase()) {
uint64_t StartOffset = *AddrOffsetSectionBase + AddrValue->getRawUValue();
uint64_t EndOffset =
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index cc7f353330b1d..59e736183e571 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -137,8 +137,7 @@ static alias DumpAllAlias("a", desc("Alias for --all"), aliasopt(DumpAll),
// Options for dumping specific sections.
static unsigned DumpType = DIDT_Null;
-static std::array<llvm::Optional<uint64_t>, (unsigned)DIDT_ID_Count>
- DumpOffsets;
+static std::array<std::optional<uint64_t>, (unsigned)DIDT_ID_Count> DumpOffsets;
#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME, OPTION) \
static opt<OPTION> Dump##ENUM_NAME(CMDLINE_NAME, \
desc("Dump the " ELF_NAME " section"), \
@@ -386,7 +385,7 @@ static void filterByName(const StringSet<> &Names,
static void getDies(DWARFContext &DICtx, const AppleAcceleratorTable &Accel,
StringRef Name, SmallVectorImpl<DWARFDie> &Dies) {
for (const auto &Entry : Accel.equal_range(Name)) {
- if (llvm::Optional<uint64_t> Off = Entry.getDIESectionOffset()) {
+ if (std::optional<uint64_t> Off = Entry.getDIESectionOffset()) {
if (DWARFDie Die = DICtx.getDIEForOffset(*Off))
Dies.push_back(Die);
}
@@ -395,8 +394,8 @@ static void getDies(DWARFContext &DICtx, const AppleAcceleratorTable &Accel,
static DWARFDie toDie(const DWARFDebugNames::Entry &Entry,
DWARFContext &DICtx) {
- llvm::Optional<uint64_t> CUOff = Entry.getCUOffset();
- llvm::Optional<uint64_t> Off = Entry.getDIEUnitOffset();
+ std::optional<uint64_t> CUOff = Entry.getCUOffset();
+ std::optional<uint64_t> Off = Entry.getDIEUnitOffset();
if (!CUOff || !Off)
return DWARFDie();
@@ -404,7 +403,7 @@ static DWARFDie toDie(const DWARFDebugNames::Entry &Entry,
if (!CU)
return DWARFDie();
- if (llvm::Optional<uint64_t> DWOId = CU->getDWOId()) {
+ if (std::optional<uint64_t> DWOId = CU->getDWOId()) {
// This is a skeleton unit. Look up the DIE in the DWO unit.
CU = DICtx.getDWOCompileUnitForHash(*DWOId);
if (!CU)
@@ -477,7 +476,7 @@ static bool collectLineTableSources(const DWARFDebugLine::LineTable <,
StringRef CompDir,
std::vector<std::string> &Sources) {
bool Result = true;
- llvm::Optional<uint64_t> LastIndex = LT.getLastValidFileIndex();
+ std::optional<uint64_t> LastIndex = LT.getLastValidFileIndex();
for (uint64_t I = LT.hasFileAtIndex(0) ? 0 : 1,
E = LastIndex ? *LastIndex + 1 : 0;
I < E; ++I) {
diff --git a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
index f06d8d038f650..48d3b1fcc3f7b 100644
--- a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
+++ b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
@@ -76,7 +76,7 @@ class ObjFileAddressMap : public AddressesMap {
DIE.getTag() == dwarf::DW_TAG_label) &&
"Wrong type of input die");
- if (Optional<uint64_t> LowPC =
+ if (std::optional<uint64_t> LowPC =
dwarf::toAddress(DIE.find(dwarf::DW_AT_low_pc))) {
if (!isDeadAddress(*LowPC, DIE.getDwarfUnit()->getVersion(),
Opts.Tombstone,
diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
index a173eb1faa627..4b604206fc98f 100644
--- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
@@ -602,7 +602,8 @@ Error DumpOutputStyle::dumpTypeStats() {
StatCollection TypeStats;
LazyRandomTypeCollection &Types =
opts::dump::DumpTypeStats ? File.types() : File.ids();
- for (Optional<TypeIndex> TI = Types.getFirst(); TI; TI = Types.getNext(*TI)) {
+ for (std::optional<TypeIndex> TI = Types.getFirst(); TI;
+ TI = Types.getNext(*TI)) {
CVType Type = Types.getType(*TI);
TypeStats.update(uint32_t(Type.kind()), Type.length());
}
@@ -692,7 +693,7 @@ Error DumpOutputStyle::dumpUdtStats() {
Kind = kNoneUdtKind;
else if (UDT.Type.isSimple())
Kind = kSimpleUdtKind;
- else if (Optional<CVType> T = TpiTypes.tryGetType(UDT.Type)) {
+ else if (std::optional<CVType> T = TpiTypes.tryGetType(UDT.Type)) {
Kind = T->kind();
RecordSize = T->length();
} else
@@ -1250,7 +1251,7 @@ static void dumpPartialTypeStream(LinePrinter &Printer,
if (TI.isSimple()) {
Printer.formatLine("{0} | {1}", fmt_align(I, AlignStyle::Right, Width),
Types.getTypeName(TI));
- } else if (Optional<CVType> Type = Types.tryGetType(TI)) {
+ } else if (std::optional<CVType> Type = Types.tryGetType(TI)) {
if (auto EC = codeview::visitTypeRecord(*Type, TI, V))
Printer.formatLine("An error occurred dumping type record {0}: {1}",
TI, toString(std::move(EC)));
@@ -1517,7 +1518,8 @@ Error DumpOutputStyle::dumpTypeRefStats() {
size_t TotalBytes = 0;
size_t RefBytes = 0;
auto &Types = File.types();
- for (Optional<TypeIndex> TI = Types.getFirst(); TI; TI = Types.getNext(*TI)) {
+ for (std::optional<TypeIndex> TI = Types.getFirst(); TI;
+ TI = Types.getNext(*TI)) {
CVType Type = File.types().getType(*TI);
TotalBytes += Type.length();
if (RefTracker->isTypeReferenced(*TI)) {
diff --git a/llvm/tools/llvm-pdbutil/TypeReferenceTracker.cpp b/llvm/tools/llvm-pdbutil/TypeReferenceTracker.cpp
index d813bc22a93cb..5ae720aace427 100644
--- a/llvm/tools/llvm-pdbutil/TypeReferenceTracker.cpp
+++ b/llvm/tools/llvm-pdbutil/TypeReferenceTracker.cpp
@@ -24,7 +24,8 @@ using namespace llvm::codeview;
// just iterate up front to find out.
static uint32_t getNumRecordsInCollection(LazyRandomTypeCollection &Types) {
uint32_t NumTypes = 0;
- for (Optional<TypeIndex> TI = Types.getFirst(); TI; TI = Types.getNext(*TI))
+ for (std::optional<TypeIndex> TI = Types.getFirst(); TI;
+ TI = Types.getNext(*TI))
++NumTypes;
return NumTypes;
}
@@ -129,9 +130,9 @@ void TypeReferenceTracker::markReferencedTypes() {
TiRefKind RefKind;
TypeIndex RefTI;
std::tie(RefKind, RefTI) = RefWorklist.pop_back_val();
- Optional<CVType> Rec = (Ids && RefKind == TiRefKind::IndexRef)
- ? Ids->tryGetType(RefTI)
- : Types.tryGetType(RefTI);
+ std::optional<CVType> Rec = (Ids && RefKind == TiRefKind::IndexRef)
+ ? Ids->tryGetType(RefTI)
+ : Types.tryGetType(RefTI);
if (!Rec)
continue; // FIXME: Report a reference to a non-existant type.
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
index 1de06f96eff36..3d549f742ddb6 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -760,7 +760,7 @@ void ProfiledBinary::loadSymbolsFromDWARF(ObjectFile &Obj) {
// Handles DWO sections that can either be in .o, .dwo or .dwp files.
for (const auto &CompilationUnit : DebugContext->compile_units()) {
DWARFUnit *const DwarfUnit = CompilationUnit.get();
- if (llvm::Optional<uint64_t> DWOId = DwarfUnit->getDWOId()) {
+ if (std::optional<uint64_t> DWOId = DwarfUnit->getDWOId()) {
DWARFUnit *DWOCU = DwarfUnit->getNonSkeletonUnitDIE(false).getDwarfUnit();
if (!DWOCU->isDWOUnit()) {
std::string DWOName = dwarf::toString(
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index 19c9830c05625..eed1e948dbcb8 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -1371,7 +1371,7 @@ void COFFDumper::mergeCodeViewTypes(MergingTypeTableBuilder &CVIDs,
Obj->getFileName());
}
SmallVector<TypeIndex, 128> SourceToDest;
- Optional<PCHMergerInfo> PCHInfo;
+ std::optional<PCHMergerInfo> PCHInfo;
if (GHash) {
std::vector<GloballyHashedType> Hashes =
GloballyHashedType::hashTypes(Types);
diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
index 73750c2690269..5a74dfb56eeed 100644
--- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -341,11 +341,11 @@ static FunctionNameKind decideHowToPrintFunctions(const opt::InputArgList &Args,
return IsAddr2Line ? FunctionNameKind::None : FunctionNameKind::LinkageName;
}
-static Optional<bool> parseColorArg(const opt::InputArgList &Args) {
+static std::optional<bool> parseColorArg(const opt::InputArgList &Args) {
if (Args.hasArg(OPT_color))
return true;
if (const opt::Arg *A = Args.getLastArg(OPT_color_EQ))
- return StringSwitch<Optional<bool>>(A->getValue())
+ return StringSwitch<std::optional<bool>>(A->getValue())
.Case("always", true)
.Case("never", false)
.Case("auto", std::nullopt);
diff --git a/llvm/unittests/BinaryFormat/DwarfTest.cpp b/llvm/unittests/BinaryFormat/DwarfTest.cpp
index ddafbb4102bde..2fff8657939b8 100644
--- a/llvm/unittests/BinaryFormat/DwarfTest.cpp
+++ b/llvm/unittests/BinaryFormat/DwarfTest.cpp
@@ -140,8 +140,8 @@ TEST(DwarfTest, getVirtuality) {
}
TEST(DwarfTest, FixedFormSizes) {
- Optional<uint8_t> RefSize;
- Optional<uint8_t> AddrSize;
+ std::optional<uint8_t> RefSize;
+ std::optional<uint8_t> AddrSize;
// Test 32 bit DWARF version 2 with 4 byte addresses.
FormParams Params_2_4_32 = {2, 4, DWARF32};
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp
index 40eecfb36e7db..155b799b22f95 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp
@@ -422,7 +422,7 @@ TEST(DWARFDebugFrame, RegisterLocations) {
expectDumpResult(Locs, "reg12=[CFA+4], reg13=[CFA+8], reg14=same");
// Verify RegisterLocations::getRegisterLocation() works as expected.
- Optional<dwarf::UnwindLocation> OptionalLoc;
+ std::optional<dwarf::UnwindLocation> OptionalLoc;
OptionalLoc = Locs.getRegisterLocation(0);
EXPECT_FALSE(OptionalLoc.has_value());
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index 3f113d65c9bfc..4473c5af3db3a 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -245,9 +245,9 @@ void TestAllForms() {
//----------------------------------------------------------------------
// Test block forms
//----------------------------------------------------------------------
- Optional<DWARFFormValue> FormValue;
+ std::optional<DWARFFormValue> FormValue;
ArrayRef<uint8_t> ExtractedBlockData;
- Optional<ArrayRef<uint8_t>> BlockDataOpt;
+ std::optional<ArrayRef<uint8_t>> BlockDataOpt;
FormValue = DieDG.find(Attr_DW_FORM_block);
EXPECT_TRUE((bool)FormValue);
@@ -937,7 +937,7 @@ template <uint16_t Version, class AddrType> void TestAddresses() {
EXPECT_TRUE(DieDG.isValid());
uint64_t LowPC, HighPC, SectionIndex;
- Optional<uint64_t> OptU64;
+ std::optional<uint64_t> OptU64;
// Verify the that our subprogram with no PC value fails appropriately when
// asked for any PC values.
auto SubprogramDieNoPC = DieDG.getFirstChild();
@@ -1118,14 +1118,14 @@ TEST(DWARFDebugInfo, TestStringOffsets) {
ASSERT_TRUE((bool)Extracted1);
EXPECT_STREQ(String1, *Extracted1);
- Optional<DWARFFormValue> Form2 = DieDG.find(Attr2);
+ std::optional<DWARFFormValue> Form2 = DieDG.find(Attr2);
ASSERT_TRUE((bool)Form2);
EXPECT_EQ(0u, Form2->getRawUValue());
auto Extracted2 = toString(Form2);
ASSERT_TRUE((bool)Extracted2);
EXPECT_STREQ(String2, *Extracted2);
- Optional<DWARFFormValue> Form3 = DieDG.find(Attr3);
+ std::optional<DWARFFormValue> Form3 = DieDG.find(Attr3);
ASSERT_TRUE((bool)Form3);
EXPECT_EQ(1u, Form3->getRawUValue());
auto Extracted3 = toString(Form3);
@@ -1632,13 +1632,13 @@ TEST(DWARFDebugInfo, TestFindRecurse) {
TEST(DWARFDebugInfo, TestDwarfToFunctions) {
// Test all of the dwarf::toXXX functions that take a
- // Optional<DWARFFormValue> and extract the values from it.
+ // std::optional<DWARFFormValue> and extract the values from it.
uint64_t InvalidU64 = 0xBADBADBADBADBADB;
int64_t InvalidS64 = 0xBADBADBADBADBADB;
// First test that we don't get valid values back when using an optional with
// no value.
- Optional<DWARFFormValue> FormValOpt1 = DWARFFormValue();
+ std::optional<DWARFFormValue> FormValOpt1 = DWARFFormValue();
EXPECT_FALSE(toString(FormValOpt1).has_value());
EXPECT_FALSE(toUnsigned(FormValOpt1).has_value());
EXPECT_FALSE(toReference(FormValOpt1).has_value());
@@ -1655,7 +1655,7 @@ TEST(DWARFDebugInfo, TestDwarfToFunctions) {
// Test successful and unsuccessful address decoding.
uint64_t Address = 0x100000000ULL;
- Optional<DWARFFormValue> FormValOpt2 =
+ std::optional<DWARFFormValue> FormValOpt2 =
DWARFFormValue::createFromUValue(DW_FORM_addr, Address);
EXPECT_FALSE(toString(FormValOpt2).has_value());
@@ -1674,7 +1674,7 @@ TEST(DWARFDebugInfo, TestDwarfToFunctions) {
// Test successful and unsuccessful unsigned constant decoding.
uint64_t UData8 = 0x1020304050607080ULL;
- Optional<DWARFFormValue> FormValOpt3 =
+ std::optional<DWARFFormValue> FormValOpt3 =
DWARFFormValue::createFromUValue(DW_FORM_udata, UData8);
EXPECT_FALSE(toString(FormValOpt3).has_value());
@@ -1693,7 +1693,7 @@ TEST(DWARFDebugInfo, TestDwarfToFunctions) {
// Test successful and unsuccessful reference decoding.
uint32_t RefData = 0x11223344U;
- Optional<DWARFFormValue> FormValOpt4 =
+ std::optional<DWARFFormValue> FormValOpt4 =
DWARFFormValue::createFromUValue(DW_FORM_ref_addr, RefData);
EXPECT_FALSE(toString(FormValOpt4).has_value());
@@ -1712,7 +1712,7 @@ TEST(DWARFDebugInfo, TestDwarfToFunctions) {
// Test successful and unsuccessful signed constant decoding.
int64_t SData8 = 0x1020304050607080ULL;
- Optional<DWARFFormValue> FormValOpt5 =
+ std::optional<DWARFFormValue> FormValOpt5 =
DWARFFormValue::createFromSValue(DW_FORM_udata, SData8);
EXPECT_FALSE(toString(FormValOpt5).has_value());
@@ -1732,7 +1732,7 @@ TEST(DWARFDebugInfo, TestDwarfToFunctions) {
// Test successful and unsuccessful block decoding.
uint8_t Data[] = { 2, 3, 4 };
ArrayRef<uint8_t> Array(Data);
- Optional<DWARFFormValue> FormValOpt6 =
+ std::optional<DWARFFormValue> FormValOpt6 =
DWARFFormValue::createFromBlockValue(DW_FORM_block1, Array);
EXPECT_FALSE(toString(FormValOpt6).has_value());
@@ -1873,7 +1873,7 @@ TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) {
auto A = it->getAttrByIndex(0);
EXPECT_EQ(A, Attr);
- Optional<uint32_t> AttrIndex = it->findAttributeIndex(A);
+ std::optional<uint32_t> AttrIndex = it->findAttributeIndex(A);
EXPECT_TRUE((bool)AttrIndex);
EXPECT_EQ(*AttrIndex, 0u);
uint64_t OffsetVal =
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp
index 8bb4d0fe59bad..1aedd74f39439 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp
@@ -91,10 +91,10 @@ TEST(DWARFListTableHeader, OffsetEntryCount) {
/*ListTypeString=*/"range");
uint64_t Offset = 0;
EXPECT_FALSE(!!Header.extract(Extractor, &Offset));
- Optional<uint64_t> Offset0 = Header.getOffsetEntry(Extractor, 0);
+ std::optional<uint64_t> Offset0 = Header.getOffsetEntry(Extractor, 0);
EXPECT_TRUE(!!Offset0);
EXPECT_EQ(Offset0, uint64_t(4));
- Optional<uint64_t> Offset1 = Header.getOffsetEntry(Extractor, 1);
+ std::optional<uint64_t> Offset1 = Header.getOffsetEntry(Extractor, 1);
EXPECT_FALSE(!!Offset1);
EXPECT_EQ(Header.length(), sizeof(SecData) - 1);
}
More information about the llvm-commits
mailing list