[llvm] 5ec724d - [DWARFLinker] llvm::Optional => std::optional
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 13 02:14:16 PST 2022
Author: Fangrui Song
Date: 2022-12-13T10:14:09Z
New Revision: 5ec724d9506b986414d23c4b6be4a74f0230ec37
URL: https://github.com/llvm/llvm-project/commit/5ec724d9506b986414d23c4b6be4a74f0230ec37
DIFF: https://github.com/llvm/llvm-project/commit/5ec724d9506b986414d23c4b6be4a74f0230ec37.diff
LOG: [DWARFLinker] llvm::Optional => std::optional
Added:
Modified:
llvm/include/llvm/ADT/AddressRanges.h
llvm/include/llvm/DWARFLinker/DWARFLinker.h
llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
llvm/include/llvm/DWARFLinker/DWARFStreamer.h
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DWARFLinker/DWARFStreamer.cpp
llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/AddressRanges.h b/llvm/include/llvm/ADT/AddressRanges.h
index 1fd71034767d7..f2052d82e7c1f 100644
--- a/llvm/include/llvm/ADT/AddressRanges.h
+++ b/llvm/include/llvm/ADT/AddressRanges.h
@@ -9,10 +9,10 @@
#ifndef LLVM_ADT_ADDRESSRANGES_H
#define LLVM_ADT_ADDRESSRANGES_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include <cassert>
+#include <optional>
#include <stdint.h>
namespace llvm {
@@ -63,7 +63,7 @@ class AddressRanges {
bool contains(AddressRange Range) const {
return find(Range) != Ranges.end();
}
- Optional<AddressRange> getRangeThatContains(uint64_t Addr) const {
+ std::optional<AddressRange> getRangeThatContains(uint64_t Addr) const {
Collection::const_iterator It = find(Addr);
if (It == Ranges.end())
return std::nullopt;
@@ -125,7 +125,7 @@ template <typename T> class AddressRangesMap : protected AddressRanges {
assert(Ranges.size() == Values.size());
return AddressRanges::size();
}
- Optional<std::pair<AddressRange, T>>
+ std::optional<std::pair<AddressRange, T>>
getRangeValueThatContains(uint64_t Addr) const {
Collection::const_iterator It = find(Addr);
if (It == Ranges.end())
diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
index be8c8c2860e1a..8125adda78b0e 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
@@ -122,7 +122,7 @@ class DwarfEmitter {
/// original \p Entries.
virtual void emitRangesEntries(
int64_t UnitPcOffset, uint64_t OrigLowPc,
- Optional<std::pair<AddressRange, int64_t>> FuncRange,
+ std::optional<std::pair<AddressRange, int64_t>> FuncRange,
const std::vector<DWARFDebugRangeList::RangeListEntry> &Entries,
unsigned AddressSize) = 0;
diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h b/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
index 94ac62243647e..31b50c0c6a0ce 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
@@ -136,7 +136,7 @@ class CompileUnit {
uint64_t getHighPc() const { return HighPc; }
bool hasLabelAt(uint64_t Addr) const { return Labels.count(Addr); }
- Optional<PatchLocation> getUnitRangesAttribute() const {
+ std::optional<PatchLocation> getUnitRangesAttribute() const {
return UnitRangeAttribute;
}
@@ -275,7 +275,7 @@ class CompileUnit {
/// all the unit's function addresses.
/// @{
std::vector<PatchLocation> RangeAttributes;
- Optional<PatchLocation> UnitRangeAttribute;
+ std::optional<PatchLocation> UnitRangeAttribute;
/// @}
/// Location attributes that need to be transferred from the
diff --git a/llvm/include/llvm/DWARFLinker/DWARFStreamer.h b/llvm/include/llvm/DWARFLinker/DWARFStreamer.h
index 0ccab0efa8f41..3bc3f454361e5 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFStreamer.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFStreamer.h
@@ -96,7 +96,7 @@ class DwarfStreamer : public DwarfEmitter {
/// original \p Entries.
void emitRangesEntries(
int64_t UnitPcOffset, uint64_t OrigLowPc,
- Optional<std::pair<AddressRange, int64_t>> FuncRange,
+ std::optional<std::pair<AddressRange, int64_t>> FuncRange,
const std::vector<DWARFDebugRangeList::RangeListEntry> &Entries,
unsigned AddressSize) override;
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index b559f14fdc561..0261b8fc3beb5 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -137,7 +137,7 @@ AddressesMap::~AddressesMap() = default;
DwarfEmitter::~DwarfEmitter() = default;
-static Optional<StringRef> StripTemplateParameters(StringRef Name) {
+static std::optional<StringRef> StripTemplateParameters(StringRef Name) {
// We are looking for template parameters to strip from Name. e.g.
//
// operator<<B>
@@ -191,7 +191,7 @@ bool DWARFLinker::DIECloner::getDIENames(const DWARFDie &Die,
if (StripTemplate && Info.Name && Info.MangledName != Info.Name) {
StringRef Name = Info.Name.getString();
- if (Optional<StringRef> StrippedName = StripTemplateParameters(Name))
+ if (std::optional<StringRef> StrippedName = StripTemplateParameters(Name))
Info.NameWithoutTemplate = StringPool.getEntry(*StrippedName);
}
@@ -1584,7 +1584,7 @@ void DWARFLinker::patchRangesForUnit(const CompileUnit &Unit,
DWARFDataExtractor RangeExtractor(OrigDwarf.getDWARFObj(),
OrigDwarf.getDWARFObj().getRangesSection(),
OrigDwarf.isLittleEndian(), AddressSize);
- Optional<std::pair<AddressRange, int64_t>> CurrRange;
+ std::optional<std::pair<AddressRange, int64_t>> CurrRange;
DWARFUnit &OrigUnit = Unit.getOrigUnit();
auto OrigUnitDie = OrigUnit.getUnitDIE(false);
uint64_t OrigLowPc =
@@ -1718,7 +1718,7 @@ void DWARFLinker::patchLineTableForUnit(CompileUnit &Unit,
// in NewRows.
std::vector<DWARFDebugLine::Row> Seq;
const auto &FunctionRanges = Unit.getFunctionRanges();
- Optional<std::pair<AddressRange, int64_t>> CurrRange;
+ std::optional<std::pair<AddressRange, int64_t>> CurrRange;
// FIXME: This logic is meant to generate exactly the same output as
// Darwin's classic dsymutil. There is a nicer way to implement this
@@ -1752,7 +1752,7 @@ void DWARFLinker::patchLineTableForUnit(CompileUnit &Unit,
// for now do as dsymutil.
// FIXME: Understand exactly what cases this addresses and
// potentially remove it along with the Ranges map.
- if (Optional<std::pair<AddressRange, int64_t>> Range =
+ if (std::optional<std::pair<AddressRange, int64_t>> Range =
Ranges.getRangeValueThatContains(Row.Address.Address))
StopAddress = Row.Address.Address + (*Range).second;
}
@@ -1901,7 +1901,7 @@ void DWARFLinker::patchFrameInfoForObject(const DWARFFile &File,
// the function entry point, thus we can't just lookup the address
// in the debug map. Use the AddressInfo's range map to see if the FDE
// describes something that we can relocate.
- Optional<std::pair<AddressRange, int64_t>> Range =
+ std::optional<std::pair<AddressRange, int64_t>> Range =
Ranges.getRangeValueThatContains(Loc);
if (!Range) {
// The +4 is to account for the size of the InitialLength field itself.
diff --git a/llvm/lib/DWARFLinker/DWARFStreamer.cpp b/llvm/lib/DWARFLinker/DWARFStreamer.cpp
index 594d7afe3fe75..2a11d311cf642 100644
--- a/llvm/lib/DWARFLinker/DWARFStreamer.cpp
+++ b/llvm/lib/DWARFLinker/DWARFStreamer.cpp
@@ -321,7 +321,7 @@ void DwarfStreamer::emitSwiftReflectionSection(
/// sized addresses describing the ranges.
void DwarfStreamer::emitRangesEntries(
int64_t UnitPcOffset, uint64_t OrigLowPc,
- Optional<std::pair<AddressRange, int64_t>> FuncRange,
+ std::optional<std::pair<AddressRange, int64_t>> FuncRange,
const std::vector<DWARFDebugRangeList::RangeListEntry> &Entries,
unsigned AddressSize) {
MS->switchSection(MC->getObjectFileInfo()->getDwarfRangesSection());
diff --git a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
index 48d3b1fcc3f7b..4902f083a6935 100644
--- a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
+++ b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
@@ -167,7 +167,7 @@ class ObjFileAddressMap : public AddressesMap {
// of executable sections.
bool isInsideExecutableSectionsAddressRange(uint64_t LowPC,
Optional<uint64_t> HighPC) {
- Optional<AddressRange> Range =
+ std::optional<AddressRange> Range =
TextAddressRanges.getRangeThatContains(LowPC);
if (HighPC)
More information about the llvm-commits
mailing list