@@ -62,10 +62,10 @@ namespace bolt {
62
62
// / \param DIE die to look up in.
63
63
// / \param Attrs finds the first attribute that matches and extracts it.
64
64
// / \return an optional AttrInfo with DWARFFormValue and Offset.
65
- Optional <AttrInfo> findAttributeInfo (const DWARFDie DIE,
66
- std::vector<dwarf::Attribute> Attrs) {
65
+ std::optional <AttrInfo> findAttributeInfo (const DWARFDie DIE,
66
+ std::vector<dwarf::Attribute> Attrs) {
67
67
for (dwarf::Attribute &Attr : Attrs)
68
- if (Optional <AttrInfo> Info = findAttributeInfo (DIE, Attr))
68
+ if (std::optional <AttrInfo> Info = findAttributeInfo (DIE, Attr))
69
69
return Info;
70
70
return std::nullopt;
71
71
}
@@ -230,7 +230,7 @@ void DWARFRewriter::updateDebugInfo() {
230
230
231
231
auto updateDWONameCompDir = [&](DWARFUnit &Unit) -> void {
232
232
const DWARFDie &DIE = Unit.getUnitDIE ();
233
- Optional <AttrInfo> AttrInfoVal = findAttributeInfo (
233
+ std::optional <AttrInfo> AttrInfoVal = findAttributeInfo (
234
234
DIE, {dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name});
235
235
(void )AttrInfoVal;
236
236
assert (AttrInfoVal && " Skeleton CU doesn't have dwo_name." );
@@ -514,11 +514,11 @@ void DWARFRewriter::updateUnitDebugInfo(
514
514
}
515
515
};
516
516
517
- if (Optional <AttrInfo> AttrVal =
517
+ if (std::optional <AttrInfo> AttrVal =
518
518
findAttributeInfo (DIE, dwarf::DW_AT_call_pc))
519
519
patchPC (*AttrVal, " DW_AT_call_pc" );
520
520
521
- if (Optional <AttrInfo> AttrVal =
521
+ if (std::optional <AttrInfo> AttrVal =
522
522
findAttributeInfo (DIE, dwarf::DW_AT_call_return_pc))
523
523
patchPC (*AttrVal, " DW_AT_call_return_pc" );
524
524
@@ -528,7 +528,7 @@ void DWARFRewriter::updateUnitDebugInfo(
528
528
// Handle any tag that can have DW_AT_location attribute.
529
529
DWARFFormValue Value;
530
530
uint64_t AttrOffset;
531
- if (Optional <AttrInfo> AttrVal =
531
+ if (std::optional <AttrInfo> AttrVal =
532
532
findAttributeInfo (DIE, dwarf::DW_AT_location)) {
533
533
AttrOffset = AttrVal->Offset ;
534
534
Value = AttrVal->V ;
@@ -690,7 +690,7 @@ void DWARFRewriter::updateUnitDebugInfo(
690
690
SizeDiff + CurrEndOffset, 1 );
691
691
}
692
692
}
693
- } else if (Optional <AttrInfo> AttrVal =
693
+ } else if (std::optional <AttrInfo> AttrVal =
694
694
findAttributeInfo (DIE, dwarf::DW_AT_low_pc)) {
695
695
AttrOffset = AttrVal->Offset ;
696
696
Value = AttrVal->V ;
@@ -736,7 +736,7 @@ void DWARFRewriter::updateUnitDebugInfo(
736
736
}
737
737
} else if (IsDWP && Unit.isDWOUnit ()) {
738
738
// Not a common path so don't want to search all DIEs all the time.
739
- Optional <AttrInfo> SignatureAttrVal =
739
+ std::optional <AttrInfo> SignatureAttrVal =
740
740
findAttributeInfo (DIE, dwarf::DW_AT_signature);
741
741
if (!SignatureAttrVal)
742
742
continue ;
@@ -771,7 +771,8 @@ void DWARFRewriter::updateUnitDebugInfo(
771
771
case dwarf::DW_FORM_ref8:
772
772
case dwarf::DW_FORM_ref_udata:
773
773
case dwarf::DW_FORM_ref_addr: {
774
- Optional<AttrInfo> AttrVal = findAttributeInfo (DIE, AbbrevDecl, Index);
774
+ std::optional<AttrInfo> AttrVal =
775
+ findAttributeInfo (DIE, AbbrevDecl, Index);
775
776
uint32_t DestinationAddress =
776
777
AttrVal->V .getRawUValue () +
777
778
(Decl.Form == dwarf::DW_FORM_ref_addr ? 0 : Unit.getOffset ());
@@ -813,7 +814,7 @@ void DWARFRewriter::updateDWARFObjectAddressRanges(
813
814
if (RangesBase) {
814
815
// If DW_AT_GNU_ranges_base is present, update it. No further modifications
815
816
// are needed for ranges base.
816
- Optional <AttrInfo> RangesBaseAttrInfo =
817
+ std::optional <AttrInfo> RangesBaseAttrInfo =
817
818
findAttributeInfo (DIE, dwarf::DW_AT_GNU_ranges_base);
818
819
if (!RangesBaseAttrInfo)
819
820
RangesBaseAttrInfo = findAttributeInfo (DIE, dwarf::DW_AT_rnglists_base);
@@ -826,9 +827,9 @@ void DWARFRewriter::updateDWARFObjectAddressRanges(
826
827
}
827
828
}
828
829
829
- Optional <AttrInfo> LowPCAttrInfo =
830
+ std::optional <AttrInfo> LowPCAttrInfo =
830
831
findAttributeInfo (DIE, dwarf::DW_AT_low_pc);
831
- if (Optional <AttrInfo> AttrVal =
832
+ if (std::optional <AttrInfo> AttrVal =
832
833
findAttributeInfo (DIE, dwarf::DW_AT_ranges)) {
833
834
// Case 1: The object was already non-contiguous and had DW_AT_ranges.
834
835
// In this case we simply need to update the value of DW_AT_ranges
@@ -881,7 +882,7 @@ void DWARFRewriter::updateDWARFObjectAddressRanges(
881
882
882
883
// Case 2: The object has both DW_AT_low_pc and DW_AT_high_pc emitted back
883
884
// to back. Replace with new attributes and patch the DIE.
884
- Optional <AttrInfo> HighPCAttrInfo =
885
+ std::optional <AttrInfo> HighPCAttrInfo =
885
886
findAttributeInfo (DIE, dwarf::DW_AT_high_pc);
886
887
if (LowPCAttrInfo && HighPCAttrInfo) {
887
888
convertToRangesPatchAbbrev (*DIE.getDwarfUnit (), AbbreviationDecl,
@@ -937,7 +938,7 @@ void DWARFRewriter::updateLineTableOffsets(const MCAsmLayout &Layout) {
937
938
if (!Label)
938
939
continue ;
939
940
940
- Optional <AttrInfo> AttrVal =
941
+ std::optional <AttrInfo> AttrVal =
941
942
findAttributeInfo (CU.get ()->getUnitDIE (), dwarf::DW_AT_stmt_list);
942
943
if (!AttrVal)
943
944
continue ;
@@ -951,7 +952,7 @@ void DWARFRewriter::updateLineTableOffsets(const MCAsmLayout &Layout) {
951
952
952
953
for (const std::unique_ptr<DWARFUnit> &TU : BC.DwCtx ->types_section_units ()) {
953
954
DWARFUnit *Unit = TU.get ();
954
- Optional <AttrInfo> AttrVal =
955
+ std::optional <AttrInfo> AttrVal =
955
956
findAttributeInfo (TU.get ()->getUnitDIE (), dwarf::DW_AT_stmt_list);
956
957
if (!AttrVal)
957
958
continue ;
@@ -1039,9 +1040,9 @@ DWARFRewriter::finalizeDebugSections(DebugInfoBinaryPatcher &DebugInfoPatcher) {
1039
1040
uint64_t Offset = 0 ;
1040
1041
uint64_t AttrOffset = 0 ;
1041
1042
uint32_t Size = 0 ;
1042
- Optional <AttrInfo> AttrValGnu =
1043
+ std::optional <AttrInfo> AttrValGnu =
1043
1044
findAttributeInfo (DIE, dwarf::DW_AT_GNU_addr_base);
1044
- Optional <AttrInfo> AttrVal =
1045
+ std::optional <AttrInfo> AttrVal =
1045
1046
findAttributeInfo (DIE, dwarf::DW_AT_addr_base);
1046
1047
1047
1048
// For cases where Skeleton CU does not have DW_AT_GNU_addr_base
@@ -1827,8 +1828,8 @@ std::unique_ptr<DebugBufferVector> DWARFRewriter::makeFinalLocListsSection(
1827
1828
1828
1829
namespace {
1829
1830
1830
- void getRangeAttrData (DWARFDie DIE, Optional <AttrInfo> &LowPCVal,
1831
- Optional <AttrInfo> &HighPCVal) {
1831
+ void getRangeAttrData (DWARFDie DIE, std::optional <AttrInfo> &LowPCVal,
1832
+ std::optional <AttrInfo> &HighPCVal) {
1832
1833
LowPCVal = findAttributeInfo (DIE, dwarf::DW_AT_low_pc);
1833
1834
HighPCVal = findAttributeInfo (DIE, dwarf::DW_AT_high_pc);
1834
1835
uint64_t LowPCOffset = LowPCVal->Offset ;
@@ -1894,8 +1895,8 @@ void DWARFRewriter::convertToRangesPatchDebugInfo(
1894
1895
DWARFDie DIE, uint64_t RangesSectionOffset,
1895
1896
SimpleBinaryPatcher &DebugInfoPatcher, uint64_t LowPCToUse,
1896
1897
Optional<uint64_t > RangesBase) {
1897
- Optional <AttrInfo> LowPCVal;
1898
- Optional <AttrInfo> HighPCVal;
1898
+ std::optional <AttrInfo> LowPCVal;
1899
+ std::optional <AttrInfo> HighPCVal;
1899
1900
getRangeAttrData (DIE, LowPCVal, HighPCVal);
1900
1901
uint64_t LowPCOffset = LowPCVal->Offset ;
1901
1902
uint64_t HighPCOffset = HighPCVal->Offset ;
0 commit comments