diff --git a/bolt/include/bolt/Core/DebugData.h b/bolt/include/bolt/Core/DebugData.h index 5be678cc12e2..1ba31fe4d223 100644 --- a/bolt/include/bolt/Core/DebugData.h +++ b/bolt/include/bolt/Core/DebugData.h @@ -424,7 +424,7 @@ public: /// Initializes Buffer and Stream. void initialize(const DWARFSection &StrOffsetsSection, - const Optional Contr); + const std::optional 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 8f2bc4ceecc4..208b106c68f2 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 DirName = dwarf::toString( + if (std::optional DirName = dwarf::toString( LineTable->Prologue .IncludeDirectories[FileNames[FileIndex - 1].DirIdx - 1])) { Dir = *DirName; } } StringRef FileName = ""; - if (Optional FName = + if (std::optional 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 &CU : DwCtx->compile_units()) { DWARFUnit *const DwarfUnit = CU.get(); - if (llvm::Optional DWOId = DwarfUnit->getDWOId()) { + if (std::optional 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 Checksum; if (LineTable->Prologue.ContentTypes.HasMD5) Checksum = LineTable->Prologue.FileNames[0].Checksum; - Optional Name = + std::optional Name = dwarf::toString(CU->getUnitDIE().find(dwarf::DW_AT_name), nullptr); - if (Optional DWOID = CU->getDWOId()) { + if (std::optional 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 DirName = dwarf::toString( + if (std::optional DirName = dwarf::toString( LineTable->Prologue .IncludeDirectories[FileNames[I].DirIdx - Offset])) Dir = *DirName; StringRef FileName = ""; - if (Optional FName = dwarf::toString(FileNames[I].Name)) + if (std::optional FName = + dwarf::toString(FileNames[I].Name)) FileName = *FName; assert(FileName != ""); std::optional 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 FName = + if (std::optional 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 6d39353dcf72..d0e8988405f6 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 Value = + std::optional 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 ValSizeOpt = AttrVal->getByteSize(U); + std::optional ValSizeOpt = AttrVal->getByteSize(U); if (ValSizeOpt) { ValSize = static_cast(*ValSizeOpt); } else { @@ -81,7 +81,7 @@ Optional findAttributeInfo(const DWARFDie DIE, DIE.getAbbreviationDeclarationPtr(); if (!AbbrevDecl) return std::nullopt; - Optional Index = AbbrevDecl->findAttributeIndex(Attr); + std::optional 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 BaseOffset = CU->getAddrOffsetSectionBase(); + std::optional 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 Contr) { + const std::optional Contr) { if (!Contr) return; diff --git a/bolt/lib/Core/Exceptions.cpp b/bolt/lib/Core/Exceptions.cpp index 6ec6d05c7a6c..b1976ed7669b 100644 --- a/bolt/lib/Core/Exceptions.cpp +++ b/bolt/lib/Core/Exceptions.cpp @@ -115,7 +115,7 @@ void BinaryFunction::parseLSDA(ArrayRef 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 MaybeLPStart = Data.getEncodedPointer( + if (std::optional 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 LSDA = CurFDE.getLSDAAddress(); + std::optional 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 Personality = + std::optional 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 LSDAAddress; + std::optional 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 abcb373f4b65..72eac7b2f777 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 *NameToIndexMap, std::unordered_map &DWOIdToName) { - llvm::Optional DWOId = CU.getDWOId(); + std::optional 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(*CU.get(), DwarfVersion, false); - if (Optional DWOId = CU->getDWOId()) { + if (std::optional 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(); } - if (Optional DWOId = CU->getDWOId()) { + if (std::optional 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 SplitCU; Optional RangesBase; - llvm::Optional DWOId = Unit->getDWOId(); + std::optional 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 Address = AttrVal.V.getAsAddress(); + std::optional 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 SectionAddress = + std::optional 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 LocOffset = Unit.getLoclistOffset(Offset); + std::optional 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 EntryAddress = + std::optional EntryAddress = Unit.getAddrOffsetSectionItem(Entry.Value0); assert(EntryAddress && "base Address not found."); BaseAddress = EntryAddress->Address; break; } case dwarf::DW_LLE_startx_length: { - Optional EntryAddress = + std::optional 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 StartAddress = + std::optional StartAddress = Unit.getAddrOffsetSectionItem(Entry.Value0); assert(StartAddress && "Start Address does not exist."); - Optional EndAddress = + std::optional 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 EntryAddress = + std::optional EntryAddress = Unit.getAddrOffsetSectionItem(Index); assert(EntryAddress && "Address is not found."); assert(Index <= std::numeric_limits::max() && @@ -694,7 +694,7 @@ void DWARFRewriter::updateUnitDebugInfo( findAttributeInfo(DIE, dwarf::DW_AT_low_pc)) { AttrOffset = AttrVal->Offset; Value = AttrVal->V; - const Optional Result = Value.getAsAddress(); + const std::optional 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 Val = SignatureAttrVal->V.getAsReferenceUVal()) + if (std::optional 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 DebugLineOffsetMap; auto GetStatementListValue = [](DWARFUnit *Unit) { - Optional StmtList = + std::optional StmtList = Unit->getUnitDIE().find(dwarf::DW_AT_stmt_list); - Optional Offset = dwarf::toSectionOffset(StmtList); + std::optional 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 &CU : BC.DwCtx->compile_units()) { - Optional DWOId = CU->getDWOId(); + std::optional DWOId = CU->getDWOId(); if (!DWOId) continue; @@ -1581,7 +1582,7 @@ void DWARFRewriter::writeDWOFiles( } for (const std::unique_ptr &CU : BC.DwCtx->compile_units()) { - Optional DWOId = CU->getDWOId(); + std::optional DWOId = CU->getDWOId(); if (!DWOId) continue; diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp index af463c218bb9..d723e48e99bc 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 pchInfo; + std::optional 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 be4609fa229b..a56454c53a6d 100644 --- a/lld/ELF/DWARF.cpp +++ b/lld/ELF/DWARF.cpp @@ -127,7 +127,7 @@ LLDDwarfObj::findAux(const InputSectionBase &sec, uint64_t pos, DataRefImpl d; d.p = getAddend(rel); return RelocAddrEntry{secIndex, RelocationRef(d, nullptr), - val, Optional(), + val, std::optional(), 0, LLDRelocationResolver::resolve}; } diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index e92216bb5e4d..d6029aa13709 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 { + [&](uint32_t index) -> std::optional { 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 loc) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index 21ef765d1bba..399578b6a353 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -578,7 +578,7 @@ llvm::Expected 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 off = GetRnglistTable()->getOffsetEntry( + if (std::optional 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 26e322059743..9fdab3c5273f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -243,7 +243,7 @@ public: if (!m_loclist_table_header) return llvm::None; - llvm::Optional Offset = m_loclist_table_header->getOffsetEntry( + std::optional 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 a8e9b41c83fe..d0b2ef66d401 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 DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) { - llvm::Optional cu_offset = entry.getCUOffset(); + std::optional 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 die_offset = entry.getDIEUnitOffset()) + if (std::optional 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 d15c0ee99f96..e2e06491e8c1 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 cvt = types.tryGetType(bis.BuildId); + std::optional 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 e288c5191bdb..2b49c375acb3 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 LanguageLowerBound(SourceLanguage L); +std::optional 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 value with the fixed byte size or None if +/// \returns std::optional value with the fixed byte size or None if /// \p Form doesn't have a fixed byte size. -Optional getFixedFormByteSize(dwarf::Form Form, FormParams Params); +std::optional 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 d474173973b5..fa2277343d5d 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h +++ b/llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h @@ -36,8 +36,8 @@ public: ~AppendingTypeTableBuilder(); // TypeCollection overrides - Optional getFirst() override; - Optional getNext(TypeIndex Prev) override; + std::optional getFirst() override; + std::optional 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 ef44b622d955..c629018fd109 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 SymbolOffset; - llvm::Optional ParentRecursiveDepth; - llvm::Optional ChildRecursiveDepth; + std::optional SymbolOffset; + std::optional ParentRecursiveDepth; + std::optional ChildRecursiveDepth; }; CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks); diff --git a/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h b/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h index ccaf6506abde..5a2d0c6c049a 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 @@ public: explicit CodeViewRecordIO(CodeViewRecordStreamer &Streamer) : Streamer(&Streamer) {} - Error beginRecord(Optional MaxLength); + Error beginRecord(std::optional MaxLength); Error endRecord(); Error mapInteger(TypeIndex &TypeInd, const Twine &Comment = ""); @@ -245,9 +244,9 @@ private: struct RecordLimit { uint32_t BeginOffset; - Optional MaxLength; + std::optional MaxLength; - Optional bytesRemaining(uint32_t CurrentOffset) const { + std::optional 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 0f83ae370a1e..84cef520a2f4 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 SegmentOffsets; - Optional Kind; + std::optional 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 RefersTo); + std::optional RefersTo); public: ContinuationRecordBuilder(); diff --git a/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h index d592bde18bae..18f16bc66a77 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h +++ b/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h @@ -49,8 +49,8 @@ public: ~GlobalTypeTableBuilder(); // TypeCollection overrides - Optional getFirst() override; - Optional getNext(TypeIndex Prev) override; + std::optional getFirst() override; + std::optional 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 ddbb4e3c5e6c..240f7092140c 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 @@ public: uint32_t getOffsetOfType(TypeIndex Index); - Optional tryGetType(TypeIndex Index); + std::optional 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 getFirst() override; - Optional getNext(TypeIndex Prev) override; + std::optional getFirst() override; + std::optional 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 1965aab9b5cc..10bc8f60613c 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h +++ b/llvm/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h @@ -45,8 +45,8 @@ public: ~MergingTypeTableBuilder(); // TypeCollection overrides - Optional getFirst() override; - Optional getNext(TypeIndex Prev) override; + std::optional getFirst() override; + std::optional 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 9513e19a330a..3ddcf9c57390 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 @@ private: return true; } - Optional Current; + std::optional Current; ArrayRef Data; ArrayRef Next; }; diff --git a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h index 34368b6185d6..30e9c626c205 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h +++ b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h @@ -35,7 +35,7 @@ public: #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" private: - Optional Kind; + std::optional Kind; CodeViewRecordIO IO; CodeViewContainer Container; diff --git a/llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h b/llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h index 53986f9a6db6..df52b374f72d 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 CurrentSymbol; + std::optional 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 f643bc4d7451..dd082a72125a 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h +++ b/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h @@ -21,8 +21,8 @@ public: bool empty() { return size() == 0; } - virtual Optional getFirst() = 0; - virtual Optional getNext(TypeIndex Prev) = 0; + virtual std::optional getFirst() = 0; + virtual std::optional getNext(TypeIndex Prev) = 0; virtual CVType getType(TypeIndex Index) = 0; virtual StringRef getTypeName(TypeIndex Index) = 0; @@ -32,7 +32,7 @@ public: virtual bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) = 0; template void ForEachRecord(TFunc Func) { - Optional Next = getFirst(); + std::optional 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 01916bd18fb8..1ebc4d47e096 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 #include +#include #include namespace llvm { diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h b/llvm/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h index ed4fc7a75624..26eb7d221679 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 namespace llvm { class BinaryStreamReader; @@ -46,8 +46,8 @@ public: #include "llvm/DebugInfo/CodeView/CodeViewTypes.def" private: - Optional TypeKind; - Optional MemberKind; + std::optional TypeKind; + std::optional MemberKind; CodeViewRecordIO IO; }; diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h b/llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h index 6abf67a27bd1..86edfc4b055f 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 &SourceToDest, const CVTypeArray &IdsAndTypes, - Optional &PCHInfo); + std::optional &PCHInfo); Error mergeTypeAndIdRecords(GlobalTypeTableBuilder &DestIds, GlobalTypeTableBuilder &DestTypes, SmallVectorImpl &SourceToDest, const CVTypeArray &IdsAndTypes, ArrayRef Hashes, - Optional &PCHInfo); + std::optional &PCHInfo); Error mergeTypeRecords(GlobalTypeTableBuilder &Dest, SmallVectorImpl &SourceToDest, const CVTypeArray &Types, ArrayRef Hashes, - Optional &PCHInfo); + std::optional &PCHInfo); Error mergeIdRecords(GlobalTypeTableBuilder &Dest, ArrayRef Types, SmallVectorImpl &SourceToDest, diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeTableCollection.h b/llvm/include/llvm/DebugInfo/CodeView/TypeTableCollection.h index c3008742d2e1..2a389b9ac34e 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> Records); - Optional getFirst() override; - Optional getNext(TypeIndex Prev) override; + std::optional getFirst() override; + std::optional 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 9b278b696073..afc2d5176ebc 100644 --- a/llvm/include/llvm/DebugInfo/DIContext.h +++ b/llvm/include/llvm/DebugInfo/DIContext.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -36,11 +37,11 @@ struct DILineInfo { std::string FileName; std::string FunctionName; std::string StartFileName; - Optional Source; + std::optional Source; uint32_t Line = 0; uint32_t Column = 0; uint32_t StartLine = 0; - Optional StartAddress; + std::optional StartAddress; // DWARF-specific. uint32_t Discriminator = 0; @@ -125,9 +126,9 @@ struct DILocal { std::string Name; std::string DeclFile; uint64_t DeclLine = 0; - Optional FrameOffset; - Optional Size; - Optional TagOffset; + std::optional FrameOffset; + std::optional Size; + std::optional 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 3887656ceef6..6d7c5773379e 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 @@ public: : Attr(A), Form(F), Value(Value) { assert(isImplicitConst()); } - AttributeSpec(dwarf::Attribute A, dwarf::Form F, Optional ByteSize) + AttributeSpec(dwarf::Attribute A, dwarf::Form F, + std::optional ByteSize) : Attr(A), Form(F) { assert(!isImplicitConst()); this->ByteSize.HasByteSize = ByteSize.has_value(); @@ -79,7 +79,7 @@ public: /// 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 getByteSize(const DWARFUnit &U) const; + std::optional getByteSize(const DWARFUnit &U) const; }; using AttributeSpecVector = SmallVector; @@ -128,7 +128,7 @@ public: /// /// \param attr DWARF attribute to search for. /// \returns Optional index of the attribute if found, None otherwise. - Optional findAttributeIndex(dwarf::Attribute attr) const; + std::optional findAttributeIndex(dwarf::Attribute attr) const; /// Extract a DWARF form value from a DIE specified by DIE offset. /// @@ -140,9 +140,9 @@ public: /// \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 getAttributeValue(const uint64_t DIEOffset, - const dwarf::Attribute Attr, - const DWARFUnit &U) const; + std::optional 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 @@ public: /// \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 + std::optional getAttributeValueFromOffset(uint32_t AttrIndex, uint64_t Offset, const DWARFUnit &U) const; @@ -171,7 +171,7 @@ public: // 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 getFixedAttributesByteSize(const DWARFUnit &U) const; + std::optional getFixedAttributesByteSize(const DWARFUnit &U) const; private: void clear(); @@ -206,7 +206,7 @@ private: AttributeSpecVector AttributeSpecs; /// If this abbreviation has a fixed byte size then FixedAttributeSize member /// variable below will have a value. - Optional FixedAttributeSize; + std::optional FixedAttributeSize; }; } // end namespace llvm diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h index 355995bf69b9..aad46b945adf 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h @@ -53,12 +53,12 @@ public: /// 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 getCUOffset() const = 0; + virtual std::optional 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 getTag() const = 0; + virtual std::optional 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, 3> Atoms; - Optional extractOffset(Optional Value) const; + std::optional + extractOffset(std::optional Value) const; }; struct Header Hdr; @@ -122,19 +123,19 @@ public: void extract(const AppleAcceleratorTable &AccelTable, uint64_t *Offset); public: - Optional getCUOffset() const override; + std::optional 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 getDIESectionOffset() const; + std::optional getDIESectionOffset() const; - Optional getTag() const override; + std::optional getTag() const override; /// Returns the value of the Atom in this Accelerator Entry, if the Entry /// contains such Atom. - Optional lookup(HeaderData::AtomType Atom) const; + std::optional lookup(HeaderData::AtomType Atom) const; friend class AppleAcceleratorTable; friend class ValueIterator; @@ -287,8 +288,8 @@ public: Entry(const NameIndex &NameIdx, const Abbrev &Abbr); public: - Optional getCUOffset() const override; - Optional getTag() const override { return tag(); } + std::optional getCUOffset() const override; + std::optional 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 @@ public: /// 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 getCUIndex() const; + std::optional 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 getDIEUnitOffset() const; + std::optional getDIEUnitOffset() const; /// Return the Abbreviation that can be used to interpret the raw values of /// this Accelerator Entry. @@ -313,7 +314,7 @@ public: /// Returns the value of the Index Attribute in this Accelerator Entry, if /// the Entry contains such Attribute. - Optional lookup(dwarf::Index Index) const; + std::optional lookup(dwarf::Index Index) const; void dump(ScopedPrinter &W) const; @@ -406,7 +407,7 @@ public: void dumpAbbreviations(ScopedPrinter &W) const; bool dumpEntry(ScopedPrinter &W, uint64_t *Offset) const; void dumpName(ScopedPrinter &W, const NameTableEntry &NTE, - Optional Hash) const; + std::optional Hash) const; void dumpBucket(ScopedPrinter &W, uint32_t Bucket) const; Expected extractAttributeEncoding(uint64_t *Offset); @@ -491,13 +492,13 @@ public: /// (searches all name indices). bool IsLocal; - Optional CurrentEntry; + std::optional CurrentEntry; uint64_t DataOffset = 0; ///< Offset into the section. std::string Key; ///< The Key we are searching for. - Optional Hash; ///< Hash of Key, if it has been computed. + std::optional Hash; ///< Hash of Key, if it has been computed. bool getEntryAtCurrentOffset(); - Optional findEntryOffsetInCurrentIndex(); + std::optional 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 bf591ed554c6..5dc000163e7d 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> NormalTypeUnits; + std::optional> NormalTypeUnits; std::unique_ptr CUIndex; std::unique_ptr GdbIndex; std::unique_ptr TUIndex; @@ -65,7 +65,7 @@ class DWARFContext : public DIContext { std::unique_ptr AppleObjC; DWARFUnitVector DWOUnits; - Optional> DWOTypeUnits; + std::optional> DWOTypeUnits; std::unique_ptr AbbrevDWO; std::unique_ptr MacinfoDWO; std::unique_ptr MacroDWO; @@ -132,10 +132,10 @@ public: /// 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, DIDT_ID_Count> DumpOffsets); + std::array, DIDT_ID_Count> DumpOffsets); void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override { - std::array, DIDT_ID_Count> DumpOffsets; + std::array, 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 49749201af99..e94fa7bf5590 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h @@ -81,8 +81,8 @@ public: /// 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 getEncodedPointer(uint64_t *Offset, uint8_t Encoding, - uint64_t AbsPosOffset = 0) const; + std::optional 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 882aa69d9ccb..52a88f2c390a 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 Data; + mutable std::optional Data; public: DWARFDebugAbbrev(); diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h index 67d9ce1476dd..9549a5789488 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h @@ -70,7 +70,7 @@ public: /// Return the full length of this table, including the length field. /// Return None if the length cannot be identified reliably. - Optional getFullLength() const; + std::optional 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 75a1a0b05b2a..9dfe95aa7131 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h @@ -67,10 +67,10 @@ private: 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 AddrSpace; /// The address space for Kind == RegPlusOffset - /// for CFA. - Optional Expr; /// The DWARF expression for Kind == - /// DWARFExpression. + std::optional AddrSpace; /// The address space for Kind == + /// RegPlusOffset for CFA. + std::optional 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 @@ private: : Kind(K), RegNum(InvalidRegisterNumber), Offset(0), AddrSpace(std::nullopt), Dereference(false) {} - UnwindLocation(Location K, uint32_t Reg, int32_t Off, Optional AS, - bool Deref) + UnwindLocation(Location K, uint32_t Reg, int32_t Off, + std::optional AS, bool Deref) : Kind(K), RegNum(Reg), Offset(Off), AddrSpace(AS), Dereference(Deref) {} UnwindLocation(DWARFExpression E, bool Deref) @@ -117,10 +117,10 @@ public: /// false. static UnwindLocation createIsRegisterPlusOffset(uint32_t Reg, int32_t Off, - Optional AddrSpace = std::nullopt); + std::optional AddrSpace = std::nullopt); static UnwindLocation createAtRegisterPlusOffset(uint32_t Reg, int32_t Off, - Optional AddrSpace = std::nullopt); + std::optional 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 @@ public: // DW_CFA_AARCH64_negate_ra_state). void setConstant(int32_t Value) { Offset = Value; } - Optional getDWARFExpressionBytes() const { return Expr; } + std::optional getDWARFExpressionBytes() const { + return Expr; + } /// Dump a location expression as text and use the register information if /// some is provided. /// @@ -187,7 +189,7 @@ public: /// /// \returns A location if one is available for \a RegNum, or llvm::None /// otherwise. - Optional getRegisterLocation(uint32_t RegNum) const { + std::optional 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 Address; ///< Address for row in FDE, invalid for CIE. + std::optional 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 @@ private: 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 EndAddress; + std::optional EndAddress; /// Parse the information in the CFIProgram and update the CurrRow object /// that the state machine describes. @@ -416,7 +418,7 @@ public: uint8_t Opcode; Operands Ops; // Associated DWARF expression in case this instruction refers to one - Optional Expression; + std::optional Expression; Expected getOperandAsUnsigned(const CFIProgram &CFIP, uint32_t OperandIdx) const; @@ -573,8 +575,8 @@ public: uint8_t SegmentDescriptorSize, uint64_t CodeAlignmentFactor, int64_t DataAlignmentFactor, uint64_t ReturnAddressRegister, SmallString<8> AugmentationData, uint32_t FDEPointerEncoding, - uint32_t LSDAPointerEncoding, Optional Personality, - Optional PersonalityEnc, Triple::ArchType Arch) + uint32_t LSDAPointerEncoding, std::optional Personality, + std::optional PersonalityEnc, Triple::ArchType Arch) : FrameEntry(FK_CIE, IsDWARF64, Offset, Length, CodeAlignmentFactor, DataAlignmentFactor, Arch), Version(Version), Augmentation(std::move(Augmentation)), @@ -594,8 +596,10 @@ public: int64_t getDataAlignmentFactor() const { return DataAlignmentFactor; } uint8_t getVersion() const { return Version; } uint64_t getReturnAddressRegister() const { return ReturnAddressRegister; } - Optional getPersonalityAddress() const { return Personality; } - Optional getPersonalityEncoding() const { return PersonalityEnc; } + std::optional getPersonalityAddress() const { return Personality; } + std::optional getPersonalityEncoding() const { + return PersonalityEnc; + } uint32_t getFDEPointerEncoding() const { return FDEPointerEncoding; } @@ -618,8 +622,8 @@ private: const SmallString<8> AugmentationData; const uint32_t FDEPointerEncoding; const uint32_t LSDAPointerEncoding; - const Optional Personality; - const Optional PersonalityEnc; + const std::optional Personality; + const std::optional 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 LSDAAddress, Triple::ArchType Arch) + std::optional 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 @@ public: const CIE *getLinkedCIE() const { return LinkedCIE; } uint64_t getInitialLocation() const { return InitialLocation; } uint64_t getAddressRange() const { return AddressRange; } - Optional getLSDAAddress() const { return LSDAAddress; } + std::optional getLSDAAddress() const { return LSDAAddress; } void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH) const override; @@ -656,7 +659,7 @@ private: const uint64_t InitialLocation; const uint64_t AddressRange; const CIE *LinkedCIE; - const Optional LSDAAddress; + const std::optional LSDAAddress; }; } // end namespace dwarf @@ -686,7 +689,7 @@ public: /// Dump the section data into the given stream. void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, - Optional Offset) const; + std::optional 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 89c042a0287b..7d59f4257b2e 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h @@ -45,7 +45,7 @@ public: uint64_t getOffset() const { return Offset; } /// Returns index of the parent die. - Optional getParentIdx() const { + std::optional getParentIdx() const { if (ParentIdx == UINT32_MAX) return std::nullopt; @@ -53,7 +53,7 @@ public: } /// Returns index of the sibling die. - Optional getSiblingIdx() const { + std::optional 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 a932662ae04e..de9902ae2ebc 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 @@ public: bool hasFileAtIndex(uint64_t FileIndex) const; - Optional getLastValidFileIndex() const; + std::optional getLastValidFileIndex() const; bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, @@ -246,7 +245,7 @@ public: return Prologue.hasFileAtIndex(FileIndex); } - Optional getLastValidFileIndex() const { + std::optional getLastValidFileIndex() const { return Prologue.getLastValidFileIndex(); } @@ -294,7 +293,7 @@ public: private: uint32_t findRowInSeq(const DWARFDebugLine::Sequence &Seq, object::SectionedAddress Address) const; - Optional + std::optional 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 90e009e514d4..74638fc180b5 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 @@ public: /// 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 BaseAddr, + std::optional BaseAddr, const MCRegisterInfo *MRI, const DWARFObject &Obj, DWARFUnit *U, DIDumpOptions DumpOpts, unsigned Indent) const; Error visitAbsoluteLocationList( - uint64_t Offset, Optional BaseAddr, - std::function(uint32_t)> LookupAddr, + uint64_t Offset, std::optional BaseAddr, + std::function(uint32_t)> + LookupAddr, function_ref)> Callback) const; const DWARFDataExtractor &getData() { return Data; } @@ -111,7 +111,7 @@ public: /// Print the location lists found within the debug_loc section. void dump(raw_ostream &OS, const MCRegisterInfo *RegInfo, const DWARFObject &Obj, DIDumpOptions DumpOpts, - Optional Offset) const; + std::optional 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 25be64d064bb..cc32e7f24125 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h @@ -125,8 +125,8 @@ public: private: /// Parse the debug_macinfo/debug_macro section accessible via the 'MacroData' /// parameter. - Error parseImpl(Optional Units, - Optional StringExtractor, + Error parseImpl(std::optional Units, + std::optional StringExtractor, DWARFDataExtractor Data, bool IsMacro); }; diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h index f4aeac1bb9db..02bb5f0a3d95 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h @@ -72,7 +72,7 @@ public: /// list. Has to be passed base address of the compile unit referencing this /// range list. DWARFAddressRangesVector - getAbsoluteRanges(llvm::Optional BaseAddr) const; + getAbsoluteRanges(std::optional BaseAddr) const; }; } // end namespace llvm diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h index 13f018f53fa1..8ddd9cab2364 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(uint32_t)> - LookupPooledAddress) const; + void + dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength, + uint64_t &CurrentBase, DIDumpOptions DumpOpts, + llvm::function_ref(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 { public: /// Build a DWARFAddressRangesVector from a rangelist. - DWARFAddressRangesVector - getAbsoluteRanges(Optional BaseAddr, - uint8_t AddressByteSize, - function_ref(uint32_t)> - LookupPooledAddress) const; + DWARFAddressRangesVector getAbsoluteRanges( + std::optional BaseAddr, uint8_t AddressByteSize, + function_ref(uint32_t)> + LookupPooledAddress) const; /// Build a DWARFAddressRangesVector from a rangelist. DWARFAddressRangesVector - getAbsoluteRanges(llvm::Optional BaseAddr, + getAbsoluteRanges(std::optional BaseAddr, DWARFUnit &U) const; }; diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h index 149c5ef4e493..90f59138fc19 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 @@ public: /// \param Attr the attribute to extract. /// \returns an optional DWARFFormValue that will have the form value if the /// attribute was successfully extracted. - Optional find(dwarf::Attribute Attr) const; + std::optional find(dwarf::Attribute Attr) const; /// Extract the first value of any attribute in Attrs from this DIE. /// @@ -152,7 +151,7 @@ public: /// \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 find(ArrayRef Attrs) const; + std::optional find(ArrayRef 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 @@ public: /// 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 + std::optional findRecursively(ArrayRef Attrs) const; /// Extract the specified attribute from this DIE as the referenced DIE. @@ -190,8 +189,8 @@ public: /// or DW_AT_GNU_ranges_base attribute. /// /// \returns anm optional absolute section offset value for the attribute. - Optional getRangesBaseAttribute() const; - Optional getLocBaseAttribute() const; + std::optional getRangesBaseAttribute() const; + std::optional getLocBaseAttribute() const; /// Get the DW_AT_high_pc attribute value as an address. /// @@ -203,7 +202,7 @@ public: /// /// \param LowPC the low PC that might be needed to calculate the high PC. /// \returns an optional address value for the attribute. - Optional getHighPC(uint64_t LowPC) const; + std::optional 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 @@ public: /// \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 getTypeSize(uint64_t PointerSize); + std::optional 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 0c9789339660..6e5a16f635c8 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 @@ public: private: bool extract(DataExtractor Data, uint8_t AddressSize, uint64_t Offset, - Optional Format); + std::optional Format); }; /// An iterator to go through the expression operations. @@ -140,7 +139,7 @@ public: }; DWARFExpression(DataExtractor Data, uint8_t AddressSize, - Optional Format = std::nullopt) + std::optional Format = std::nullopt) : Data(Data), AddressSize(AddressSize), Format(Format) { assert(AddressSize == 8 || AddressSize == 4 || AddressSize == 2); } @@ -172,7 +171,7 @@ public: private: DataExtractor Data; uint8_t AddressSize; - Optional Format; + std::optional 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 4969e671609f..e9944a1fbee6 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 @@ public: /// getAsFoo functions below return the extracted value as Foo if only /// DWARFFormValue has form class is suitable for representing Foo. - Optional getAsReference() const; + std::optional getAsReference() const; struct UnitOffset { DWARFUnit *Unit; uint64_t Offset; }; - Optional getAsRelativeReference() const; - Optional getAsUnsignedConstant() const; - Optional getAsSignedConstant() const; + std::optional getAsRelativeReference() const; + std::optional getAsUnsignedConstant() const; + std::optional getAsSignedConstant() const; Expected getAsCString() const; - Optional getAsAddress() const; - Optional getAsSectionedAddress() const; - Optional getAsSectionOffset() const; - Optional> getAsBlock() const; - Optional getAsCStringOffset() const; - Optional getAsReferenceUVal() const; + std::optional getAsAddress() const; + std::optional getAsSectionedAddress() const; + std::optional getAsSectionOffset() const; + std::optional> getAsBlock() const; + std::optional getAsCStringOffset() const; + std::optional 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 @@ public: /// /// \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::optional 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 toString(const Optional &V) { +inline std::optional +toString(const std::optional &V) { if (!V) return std::nullopt; Expected E = V->getAsCString(); @@ -190,7 +190,7 @@ inline Optional toString(const Optional &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 &V, +inline StringRef toStringRef(const std::optional &V, StringRef Default = {}) { if (!V) return Default; @@ -210,7 +210,7 @@ inline StringRef toStringRef(const Optional &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 &V, +inline const char *toString(const std::optional &V, const char *Default) { if (auto E = toString(V)) return *E; @@ -222,7 +222,8 @@ inline const char *toString(const Optional &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 toUnsigned(const Optional &V) { +inline std::optional +toUnsigned(const std::optional &V) { if (V) return V->getAsUnsignedConstant(); return std::nullopt; @@ -234,7 +235,7 @@ inline Optional toUnsigned(const Optional &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 &V, +inline uint64_t toUnsigned(const std::optional &V, uint64_t Default) { return toUnsigned(V).value_or(Default); } @@ -244,7 +245,8 @@ inline uint64_t toUnsigned(const Optional &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 toReference(const Optional &V) { +inline std::optional +toReference(const std::optional &V) { if (V) return V->getAsReference(); return std::nullopt; @@ -256,7 +258,7 @@ inline Optional toReference(const Optional &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 &V, +inline uint64_t toReference(const std::optional &V, uint64_t Default) { return toReference(V).value_or(Default); } @@ -266,7 +268,7 @@ inline uint64_t toReference(const Optional &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 toSigned(const Optional &V) { +inline std::optional toSigned(const std::optional &V) { if (V) return V->getAsSignedConstant(); return std::nullopt; @@ -278,7 +280,8 @@ inline Optional toSigned(const Optional &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 &V, int64_t Default) { +inline int64_t toSigned(const std::optional &V, + int64_t Default) { return toSigned(V).value_or(Default); } @@ -287,14 +290,15 @@ inline int64_t toSigned(const Optional &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 toAddress(const Optional &V) { +inline std::optional +toAddress(const std::optional &V) { if (V) return V->getAsAddress(); return std::nullopt; } -inline Optional -toSectionedAddress(const Optional &V) { +inline std::optional +toSectionedAddress(const std::optional &V) { if (V) return V->getAsSectionedAddress(); return std::nullopt; @@ -306,7 +310,8 @@ toSectionedAddress(const Optional &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 &V, uint64_t Default) { +inline uint64_t toAddress(const std::optional &V, + uint64_t Default) { return toAddress(V).value_or(Default); } @@ -315,7 +320,8 @@ inline uint64_t toAddress(const Optional &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 toSectionOffset(const Optional &V) { +inline std::optional +toSectionOffset(const std::optional &V) { if (V) return V->getAsSectionOffset(); return std::nullopt; @@ -327,7 +333,7 @@ inline Optional toSectionOffset(const Optional &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 &V, +inline uint64_t toSectionOffset(const std::optional &V, uint64_t Default) { return toSectionOffset(V).value_or(Default); } @@ -337,7 +343,8 @@ inline uint64_t toSectionOffset(const Optional &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> toBlock(const Optional &V) { +inline std::optional> +toBlock(const std::optional &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 e5fe14cfb19e..d739d6c195df 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h @@ -112,17 +112,18 @@ public: void dump(DataExtractor Data, raw_ostream &OS, DIDumpOptions DumpOpts = {}) const; - Optional getOffsetEntry(DataExtractor Data, uint32_t Index) const { + std::optional getOffsetEntry(DataExtractor Data, + uint32_t Index) const { if (Index >= HeaderData.OffsetEntryCount) return std::nullopt; return getOffsetEntry(Data, getHeaderOffset() + getHeaderSize(Format), Format, Index); } - static Optional getOffsetEntry(DataExtractor Data, - uint64_t OffsetTableOffset, - dwarf::DwarfFormat Format, - uint32_t Index) { + static std::optional 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 @@ public: uint32_t getOffsetEntryCount() const { return Header.getOffsetEntryCount(); } dwarf::DwarfFormat getFormat() const { return Header.getFormat(); } - void dump(DWARFDataExtractor Data, raw_ostream &OS, - llvm::function_ref(uint32_t)> - LookupPooledAddress, - DIDumpOptions DumpOpts = {}) const; + void + dump(DWARFDataExtractor Data, raw_ostream &OS, + llvm::function_ref(uint32_t)> + LookupPooledAddress, + DIDumpOptions DumpOpts = {}) const; /// Return the contents of the offset entry designated by a given index. - Optional getOffsetEntry(DataExtractor Data, uint32_t Index) const { + std::optional 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::extract(DWARFDataExtractor Data, template void DWARFListTableBase::dump( DWARFDataExtractor Data, raw_ostream &OS, - llvm::function_ref(uint32_t)> + llvm::function_ref(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 35aa1a78e129..b221f9cc9279 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 Range; + std::optional Range; /// The expression itself. SmallVector Expr; diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h index fef59c5e95f8..c5999a65c2a7 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 Reloc2; + std::optional 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 25ca5cc42720..584cc5585693 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 DWOId; + std::optional DWOId; // Unit type as parsed, or derived from the section kind. uint8_t UnitType = 0; @@ -93,7 +92,7 @@ public: } uint64_t getLength() const { return Length; } uint64_t getAbbrOffset() const { return AbbrOffset; } - Optional getDWOId() const { return DWOId; } + std::optional getDWOId() const { return DWOId; } void setDWOId(uint64_t Id) { assert((!DWOId || *DWOId == Id) && "setting DWOId to a different value"); DWOId = Id; @@ -223,17 +222,18 @@ class DWARFUnit { const DWARFSection &StringOffsetSection; const DWARFSection *AddrOffsetSection; DWARFUnit *SU; - Optional AddrOffsetSectionBase; + std::optional 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 StringOffsetsTableContribution; + std::optional + StringOffsetsTableContribution; mutable const DWARFAbbreviationDeclarationSet *Abbrevs; - llvm::Optional BaseAddr; + std::optional BaseAddr; /// The compile unit debug information entry items. std::vector DieArray; @@ -287,14 +287,14 @@ protected: /// 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> + Expected> 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> + Expected> determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA); public: @@ -346,7 +346,7 @@ public: AddrOffsetSectionBase = Base; } - Optional getAddrOffsetSectionBase() const { + std::optional getAddrOffsetSectionBase() const { return AddrOffsetSectionBase; } @@ -365,7 +365,7 @@ public: return LocSectionBase; } - Optional + std::optional getAddrOffsetSectionItem(uint32_t Index) const; Expected getStringOffsetSectionItem(uint32_t Index) const; @@ -385,7 +385,7 @@ public: DWARFDebugRangeList &RangeList) const; void clear(); - const Optional & + const std::optional & getStringOffsetsTableContribution() const { return StringOffsetsTableContribution; } @@ -421,7 +421,7 @@ public: return false; } - llvm::Optional getBaseAddress(); + std::optional getBaseAddress(); DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) { extractDIEsIfNeeded(ExtractUnitDIEOnly); @@ -438,7 +438,7 @@ public: } const char *getCompilationDir(); - Optional getDWOId() { + std::optional getDWOId() { extractDIEsIfNeeded(/*CUDieOnly*/ true); return getHeader().getDWOId(); } @@ -456,9 +456,9 @@ public: /// 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 getRnglistOffset(uint32_t Index); + std::optional getRnglistOffset(uint32_t Index); - Optional getLoclistOffset(uint32_t Index); + std::optional getLoclistOffset(uint32_t Index); Expected collectAddressRanges(); @@ -514,7 +514,7 @@ public: /// Return the DIE object for a given offset \p Offset inside the /// unit's DIE vector. DWARFDie getDIEForOffset(uint64_t Offset) { - if (Optional DieIdx = getDIEIndexForOffset(Offset)) + if (std::optional DieIdx = getDIEIndexForOffset(Offset)) return DWARFDie(this, &DieArray[*DieIdx]); return DWARFDie(); @@ -522,7 +522,7 @@ public: /// Return the DIE index for a given offset \p Offset inside the /// unit's DIE vector. - Optional getDIEIndexForOffset(uint64_t Offset) { + std::optional 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 1f1ebe943238..b9ead366cb23 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 @@ public: /// 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 insert(const DWARFAddressRange &R); + std::optional 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 d02184ff62ee..713e3c239e95 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 OptLineTable; - llvm::Optional Inline; + std::optional OptLineTable; + std::optional 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 29ad1c18e295..2eac8b43f006 100644 --- a/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h +++ b/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h @@ -139,9 +139,9 @@ class GsymCreator { DenseMap FileEntryToIndex; std::vector Files; std::vector UUID; - Optional ValidTextRanges; + std::optional ValidTextRanges; AddressRanges Ranges; - llvm::Optional BaseAddress; + std::optional BaseAddress; bool Finalized = false; bool Quiet; @@ -249,7 +249,7 @@ public: } /// Get the valid text ranges. - const Optional GetValidTextRanges() const { + const std::optional GetValidTextRanges() const { return ValidTextRanges; } diff --git a/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h b/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h index d026d9b85a58..f2ac33be3bbe 100644 --- a/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h +++ b/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h @@ -138,7 +138,7 @@ public: /// \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 getFile(uint32_t Index) const { + std::optional getFile(uint32_t Index) const { if (Index < Files.size()) return Files[Index]; return std::nullopt; @@ -191,7 +191,7 @@ public: /// \param OS The output stream to dump to. /// /// \param FE The object to dump. - void dump(raw_ostream &OS, Optional FE); + void dump(raw_ostream &OS, std::optional FE); /// Get the number of addresses in this Gsym file. uint32_t getNumAddresses() const { @@ -205,7 +205,7 @@ public: /// \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 getAddress(size_t Index) const; + std::optional getAddress(size_t Index) const; protected: @@ -237,8 +237,8 @@ protected: /// \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 Optional - addressForIndex(size_t Index) const { + template + std::optional addressForIndex(size_t Index) const { ArrayRef AIO = getAddrOffsets(); if (Index < AIO.size()) return AIO[Index] + Hdr->BaseAddress; @@ -254,7 +254,8 @@ protected: /// \returns The matching address offset index. This index will be used to /// extract the FunctionInfo data's offset from the AddrInfoOffsets array. template - llvm::Optional getAddressOffsetIndex(const uint64_t AddrOffset) const { + std::optional + getAddressOffsetIndex(const uint64_t AddrOffset) const { ArrayRef AIO = getAddrOffsets(); const auto Begin = AIO.begin(); const auto End = AIO.end(); @@ -301,7 +302,7 @@ protected: /// \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 getAddressInfoOffset(size_t Index) const; + std::optional 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 80385116598a..03bc85396d99 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 getInlineStack(uint64_t Addr) const; + std::optional 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 c0121a8787be..a27019fc769d 100644 --- a/llvm/include/llvm/DebugInfo/GSYM/LineTable.h +++ b/llvm/include/llvm/DebugInfo/GSYM/LineTable.h @@ -170,7 +170,7 @@ public: /// /// \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 first() const { + std::optional first() const { if (Lines.empty()) return std::nullopt; return Lines.front(); @@ -179,7 +179,7 @@ public: /// /// \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 last() const { + std::optional 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 f05b58c55507..d331ba68557a 100644 --- a/llvm/include/llvm/DebugInfo/PDB/DIA/DIADataStream.h +++ b/llvm/include/llvm/DebugInfo/PDB/DIA/DIADataStream.h @@ -20,7 +20,7 @@ public: uint32_t getRecordCount() const override; std::string getName() const override; - llvm::Optional getItemAtIndex(uint32_t Index) const override; + std::optional 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 4d0589a87915..fb18396cafe3 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 +#include #include namespace llvm { @@ -28,7 +28,7 @@ public: virtual uint32_t getRecordCount() const = 0; virtual std::string getName() const = 0; - virtual Optional getItemAtIndex(uint32_t Index) const = 0; + virtual std::optional 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 2f99aa942a05..9a84fc3e7c55 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 @@ private: msf::MSFBuilder &Msf; BumpPtrAllocator &Allocator; - Optional VerHeader; + std::optional VerHeader; uint32_t Age; uint16_t BuildNumber; uint16_t PdbDllVersion; @@ -120,7 +119,7 @@ private: std::vector> ModiList; - Optional NewFpoData; + std::optional NewFpoData; std::vector OldFpoData; StringMap SourceFileNames; @@ -130,7 +129,7 @@ private: MutableBinaryByteStream FileInfoBuffer; std::vector SectionContribs; std::vector SectionMap; - std::array, (int)DbgHeaderType::Max> DbgStreams; + std::array, (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 69fcb4aa9994..eb03397ba694 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Native/HashTable.h +++ b/llvm/include/llvm/DebugInfo/PDB/Native/HashTable.h @@ -218,7 +218,7 @@ public: const_iterator find_as(const Key &K, TraitsT &Traits) const { uint32_t H = Traits.hashLookupKey(K) % capacity(); uint32_t I = H; - Optional FirstUnused; + std::optional FirstUnused; do { if (isPresent(I)) { if (Traits.storageKeyToLookupKey(Buckets[I].first) == K) @@ -271,7 +271,7 @@ private: /// from a real key to an internal key. template bool set_as_internal(const Key &K, ValueT V, TraitsT &Traits, - Optional InternalKey) { + std::optional 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 2d5088a3bd42..4b77e321353f 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 @@ public: bool hashPDBContentsToGUID() const { return HashPDBContentsToGUID; } uint32_t getAge() const { return Age; } codeview::GUID getGuid() const { return Guid; } - Optional getSignature() const { return Signature; } + std::optional getSignature() const { return Signature; } uint32_t finalize(); @@ -61,7 +60,7 @@ private: std::vector Features; PdbRaw_ImplVer Ver; uint32_t Age; - Optional Signature; + std::optional 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 c0d722960540..834cd96b77b4 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 @@ private: bool isEnd() const; uint32_t Index = 0; - Optional SectionIter; + std::optional SectionIter; SymbolGroup Value; }; diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/LinePrinter.h b/llvm/include/llvm/DebugInfo/PDB/Native/LinePrinter.h index 0db21309f593..bb029e534c74 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 IncludeCompilands; uint32_t PaddingThreshold; uint32_t SizeThreshold; - llvm::Optional DumpModi; - llvm::Optional ParentRecurseDepth; - llvm::Optional ChildrenRecurseDepth; - llvm::Optional SymbolOffset; + std::optional DumpModi; + std::optional ParentRecurseDepth; + std::optional ChildrenRecurseDepth; + std::optional SymbolOffset; bool JustMyCode; }; diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h b/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h index 429c06f29ac7..01f13ce1073e 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 @@ public: protected: codeview::TypeIndex Index; - Optional Record; + std::optional Record; NativeTypeEnum *UnmodifiedType = nullptr; - Optional Modifiers; + std::optional Modifiers; }; } // namespace pdb diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h b/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h index 1f357754ac0f..184e00086849 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 @@ public: protected: bool isMemberPointer() const; codeview::TypeIndex TI; - Optional Record; + std::optional Record; }; } // namespace pdb diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h b/llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h index a1dd39c0b4be..79924a78cd21 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 @@ public: protected: codeview::TypeIndex Index; - Optional Class; - Optional Union; + std::optional Class; + std::optional Union; NativeTypeUDT *UnmodifiedType = nullptr; codeview::TagRecord *Tag = nullptr; - Optional Modifiers; + std::optional Modifiers; }; } // namespace pdb diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h b/llvm/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h index 9f320358144c..855b5fe1f931 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 @@ public: TpiStreamBuilder &operator=(const TpiStreamBuilder &) = delete; void setVersionHeader(PdbRaw_TpiVer Version); - void addTypeRecord(ArrayRef Type, Optional Hash); + void addTypeRecord(ArrayRef Type, std::optional Hash); void addTypeRecords(ArrayRef Types, ArrayRef Sizes, ArrayRef Hashes); diff --git a/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h b/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h index 91748e15ba65..f799b0a4cde0 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 @@ -34,7 +33,7 @@ class SourceCode; struct Request { StringRef ModuleName; - Optional Address; + std::optional Address; }; class DIPrinter { diff --git a/llvm/include/llvm/DebugInfo/Symbolize/Markup.h b/llvm/include/llvm/DebugInfo/Symbolize/Markup.h index 0061d5997693..c6242267f1e2 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 @@ public: /// previous call. /// /// \returns the next markup node or None if none remain. - Optional nextNode(); + std::optional nextNode(); bool isSGR(const MarkupNode &Node) const { return SGRSyntax.match(Node.Text); } private: - Optional parseElement(StringRef Line); + std::optional parseElement(StringRef Line); void parseTextOutsideMarkup(StringRef Text); - Optional parseMultiLineBegin(StringRef Line); - Optional parseMultiLineEnd(StringRef Line); + std::optional parseMultiLineBegin(StringRef Line); + std::optional 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 27c07f7942c7..534255640075 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 ColorsEnabled = std::nullopt); + std::optional ColorsEnabled = std::nullopt); /// Filters a line containing symbolizer markup and writes the human-readable /// results to the output stream. @@ -110,16 +110,16 @@ private: void printRawElement(const MarkupNode &Element); void printValue(Twine Value); - Optional parseModule(const MarkupNode &Element) const; - Optional parseMMap(const MarkupNode &Element) const; + std::optional parseModule(const MarkupNode &Element) const; + std::optional parseMMap(const MarkupNode &Element) const; - Optional parseAddr(StringRef Str) const; - Optional parseModuleID(StringRef Str) const; - Optional parseSize(StringRef Str) const; - Optional> parseBuildID(StringRef Str) const; - Optional parseMode(StringRef Str) const; - Optional parsePCType(StringRef Str) const; - Optional parseFrameNumber(StringRef Str) const; + std::optional parseAddr(StringRef Str) const; + std::optional parseModuleID(StringRef Str) const; + std::optional parseSize(StringRef Str) const; + std::optional> parseBuildID(StringRef Str) const; + std::optional parseMode(StringRef Str) const; + std::optional parsePCType(StringRef Str) const; + std::optional parseFrameNumber(StringRef Str) const; bool checkTag(const MarkupNode &Node) const; bool checkNumFields(const MarkupNode &Element, size_t Size) const; @@ -147,10 +147,10 @@ private: // A module info line currently being built. This incorporates as much mmap // information as possible before being emitted. - Optional MIL; + std::optional MIL; // SGR state. - Optional Color; + std::optional 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 f6ea91a7b591..a9bbe41125b1 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 llvm::dwarf::LanguageLowerBound(dwarf::SourceLanguage Lang) { +std::optional +llvm::dwarf::LanguageLowerBound(dwarf::SourceLanguage Lang) { switch (Lang) { default: return std::nullopt; @@ -691,8 +692,8 @@ StringRef llvm::dwarf::IndexString(unsigned Idx) { } } -Optional llvm::dwarf::getFixedFormByteSize(dwarf::Form Form, - FormParams Params) { +std::optional 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 b9e44d023294..a3777438bba3 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 B = Table.getFirst(); + std::optional 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 617ddbd66e4e..f324eada6a07 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 FixedSize = + if (std::optional FixedSize = dwarf::getFixedFormByteSize(Form, FormParams)) return *FixedSize; diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp index e067828ed079..b559f14fdc56 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 Name = dwarf::toString(DIE.find(dwarf::DW_AT_name)); + std::optional 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 HighPc = DIE.getHighPC(*LowPc); + std::optional 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 String = dwarf::toString(Val); + std::optional 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 AddrOffsetSectionBase = + if (std::optional 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 Ref; + std::optional 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 1cb20c0bb948..77d914aec79a 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 Value; + std::optional 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 f0ffb41142f6..dc32e8336927 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 AppendingTypeTableBuilder::getFirst() { +std::optional AppendingTypeTableBuilder::getFirst() { if (empty()) return std::nullopt; return TypeIndex(TypeIndex::FirstNonSimpleIndex); } -Optional AppendingTypeTableBuilder::getNext(TypeIndex Prev) { +std::optional 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 5da300f710d5..689c643a7006 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 I = Types.getFirst(); + std::optional 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 a66f9af98835..55fafa8472d7 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 MaxLength) { +Error CodeViewRecordIO::beginRecord(std::optional 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 Min = Limits.front().bytesRemaining(Offset); + std::optional Min = Limits.front().bytesRemaining(Offset); for (auto X : makeArrayRef(Limits).drop_front()) { - Optional ThisMin = X.bytesRemaining(Offset); + std::optional 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 a3dbb3954d5c..fa59e7f9dba1 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 RefersTo) { + uint32_t OffBegin, uint32_t OffEnd, std::optional RefersTo) { assert(OffEnd - OffBegin <= USHRT_MAX); MutableArrayRef Data = Buffer.data(); @@ -228,7 +228,7 @@ std::vector ContinuationRecordBuilder::end(TypeIndex Index) { uint32_t End = SegmentWriter.getOffset(); - Optional RefersTo; + std::optional 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 24e8b583201b..1428d3038e77 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 GlobalTypeTableBuilder::getFirst() { +std::optional GlobalTypeTableBuilder::getFirst() { if (empty()) return std::nullopt; return TypeIndex(TypeIndex::FirstNonSimpleIndex); } -Optional GlobalTypeTableBuilder::getNext(TypeIndex Prev) { +std::optional 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 5e6a2e05d937..28771bd805fc 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 LazyRandomTypeCollection::tryGetType(TypeIndex Index) { +std::optional LazyRandomTypeCollection::tryGetType(TypeIndex Index) { if (Index.isSimple()) return std::nullopt; @@ -202,7 +202,7 @@ Error LazyRandomTypeCollection::visitRangeForType(TypeIndex TI) { return Error::success(); } -Optional LazyRandomTypeCollection::getFirst() { +std::optional LazyRandomTypeCollection::getFirst() { TypeIndex TI = TypeIndex::fromArrayIndex(0); if (auto EC = ensureTypeExists(TI)) { consumeError(std::move(EC)); @@ -211,7 +211,7 @@ Optional LazyRandomTypeCollection::getFirst() { return TI; } -Optional LazyRandomTypeCollection::getNext(TypeIndex Prev) { +std::optional 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 70a1878d13b1..24fe29192809 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 MergingTypeTableBuilder::getFirst() { +std::optional MergingTypeTableBuilder::getFirst() { if (empty()) return std::nullopt; return TypeIndex(TypeIndex::FirstNonSimpleIndex); } -Optional MergingTypeTableBuilder::getNext(TypeIndex Prev) { +std::optional 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 7f4511258c64..876def851e29 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 MaxLen; + std::optional 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 fdc649439682..37b1c001c0bd 100644 --- a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp +++ b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp @@ -79,7 +79,7 @@ public: Error mergeTypesAndIds(MergingTypeTableBuilder &DestIds, MergingTypeTableBuilder &DestTypes, const CVTypeArray &IdsAndTypes, - Optional &PCHInfo); + std::optional &PCHInfo); Error mergeIdRecords(MergingTypeTableBuilder &Dest, ArrayRef TypeSourceToDest, const CVTypeArray &Ids); @@ -91,14 +91,14 @@ public: GlobalTypeTableBuilder &DestTypes, const CVTypeArray &IdsAndTypes, ArrayRef Hashes, - Optional &PCHInfo); + std::optional &PCHInfo); Error mergeIdRecords(GlobalTypeTableBuilder &Dest, ArrayRef TypeSourceToDest, const CVTypeArray &Ids, ArrayRef Hashes); Error mergeTypeRecords(GlobalTypeTableBuilder &Dest, const CVTypeArray &Types, ArrayRef Hashes, - Optional &PCHInfo); + std::optional &PCHInfo); private: Error doit(const CVTypeArray &Types); @@ -198,7 +198,7 @@ private: /// its type indices. SmallVector RemapStorage; - Optional PCHInfo; + std::optional 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 &PCHInfo) { +Error TypeStreamMerger::mergeTypesAndIds( + MergingTypeTableBuilder &DestIds, MergingTypeTableBuilder &DestTypes, + const CVTypeArray &IdsAndTypes, std::optional &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 Hashes, - Optional &PCHInfo) { +Error TypeStreamMerger::mergeTypeRecords( + GlobalTypeTableBuilder &Dest, const CVTypeArray &Types, + ArrayRef Hashes, + std::optional &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 Hashes, - Optional &PCHInfo) { +Error TypeStreamMerger::mergeTypesAndIds( + GlobalTypeTableBuilder &DestIds, GlobalTypeTableBuilder &DestTypes, + const CVTypeArray &IdsAndTypes, ArrayRef Hashes, + std::optional &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 &SourceToDest, const CVTypeArray &IdsAndTypes, - Optional &PCHInfo) { + std::optional &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 &SourceToDest, const CVTypeArray &IdsAndTypes, - ArrayRef Hashes, Optional &PCHInfo) { + ArrayRef Hashes, + std::optional &PCHInfo) { TypeStreamMerger M(SourceToDest); return M.mergeTypesAndIds(DestIds, DestTypes, IdsAndTypes, Hashes, PCHInfo); } @@ -465,7 +464,7 @@ Error llvm::codeview::mergeTypeRecords(GlobalTypeTableBuilder &Dest, SmallVectorImpl &SourceToDest, const CVTypeArray &Types, ArrayRef Hashes, - Optional &PCHInfo) { + std::optional &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 4cd19add0616..50ac6fc5906d 100644 --- a/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp +++ b/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp @@ -21,13 +21,13 @@ TypeTableCollection::TypeTableCollection(ArrayRef> Records) Names.resize(Records.size()); } -Optional TypeTableCollection::getFirst() { +std::optional TypeTableCollection::getFirst() { if (empty()) return std::nullopt; return TypeIndex::fromArrayIndex(0); } -Optional TypeTableCollection::getNext(TypeIndex Prev) { +std::optional 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 fb2aa7b61983..2b5995cb7f53 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 ByteSize; + std::optional 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 +std::optional 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 +std::optional 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 +std::optional 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 MatchAttrIndex = findAttributeIndex(Attr); + std::optional MatchAttrIndex = findAttributeIndex(Attr); if (!MatchAttrIndex) return std::nullopt; @@ -210,20 +210,20 @@ size_t DWARFAbbreviationDeclaration::FixedSizeInfo::getByteSize( return ByteSize; } -Optional DWARFAbbreviationDeclaration::AttributeSpec::getByteSize( +std::optional DWARFAbbreviationDeclaration::AttributeSpec::getByteSize( const DWARFUnit &U) const { if (isImplicitConst()) return 0; if (ByteSize.HasByteSize) return ByteSize.ByteSize; - Optional S; + std::optional S; auto FixedByteSize = dwarf::getFixedFormByteSize(Form, U.getFormParams()); if (FixedByteSize) S = *FixedByteSize; return S; } -Optional DWARFAbbreviationDeclaration::getFixedAttributesByteSize( +std::optional 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 0e85160b5737..889d3f0915b0 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 AppleAcceleratorTable::HeaderData::extractOffset( - Optional Value) const { +std::optional AppleAcceleratorTable::HeaderData::extractOffset( + std::optional 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 Val = Atom.getAsUnsignedConstant()) { + if (std::optional 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 +std::optional 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 AppleAcceleratorTable::Entry::getDIESectionOffset() const { +std::optional +AppleAcceleratorTable::Entry::getDIESectionOffset() const { return HdrData->extractOffset(lookup(dwarf::DW_ATOM_die_offset)); } -Optional AppleAcceleratorTable::Entry::getCUOffset() const { +std::optional AppleAcceleratorTable::Entry::getCUOffset() const { return HdrData->extractOffset(lookup(dwarf::DW_ATOM_cu_offset)); } -Optional AppleAcceleratorTable::Entry::getTag() const { - Optional Tag = lookup(dwarf::DW_ATOM_die_tag); +std::optional AppleAcceleratorTable::Entry::getTag() const { + std::optional Tag = lookup(dwarf::DW_ATOM_die_tag); if (!Tag) return std::nullopt; - if (Optional Value = Tag->getAsUnsignedConstant()) + if (std::optional 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 +std::optional 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 DWARFDebugNames::Entry::getDIEUnitOffset() const { - if (Optional Off = lookup(dwarf::DW_IDX_die_offset)) +std::optional DWARFDebugNames::Entry::getDIEUnitOffset() const { + if (std::optional Off = lookup(dwarf::DW_IDX_die_offset)) return Off->getAsReferenceUVal(); return std::nullopt; } -Optional DWARFDebugNames::Entry::getCUIndex() const { - if (Optional Off = lookup(dwarf::DW_IDX_compile_unit)) +std::optional DWARFDebugNames::Entry::getCUIndex() const { + if (std::optional 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 DWARFDebugNames::Entry::getCUIndex() const { return std::nullopt; } -Optional DWARFDebugNames::Entry::getCUOffset() const { - Optional Index = getCUIndex(); +std::optional DWARFDebugNames::Entry::getCUOffset() const { + std::optional 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 Hash) const { + std::optional 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 +std::optional 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 Offset = findEntryOffsetInCurrentIndex(); + std::optional 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 e1d74310a51a..d7118b835a0d 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>; + std::vector>; // 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 &L, - const Optional &R) { + [](const std::optional &L, + const std::optional &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 &L, - const Optional &R) { + [](const std::optional &L, + const std::optional &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(uint32_t)> + llvm::function_ref(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 DumpOffset) { + std::optional 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, DIDT_ID_Count> DumpOffsets) { + std::array, 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 * { + StringRef Section) -> std::optional * { unsigned Mask = 1U << ID; bool Should = (DumpType & Mask) && (Explicit || !Section.empty()); if (!Should) @@ -459,7 +459,7 @@ void DWARFContext::dump( } } - if (const Optional *Off = + if (const std::optional *Off = shouldDump(Explicit, ".debug_frame", DIDT_ID_DebugFrame, DObj->getFrameSection().Data)) { if (Expected DF = getDebugFrame()) @@ -468,7 +468,7 @@ void DWARFContext::dump( RecoverableErrorHandler(DF.takeError()); } - if (const Optional *Off = + if (const std::optional *Off = shouldDump(Explicit, ".eh_frame", DIDT_ID_DebugFrame, DObj->getEHFrameSection().Data)) { if (Expected DF = getEHFrame()) @@ -519,7 +519,7 @@ void DWARFContext::dump( auto DumpLineSection = [&](DWARFDebugLine::SectionParser Parser, DIDumpOptions DumpOpts, - Optional DumpOffset) { + std::optional 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 { + auto LookupPooledAddress = + [&](uint32_t Index) -> std::optional { 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> ⤅ + std::optional> ⤅ }; 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 DWOId = - toUnsigned(DWOCU->getUnitDIE().find(DW_AT_GNU_dwo_id))) + if (std::optional 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 &StartAddress) { + std::optional &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 +static std::optional getExpressionFrameOffset(ArrayRef Expr, - Optional FrameBaseReg) { + std::optional 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 FrameBaseReg; + std::optional FrameBaseReg; if (auto FrameBase = Subprogram.find(DW_AT_frame_base)) - if (Optional> Expr = FrameBase->getAsBlock()) + if (std::optional> 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> Loc = Die.getLocations(DW_AT_location)) { for (const auto &Entry : *Loc) { - if (Optional FrameOffset = + if (std::optional 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 Name = dwarf::toString(*NameAttr)) + if (std::optional 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 StartAddress; + std::optional StartAddress; getFunctionNameAndStartLineForAddress(CU, Address.Address, Spec.FNKind, Spec.FLIKind, FunctionName, StartFileName, StartLine, StartAddress); @@ -1846,9 +1847,9 @@ public: if (Supports && Supports(Reloc.getType())) { auto I = Map->try_emplace( Reloc.getOffset(), - RelocAddrEntry{SymInfoOrErr->SectionIndex, Reloc, - SymInfoOrErr->Address, - Optional(), 0, Resolver}); + RelocAddrEntry{ + SymInfoOrErr->SectionIndex, Reloc, SymInfoOrErr->Address, + std::optional(), 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 ff6ed2b66756..97434b3cfab8 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 +std::optional 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 fa13491e83b9..98eaf1a095d9 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp @@ -177,9 +177,8 @@ Expected DWARFDebugAddrTable::getAddrEntry(uint32_t Index) const { Index, Offset); } -Optional DWARFDebugAddrTable::getFullLength() const { +std::optional 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 e9b657ea8271..2540291d0038 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 AddrSpace) { + std::optional AddrSpace) { return {RegPlusOffset, RegNum, Offset, AddrSpace, false}; } UnwindLocation UnwindLocation::createAtRegisterPlusOffset(uint32_t RegNum, int32_t Offset, - Optional AddrSpace) { + std::optional AddrSpace) { return {RegPlusOffset, RegNum, Offset, AddrSpace, true}; } @@ -571,7 +571,7 @@ Error UnwindTable::parseRows(const CFIProgram &CFIP, UnwindRow &Row, llvm::Expected RegNum = Inst.getOperandAsUnsigned(CFIP, 0); if (!RegNum) return RegNum.takeError(); - if (Optional O = + if (std::optional 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 Personality; - Optional PersonalityEncoding; + std::optional Personality; + std::optional PersonalityEncoding; if (IsEH) { std::optional 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 LSDAAddress; + std::optional 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 Offset) const { + std::optional 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 7dbeebc2770f..4cd22cda374a 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 FixedSize = AbbrevDecl->getFixedAttributesByteSize(U)) { + if (std::optional 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 2bce28fe8a03..5e56330ee732 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 DWARFDebugLine::Prologue::getLastValidFileIndex() const { +std::optional +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 -static Optional parseULEB128(DWARFDataExtractor &Data, - DataExtractor::Cursor &Cursor) { +static std::optional 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 Operand = + if (std::optional Operand = parseULEB128(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 File = + if (std::optional File = parseULEB128(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 Column = + if (std::optional Column = parseULEB128(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 Isa = parseULEB128(TableData, Cursor)) { + if (std::optional Isa = + parseULEB128(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 Operands; for (uint8_t I = 0; I < OpcodeLength; ++I) { - if (Optional Value = + if (std::optional Value = parseULEB128(TableData, Cursor)) Operands.push_back(*Value); else @@ -1330,8 +1332,9 @@ bool DWARFDebugLine::LineTable::lookupAddressRangeImpl( return true; } -Optional DWARFDebugLine::LineTable::getSourceByIndex(uint64_t FileIndex, - FileLineInfoKind Kind) const { +std::optional +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 6a44052e3474..58c3889f2cc4 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 Base; - std::function(uint32_t)> LookupAddr; + std::optional Base; + std::function(uint32_t)> LookupAddr; public: DWARFLocationInterpreter( - Optional Base, - std::function(uint32_t)> LookupAddr) + std::optional Base, + std::function(uint32_t)> + LookupAddr) : Base(Base), LookupAddr(std::move(LookupAddr)) {} - Expected> + Expected> Interpret(const DWARFLocationEntry &E); }; } // namespace @@ -48,7 +49,7 @@ static Error createResolverError(uint32_t Index, unsigned Kind) { return make_error(Index, (dwarf::LoclistEntries)Kind); } -Expected> +Expected> 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 LowPC = LookupAddr(E.Value0); + std::optional LowPC = LookupAddr(E.Value0); if (!LowPC) return createResolverError(E.Value0, E.Kind); - Optional HighPC = LookupAddr(E.Value1); + std::optional 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 LowPC = LookupAddr(E.Value0); + std::optional 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 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 BaseAddr, + const MCRegisterInfo *MRI, const DWARFObject &Obj, DWARFUnit *U, + DIDumpOptions DumpOpts, unsigned Indent) const { DWARFLocationInterpreter Interp( - BaseAddr, [U](uint32_t Index) -> Optional { + BaseAddr, [U](uint32_t Index) -> std::optional { if (U) return U->getAddrOffsetSectionItem(Index); return std::nullopt; }); OS << format("0x%8.8" PRIx64 ": ", *Offset); Error E = visitLocationList(Offset, [&](const DWARFLocationEntry &E) { - Expected> Loc = Interp.Interpret(E); + Expected> 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 BaseAddr, - std::function(uint32_t)> LookupAddr, + uint64_t Offset, std::optional BaseAddr, + std::function(uint32_t)> LookupAddr, function_ref)> Callback) const { DWARFLocationInterpreter Interp(BaseAddr, std::move(LookupAddr)); return visitLocationList(&Offset, [&](const DWARFLocationEntry &E) { - Expected> Loc = Interp.Interpret(E); + Expected> 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 DumpOffset) const { + std::optional 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 80daea64814a..4d52046ba9ba 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 Units, - Optional StringExtractor, DWARFDataExtractor Data, + std::optional Units, + std::optional 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 cad3dcab8a7e..db01719bed59 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 BaseAddr) const { + std::optional 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 d12acca1962e..b428c2adfe0b 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 BaseAddr, DWARFUnit &U) const { + std::optional BaseAddr, DWARFUnit &U) const { return getAbsoluteRanges( BaseAddr, U.getAddressByteSize(), [&](uint32_t Index) { return U.getAddrOffsetSectionItem(Index); }); } DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges( - Optional BaseAddr, uint8_t AddressByteSize, - function_ref(uint32_t)> + std::optional BaseAddr, uint8_t AddressByteSize, + function_ref(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(uint32_t)> + llvm::function_ref(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 d6f0ee4312e8..9c94b5121a5b 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 Val = FormValue.getAsUnsignedConstant()) { + if (std::optional 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 Val = FormValue.getAsUnsignedConstant()) + } else if (std::optional 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 Val = FormValue.getAsUnsignedConstant()) + if (std::optional 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 OptVal = FormValue.getAsUnsignedConstant()) + if (std::optional 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 DWARFDie::find(dwarf::Attribute Attr) const { +std::optional DWARFDie::find(dwarf::Attribute Attr) const { if (!isValid()) return std::nullopt; auto AbbrevDecl = getAbbreviationDeclarationPtr(); @@ -258,7 +258,7 @@ Optional DWARFDie::find(dwarf::Attribute Attr) const { return std::nullopt; } -Optional +std::optional DWARFDie::find(ArrayRef Attrs) const { if (!isValid()) return std::nullopt; @@ -272,7 +272,7 @@ DWARFDie::find(ArrayRef Attrs) const { return std::nullopt; } -Optional +std::optional DWARFDie::findRecursively(ArrayRef Attrs) const { SmallVector Worklist; Worklist.push_back(*this); @@ -307,7 +307,7 @@ DWARFDie::findRecursively(ArrayRef Attrs) const { DWARFDie DWARFDie::getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const { - if (Optional F = find(Attr)) + if (std::optional 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 Sig = Attr->getAsReferenceUVal()) { + if (std::optional 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 DWARFDie::getRangesBaseAttribute() const { +std::optional DWARFDie::getRangesBaseAttribute() const { return toSectionOffset(find({DW_AT_rnglists_base, DW_AT_GNU_ranges_base})); } -Optional DWARFDie::getLocBaseAttribute() const { +std::optional DWARFDie::getLocBaseAttribute() const { return toSectionOffset(find(DW_AT_loclists_base)); } -Optional DWARFDie::getHighPC(uint64_t LowPC) const { +std::optional DWARFDie::getHighPC(uint64_t LowPC) const { uint64_t Tombstone = dwarf::computeTombstoneAddress(U->getAddressByteSize()); if (LowPC == Tombstone) return std::nullopt; @@ -385,7 +385,7 @@ Expected DWARFDie::getAddressRanges() const { if (getLowAndHighPC(LowPC, HighPC, Index)) return DWARFAddressRangesVector{{LowPC, HighPC, Index}}; - Optional Value = find(DW_AT_ranges); + std::optional 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 DWARFDie::getLocations(dwarf::Attribute Attr) const { - Optional Location = find(Attr); + std::optional Location = find(Attr); if (!Location) return createStringError(inconvertibleErrorCode(), "No %s", dwarf::AttributeString(Attr).data()); - if (Optional Off = Location->getAsSectionOffset()) { + if (std::optional 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> Expr = Location->getAsBlock()) { + if (std::optional> 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 DWARFDie::getTypeSize(uint64_t PointerSize) { +std::optional DWARFDie::getTypeSize(uint64_t PointerSize) { if (auto SizeAttr = find(DW_AT_byte_size)) - if (Optional Size = SizeAttr->getAsUnsignedConstant()) + if (std::optional Size = SizeAttr->getAsUnsignedConstant()) return Size; switch (getTag()) { @@ -521,7 +521,7 @@ Optional DWARFDie::getTypeSize(uint64_t PointerSize) { DWARFDie BaseType = getAttributeValueAsReferencedDie(DW_AT_type); if (!BaseType) return std::nullopt; - Optional BaseSize = BaseType.getTypeSize(PointerSize); + std::optional BaseSize = BaseType.getTypeSize(PointerSize); if (!BaseSize) return std::nullopt; uint64_t Size = *BaseSize; @@ -530,11 +530,11 @@ Optional DWARFDie::getTypeSize(uint64_t PointerSize) { continue; if (auto ElemCountAttr = Child.find(DW_AT_count)) - if (Optional ElemCount = + if (std::optional ElemCount = ElemCountAttr->getAsUnsignedConstant()) Size *= *ElemCount; if (auto UpperBoundAttr = Child.find(DW_AT_upper_bound)) - if (Optional UpperBound = + if (std::optional 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 ParentIdx = Die->getParentIdx()) + if (std::optional 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 b9d5ddd8ab9d..061b656bf9aa 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 Format) { + std::optional Format) { EndOffset = Offset; Opcode = Data.getU8(&Offset); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp index 99b92f11cfdb..5be55f26688b 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 FixedSize = + if (std::optional FixedSize = dwarf::getFixedFormByteSize(Form, Params)) { *OffsetPtr += *FixedSize; return true; @@ -427,7 +427,8 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const { OS << ""; break; } - Optional A = U->getAddrOffsetSectionItem(UValue); + std::optional 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 A = U->getAddrOffsetSectionItem(Index); + std::optional 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 DWARFFormValue::getAsCString() const { inconvertibleErrorCode()); } -Optional DWARFFormValue::getAsAddress() const { +std::optional DWARFFormValue::getAsAddress() const { if (auto SA = getAsSectionedAddress()) return SA->Address; return std::nullopt; } -Optional +std::optional 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 SA = U->getAddrOffsetSectionItem(Index); + std::optional SA = + U->getAddrOffsetSectionItem(Index); if (!SA) return std::nullopt; if (AddrOffset) @@ -692,13 +695,14 @@ DWARFFormValue::getAsSectionedAddress() const { return {{Value.uval, Value.SectionIndex}}; } -Optional DWARFFormValue::getAsReference() const { +std::optional DWARFFormValue::getAsReference() const { if (auto R = getAsRelativeReference()) return R->Unit ? R->Unit->getOffset() + R->Offset : R->Offset; return std::nullopt; } -Optional DWARFFormValue::getAsRelativeReference() const { +std::optional +DWARFFormValue::getAsRelativeReference() const { if (!isFormClass(FC_Reference)) return std::nullopt; switch (Form) { @@ -719,20 +723,20 @@ Optional DWARFFormValue::getAsRelativeReference() co } } -Optional DWARFFormValue::getAsSectionOffset() const { +std::optional DWARFFormValue::getAsSectionOffset() const { if (!isFormClass(FC_SectionOffset)) return std::nullopt; return Value.uval; } -Optional DWARFFormValue::getAsUnsignedConstant() const { +std::optional DWARFFormValue::getAsUnsignedConstant() const { if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) || Form == DW_FORM_sdata) return std::nullopt; return Value.uval; } -Optional DWARFFormValue::getAsSignedConstant() const { +std::optional DWARFFormValue::getAsSignedConstant() const { if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) || (Form == DW_FORM_udata && uint64_t(std::numeric_limits::max()) < Value.uval)) @@ -751,26 +755,26 @@ Optional DWARFFormValue::getAsSignedConstant() const { } } -Optional> DWARFFormValue::getAsBlock() const { +std::optional> DWARFFormValue::getAsBlock() const { if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc) && Form != DW_FORM_data16) return std::nullopt; return makeArrayRef(Value.data, Value.uval); } -Optional DWARFFormValue::getAsCStringOffset() const { +std::optional DWARFFormValue::getAsCStringOffset() const { if (!isFormClass(FC_String) && Form == DW_FORM_string) return std::nullopt; return Value.uval; } -Optional DWARFFormValue::getAsReferenceUVal() const { +std::optional DWARFFormValue::getAsReferenceUVal() const { if (!isFormClass(FC_Reference)) return std::nullopt; return Value.uval; } -Optional +std::optional 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 aca0932e0f61..6a1423d37d9f 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 LB; - Optional Count; - Optional UB; - Optional DefaultLB; - if (Optional L = C.find(DW_AT_lower_bound)) + std::optional LB; + std::optional Count; + std::optional UB; + std::optional DefaultLB; + if (std::optional L = C.find(DW_AT_lower_bound)) LB = L->getAsUnsignedConstant(); - if (Optional CountV = C.find(DW_AT_count)) + if (std::optional CountV = C.find(DW_AT_count)) Count = CountV->getAsUnsignedConstant(); - if (Optional UpperV = C.find(DW_AT_upper_bound)) + if (std::optional UpperV = C.find(DW_AT_upper_bound)) UB = UpperV->getAsUnsignedConstant(); - if (Optional LV = + if (std::optional LV = D.getDwarfUnit()->getUnitDIE().find(DW_AT_language)) - if (Optional LC = LV->getAsUnsignedConstant()) + if (std::optional LC = LV->getAsUnsignedConstant()) if ((DefaultLB = LanguageLowerBound(static_cast(*LC)))) if (LB && *LB == *DefaultLB) diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index 77b2b68ef62f..522357b7edc1 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 +std::optional 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 DWOId = toUnsigned(UnitDie.find(DW_AT_GNU_dwo_id))) + if (std::optional 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 Size = Die.getTypeSize(getAddressByteSize())) + if (std::optional 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 ParentIdx = Die->getParentIdx()) { + if (std::optional 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 SiblingIdx = Die->getSiblingIdx()) { + if (std::optional 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 ParentIdx = Die->getParentIdx(); + std::optional 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 SiblingIdx = Die->getSiblingIdx()) { + if (std::optional 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 DWARFUnit::getBaseAddress() { +std::optional DWARFUnit::getBaseAddress() { if (BaseAddr) return BaseAddr; DWARFDie UnitDie = getUnitDIE(); - Optional PC = UnitDie.find({DW_AT_low_pc, DW_AT_entry_pc}); + std::optional 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> +Expected> 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> -DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor & DA) { +Expected> +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 DWARFUnit::getRnglistOffset(uint32_t Index) { +std::optional DWARFUnit::getRnglistOffset(uint32_t Index) { DataExtractor RangesData(RangeSection->Data, IsLittleEndian, getAddressByteSize()); DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection, IsLittleEndian, 0); - if (Optional Off = llvm::DWARFListTableHeader::getOffsetEntry( + if (std::optional Off = llvm::DWARFListTableHeader::getOffsetEntry( RangesData, RangeSectionBase, getFormat(), Index)) return *Off + RangeSectionBase; return std::nullopt; } -Optional DWARFUnit::getLoclistOffset(uint32_t Index) { - if (Optional Off = llvm::DWARFListTableHeader::getOffsetEntry( +std::optional DWARFUnit::getLoclistOffset(uint32_t Index) { + if (std::optional 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 26e92781c5fd..20cd0560333e 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -43,7 +43,7 @@ namespace llvm { class DWARFDebugInfoEntry; } -Optional +std::optional 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 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 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 LastFileIdx = LT->getLastValidFileIndex()) { + if (std::optional 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 RefVal = AttrValue.Value.getAsReference(); + std::optional 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 RefVal = AttrValue.Value.getAsReference(); + std::optional 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 b7e03e9885a3..d266960ae302 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 DWOId = DwarfUnit.getDWOId()) { + if (std::optional 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 b7d711d0f875..51058fc09cf1 100644 --- a/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp +++ b/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp @@ -227,7 +227,7 @@ llvm::Expected FunctionInfo::lookup(DataExtractor &Data, return LR; } - Optional LineEntryFile = GR.getFile(LineEntry->File); + std::optional 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 352af91fa957..6afaeea8f598 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 GsymReader::getAddress(size_t Index) const { +std::optional GsymReader::getAddress(size_t Index) const { switch (Hdr->AddrOffSize) { case 1: return addressForIndex(Index); case 2: return addressForIndex(Index); @@ -216,7 +216,7 @@ Optional GsymReader::getAddress(size_t Index) const { return std::nullopt; } -Optional GsymReader::getAddressInfoOffset(size_t Index) const { +std::optional GsymReader::getAddressInfoOffset(size_t Index) const { const auto NumAddrInfoOffsets = AddrInfoOffsets.size(); if (Index < NumAddrInfoOffsets) return AddrInfoOffsets[Index]; @@ -227,7 +227,7 @@ Expected GsymReader::getAddressIndex(const uint64_t Addr) const { if (Addr >= Hdr->BaseAddress) { const uint64_t AddrOffset = Addr - Hdr->BaseAddress; - Optional AddrOffsetIndex; + std::optional AddrOffsetIndex; switch (Hdr->AddrOffSize) { case 1: AddrOffsetIndex = getAddressOffsetIndex(AddrOffset); @@ -262,7 +262,7 @@ llvm::Expected GsymReader::getFunctionInfo(uint64_t Addr) const { assert(*AddressIndex < AddrInfoOffsets.size()); auto AddrInfoOffset = AddrInfoOffsets[*AddressIndex]; DataExtractor Data(MemBuffer->getBuffer().substr(AddrInfoOffset), Endian, 4); - if (Optional OptAddr = getAddress(*AddressIndex)) { + if (std::optional 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 GsymReader::lookup(uint64_t Addr) const { assert(*AddressIndex < AddrInfoOffsets.size()); auto AddrInfoOffset = AddrInfoOffsets[*AddressIndex]; DataExtractor Data(MemBuffer->getBuffer().substr(AddrInfoOffset), Endian, 4); - if (Optional OptAddr = getAddress(*AddressIndex)) + if (std::optional 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 FE) { +void GsymReader::dump(raw_ostream &OS, std::optional 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 54cbab88ae3e..f775ab8fb65c 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::getInlineStack(uint64_t Addr) const { +std::optional +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 CallFile = GR.getFile(Inline.CallFile); + std::optional 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 51ac39fefd3b..37bd53576483 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 Value = FormValue.getAsAddress()) { + if (std::optional 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 Address = FormValue.getAsAddress()) + if (std::optional Address = FormValue.getAsAddress()) // High PC is an address. CurrentHighPC = *Address; - if (Optional Offset = FormValue.getAsUnsignedConstant()) + if (std::optional 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 LinkageDIE = + std::optional 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 DWOFileName = + std::optional 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 LoclistOffset = U->getLoclistOffset(Offset); + std::optional LoclistOffset = U->getLoclistOffset(Offset); if (!LoclistOffset) return; Offset = *LoclistOffset; } uint64_t BaseAddr = 0; - if (Optional BA = U->getBaseAddress()) + if (std::optional 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 247406c49efc..ee4078a20b72 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 +std::optional 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 3a719bd07c8a..fdb8c1bf2ad5 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 6912b8dc838e..2c3b19c7e567 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 Kinds) : Index(0), Session(PDBSession) { - Optional TI = Types.getFirst(); + std::optional 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 7eede122f669..dba00b451ef6 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 +static std::optional 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 CodeOffsetBase; - Optional CodeOffsetEnd; - Optional CurLineOffset; - Optional NextLineOffset; - Optional NextFileOffset; + std::optional CodeOffsetBase; + std::optional CodeOffsetEnd; + std::optional CurLineOffset; + std::optional NextLineOffset; + std::optional 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 Inlinee = + std::optional 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 641043a8e186..27df769ee6f2 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 Sig = Info->getSignature(); + std::optional 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 986e45e050c7..1c94194de3a2 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 Sizes) { } void TpiStreamBuilder::addTypeRecord(ArrayRef Record, - Optional Hash) { + std::optional 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 8557c755c5f7..bfd6f7c02ca3 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 MemBuf; - Optional load(StringRef FileName, - const Optional &EmbeddedSource) { + std::optional + load(StringRef FileName, const std::optional &EmbeddedSource) { if (Lines <= 0) return std::nullopt; @@ -48,7 +48,7 @@ class SourceCode { } } - Optional pruneSource(const Optional &Source) { + std::optional pruneSource(const std::optional &Source) { if (!Source) return std::nullopt; size_t FirstLinePos = StringRef::npos, Pos = 0; @@ -71,11 +71,11 @@ public: const int Lines; const int64_t FirstLine; const int64_t LastLine; - const Optional PrunedSource; + const std::optional PrunedSource; - SourceCode( - StringRef FileName, int64_t Line, int Lines, - const Optional &EmbeddedSource = Optional()) + SourceCode(StringRef FileName, int64_t Line, int Lines, + const std::optional &EmbeddedSource = + std::optional()) : Line(Line), Lines(Lines), FirstLine(std::max(static_cast(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 a6541162f468..ae3e24c0d500 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 MarkupParser::nextNode() { +std::optional MarkupParser::nextNode() { // Pull something out of the buffer if possible. if (!Buffer.empty()) { if (NextIdx < Buffer.size()) @@ -57,7 +57,7 @@ Optional MarkupParser::nextNode() { return std::nullopt; if (!InProgressMultiline.empty()) { - if (Optional MultilineEnd = parseMultiLineEnd(Line)) { + if (std::optional 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 MarkupParser::nextNode() { } // Find the first valid markup element, if any. - if (Optional Element = parseElement(Line)) { + if (std::optional 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 MarkupParser::nextNode() { // Since there were no valid elements remaining, see if the line opens a // multi-line element. - if (Optional MultilineBegin = parseMultiLineBegin(Line)) { + if (std::optional 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 MarkupParser::parseElement(StringRef Line) { +std::optional 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 MarkupParser::parseMultiLineBegin(StringRef Line) { +std::optional 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 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 MarkupParser::parseMultiLineEnd(StringRef Line) { +std::optional 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 c3b1e4d5b271..86fa52654a02 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 ColorsEnabled) + std::optional 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 Node = Parser.nextNode()) { + while (std::optional 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 Node = Parser.nextNode()) + while (std::optional Node = Parser.nextNode()) filterNode(*Node); endAnyModuleInfoLine(); resetColor(); @@ -96,7 +96,7 @@ bool MarkupFilter::tryMMap(const MarkupNode &Node, const SmallVector &DeferredNodes) { if (Node.Tag != "mmap") return false; - Optional ParsedMMap = parseMMap(Node); + std::optional ParsedMMap = parseMMap(Node); if (!ParsedMMap) return true; @@ -148,7 +148,7 @@ bool MarkupFilter::tryModule(const MarkupNode &Node, const SmallVector &DeferredNodes) { if (Node.Tag != "module") return false; - Optional ParsedModule = parseModule(Node); + std::optional ParsedModule = parseModule(Node); if (!ParsedModule) return true; @@ -243,7 +243,7 @@ bool MarkupFilter::tryPC(const MarkupNode &Node) { if (!checkNumFieldsAtMost(Node, 2)) return true; - Optional Addr = parseAddr(Node.Fields[0]); + std::optional 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 ParsedType = parsePCType(Node.Fields[1]); + std::optional 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 FrameNumber = parseFrameNumber(Node.Fields[0]); + std::optional FrameNumber = parseFrameNumber(Node.Fields[0]); if (!FrameNumber) return true; - Optional Addr = parseAddr(Node.Fields[1]); + std::optional 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 ParsedType = parsePCType(Node.Fields[2]); + std::optional 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 Addr = parseAddr(Node.Fields[0]); + std::optional 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 +std::optional 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 +std::optional 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 MarkupFilter::parseAddr(StringRef Str) const { +std::optional MarkupFilter::parseAddr(StringRef Str) const { if (Str.empty()) { reportTypeError(Str, "address"); return std::nullopt; @@ -567,7 +567,7 @@ Optional MarkupFilter::parseAddr(StringRef Str) const { } // Parse a module ID (%i in the spec). -Optional MarkupFilter::parseModuleID(StringRef Str) const { +std::optional MarkupFilter::parseModuleID(StringRef Str) const { uint64_t ID; if (Str.getAsInteger(0, ID)) { reportTypeError(Str, "module ID"); @@ -577,7 +577,7 @@ Optional MarkupFilter::parseModuleID(StringRef Str) const { } // Parse a size (%i in the spec). -Optional MarkupFilter::parseSize(StringRef Str) const { +std::optional MarkupFilter::parseSize(StringRef Str) const { uint64_t ID; if (Str.getAsInteger(0, ID)) { reportTypeError(Str, "size"); @@ -587,7 +587,7 @@ Optional MarkupFilter::parseSize(StringRef Str) const { } // Parse a frame number (%i in the spec). -Optional MarkupFilter::parseFrameNumber(StringRef Str) const { +std::optional MarkupFilter::parseFrameNumber(StringRef Str) const { uint64_t ID; if (Str.getAsInteger(10, ID)) { reportTypeError(Str, "frame number"); @@ -597,7 +597,8 @@ Optional MarkupFilter::parseFrameNumber(StringRef Str) const { } // Parse a build ID (%x in the spec). -Optional> MarkupFilter::parseBuildID(StringRef Str) const { +std::optional> +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> MarkupFilter::parseBuildID(StringRef Str) const { } // Parses the mode string for an mmap element. -Optional MarkupFilter::parseMode(StringRef Str) const { +std::optional MarkupFilter::parseMode(StringRef Str) const { if (Str.empty()) { reportTypeError(Str, "mode"); return std::nullopt; @@ -634,9 +635,10 @@ Optional MarkupFilter::parseMode(StringRef Str) const { return Str.lower(); } -Optional MarkupFilter::parsePCType(StringRef Str) const { - Optional Type = - StringSwitch>(Str) +std::optional +MarkupFilter::parsePCType(StringRef Str) const { + std::optional Type = + StringSwitch>(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 6c460a5f9c31..38ae5d8f821c 100644 --- a/llvm/lib/ProfileData/InstrProfCorrelator.cpp +++ b/llvm/lib/ProfileData/InstrProfCorrelator.cpp @@ -264,11 +264,11 @@ void DwarfInstrProfCorrelator::correlateProfileDataImpl( if (!isDIEOfProbe(Die)) return; Optional FunctionName; - Optional CFGHash; + std::optional CFGHash; Optional CounterPtr = getLocation(Die); auto FnDie = Die.getParent(); auto FunctionPtr = dwarf::toAddress(FnDie.find(dwarf::DW_AT_low_pc)); - Optional NumCounters; + std::optional 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 ac140338020a..d4fa73fc0f9a 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 LocationIdx = + std::optional 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 LowPcIdx = Abbrev->findAttributeIndex(dwarf::DW_AT_low_pc); + std::optional 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 AddrValue = DIE.find(dwarf::DW_AT_low_pc); - if (Optional AddrOffsetSectionBase = + std::optional AddrValue = DIE.find(dwarf::DW_AT_low_pc); + if (std::optional 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 cc7f353330b1..59e736183e57 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, (unsigned)DIDT_ID_Count> - DumpOffsets; +static std::array, (unsigned)DIDT_ID_Count> DumpOffsets; #define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME, OPTION) \ static opt