[Object] llvm::Optional => std::optional
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#define LLVM_DEBUGINFOD_DIFETCHER_H
|
||||
|
||||
#include "llvm/Object/BuildID.h"
|
||||
#include <optional>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@@ -27,7 +28,7 @@ public:
|
||||
|
||||
/// Fetches the given Build ID using debuginfod and returns a local path to
|
||||
/// the resulting file.
|
||||
Optional<std::string> fetch(object::BuildIDRef BuildID) const override;
|
||||
std::optional<std::string> fetch(object::BuildIDRef BuildID) const override;
|
||||
};
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
@@ -358,7 +358,7 @@ public:
|
||||
static bool classof(Binary const *v) { return v->isArchive(); }
|
||||
|
||||
// check if a symbol is in the archive
|
||||
Expected<Optional<Child>> findSym(StringRef name) const;
|
||||
Expected<std::optional<Child>> findSym(StringRef name) const;
|
||||
|
||||
virtual bool isEmpty() const;
|
||||
bool hasSymbolTable() const;
|
||||
|
||||
@@ -30,7 +30,7 @@ typedef ArrayRef<uint8_t> BuildIDRef;
|
||||
class ObjectFile;
|
||||
|
||||
/// Returns the build ID, if any, contained in the given object file.
|
||||
Optional<BuildIDRef> getBuildID(const ObjectFile *Obj);
|
||||
std::optional<BuildIDRef> getBuildID(const ObjectFile *Obj);
|
||||
|
||||
/// BuildIDFetcher searches local cache directories for debug info.
|
||||
class BuildIDFetcher {
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
virtual ~BuildIDFetcher() = default;
|
||||
|
||||
/// Returns the path to the debug file with the given build ID.
|
||||
virtual Optional<std::string> fetch(BuildIDRef BuildID) const;
|
||||
virtual std::optional<std::string> fetch(BuildIDRef BuildID) const;
|
||||
|
||||
private:
|
||||
const std::vector<std::string> DebugFileDirectories;
|
||||
|
||||
@@ -34,9 +34,9 @@ private:
|
||||
MemoryBufferRef Data;
|
||||
dxbc::Header Header;
|
||||
SmallVector<uint32_t, 4> PartOffsets;
|
||||
Optional<DXILData> DXIL;
|
||||
Optional<uint64_t> ShaderFlags;
|
||||
Optional<dxbc::ShaderHash> Hash;
|
||||
std::optional<DXILData> DXIL;
|
||||
std::optional<uint64_t> ShaderFlags;
|
||||
std::optional<dxbc::ShaderHash> Hash;
|
||||
|
||||
Error parseHeader();
|
||||
Error parsePartOffsets();
|
||||
@@ -119,11 +119,11 @@ public:
|
||||
|
||||
const dxbc::Header &getHeader() const { return Header; }
|
||||
|
||||
Optional<DXILData> getDXIL() const { return DXIL; }
|
||||
std::optional<DXILData> getDXIL() const { return DXIL; }
|
||||
|
||||
Optional<uint64_t> getShaderFlags() const { return ShaderFlags; }
|
||||
std::optional<uint64_t> getShaderFlags() const { return ShaderFlags; }
|
||||
|
||||
Optional<dxbc::ShaderHash> getShaderHash() const { return Hash; }
|
||||
std::optional<dxbc::ShaderHash> getShaderHash() const { return Hash; }
|
||||
};
|
||||
|
||||
} // namespace object
|
||||
|
||||
@@ -120,7 +120,7 @@ template <class T> struct DataRegion {
|
||||
}
|
||||
|
||||
const T *First;
|
||||
Optional<uint64_t> Size = std::nullopt;
|
||||
std::optional<uint64_t> Size = std::nullopt;
|
||||
const uint8_t *BufEnd = nullptr;
|
||||
};
|
||||
|
||||
@@ -202,10 +202,10 @@ public:
|
||||
Expected<std::vector<VerNeed>> getVersionDependencies(
|
||||
const Elf_Shdr &Sec,
|
||||
WarningHandler WarnHandler = &defaultWarningHandler) const;
|
||||
Expected<StringRef>
|
||||
getSymbolVersionByIndex(uint32_t SymbolVersionIndex, bool &IsDefault,
|
||||
SmallVector<Optional<VersionEntry>, 0> &VersionMap,
|
||||
Optional<bool> IsSymHidden) const;
|
||||
Expected<StringRef> getSymbolVersionByIndex(
|
||||
uint32_t SymbolVersionIndex, bool &IsDefault,
|
||||
SmallVector<std::optional<VersionEntry>, 0> &VersionMap,
|
||||
std::optional<bool> IsSymHidden) const;
|
||||
|
||||
Expected<StringRef>
|
||||
getStringTable(const Elf_Shdr &Section,
|
||||
@@ -233,7 +233,7 @@ public:
|
||||
Expected<const Elf_Sym *> getRelocationSymbol(const Elf_Rel &Rel,
|
||||
const Elf_Shdr *SymTab) const;
|
||||
|
||||
Expected<SmallVector<Optional<VersionEntry>, 0>>
|
||||
Expected<SmallVector<std::optional<VersionEntry>, 0>>
|
||||
loadVersionMap(const Elf_Shdr *VerNeedSec, const Elf_Shdr *VerDefSec) const;
|
||||
|
||||
static Expected<ELFFile> create(StringRef Object);
|
||||
@@ -587,10 +587,10 @@ uint32_t ELFFile<ELFT>::getRelativeRelocationType() const {
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
Expected<SmallVector<Optional<VersionEntry>, 0>>
|
||||
Expected<SmallVector<std::optional<VersionEntry>, 0>>
|
||||
ELFFile<ELFT>::loadVersionMap(const Elf_Shdr *VerNeedSec,
|
||||
const Elf_Shdr *VerDefSec) const {
|
||||
SmallVector<Optional<VersionEntry>, 0> VersionMap;
|
||||
SmallVector<std::optional<VersionEntry>, 0> VersionMap;
|
||||
|
||||
// The first two version indexes are reserved.
|
||||
// Index 0 is VER_NDX_LOCAL, index 1 is VER_NDX_GLOBAL.
|
||||
@@ -722,8 +722,8 @@ Expected<uint64_t> ELFFile<ELFT>::getDynSymtabSize() const {
|
||||
Expected<Elf_Dyn_Range> DynTable = dynamicEntries();
|
||||
if (!DynTable)
|
||||
return DynTable.takeError();
|
||||
llvm::Optional<uint64_t> ElfHash;
|
||||
llvm::Optional<uint64_t> ElfGnuHash;
|
||||
std::optional<uint64_t> ElfHash;
|
||||
std::optional<uint64_t> ElfGnuHash;
|
||||
for (const Elf_Dyn &Entry : *DynTable) {
|
||||
switch (Entry.d_tag) {
|
||||
case ELF::DT_HASH:
|
||||
@@ -876,8 +876,8 @@ Expected<const T *> ELFFile<ELFT>::getEntry(const Elf_Shdr &Section,
|
||||
template <typename ELFT>
|
||||
Expected<StringRef> ELFFile<ELFT>::getSymbolVersionByIndex(
|
||||
uint32_t SymbolVersionIndex, bool &IsDefault,
|
||||
SmallVector<Optional<VersionEntry>, 0> &VersionMap,
|
||||
Optional<bool> IsSymHidden) const {
|
||||
SmallVector<std::optional<VersionEntry>, 0> &VersionMap,
|
||||
std::optional<bool> IsSymHidden) const {
|
||||
size_t VersionIndex = SymbolVersionIndex & llvm::ELF::VERSYM_VERSION;
|
||||
|
||||
// Special markers for unversioned symbols.
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
|
||||
SubtargetFeatures getFeatures() const override;
|
||||
|
||||
Optional<StringRef> tryGetCPUName() const override;
|
||||
std::optional<StringRef> tryGetCPUName() const override;
|
||||
|
||||
void setARMSubArch(Triple &TheTriple) const override;
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
|
||||
virtual uint16_t getEMachine() const = 0;
|
||||
|
||||
std::vector<std::pair<Optional<DataRefImpl>, uint64_t>>
|
||||
std::vector<std::pair<std::optional<DataRefImpl>, uint64_t>>
|
||||
getPltAddresses() const;
|
||||
|
||||
/// Returns a vector containing a symbol version for each dynamic symbol.
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
// `TextSectionIndex` is specified, only returns the BB address maps
|
||||
// corresponding to the section with that index.
|
||||
Expected<std::vector<BBAddrMap>>
|
||||
readBBAddrMap(Optional<unsigned> TextSectionIndex = std::nullopt) const;
|
||||
readBBAddrMap(std::optional<unsigned> TextSectionIndex = std::nullopt) const;
|
||||
};
|
||||
|
||||
class ELFSectionRef : public SectionRef {
|
||||
|
||||
@@ -715,13 +715,13 @@ public:
|
||||
|
||||
/// If the optional is None, no header was found, but the object was
|
||||
/// well-formed.
|
||||
Expected<Optional<MachO::dyld_chained_fixups_header>>
|
||||
Expected<std::optional<MachO::dyld_chained_fixups_header>>
|
||||
getChainedFixupsHeader() const;
|
||||
Expected<std::vector<ChainedFixupTarget>> getDyldChainedFixupTargets() const;
|
||||
|
||||
// Note: This is a limited, temporary API, which will be removed when Apple
|
||||
// upstreams their implementation. Please do not rely on this.
|
||||
Expected<Optional<MachO::linkedit_data_command>>
|
||||
Expected<std::optional<MachO::linkedit_data_command>>
|
||||
getChainedFixupsLoadCommand() const;
|
||||
// Returns the number of sections listed in dyld_chained_starts_in_image, and
|
||||
// a ChainedFixupsSegment for each segment that has fixups.
|
||||
|
||||
@@ -42,7 +42,8 @@ public:
|
||||
|
||||
/// Returns the raw contents of the stream of the given type, or None if the
|
||||
/// file does not contain a stream of this type.
|
||||
Optional<ArrayRef<uint8_t>> getRawStream(minidump::StreamType Type) const;
|
||||
std::optional<ArrayRef<uint8_t>>
|
||||
getRawStream(minidump::StreamType Type) const;
|
||||
|
||||
/// Returns the raw contents of an object given by the LocationDescriptor. An
|
||||
/// error is returned if the descriptor points outside of the minidump file.
|
||||
@@ -188,7 +189,7 @@ private:
|
||||
|
||||
template <typename T>
|
||||
Expected<const T &> MinidumpFile::getStream(minidump::StreamType Type) const {
|
||||
if (Optional<ArrayRef<uint8_t>> Stream = getRawStream(Type)) {
|
||||
if (std::optional<ArrayRef<uint8_t>> Stream = getRawStream(Type)) {
|
||||
if (Stream->size() >= sizeof(T))
|
||||
return *reinterpret_cast<const T *>(Stream->data());
|
||||
return createEOFError();
|
||||
|
||||
@@ -337,7 +337,9 @@ public:
|
||||
virtual StringRef getFileFormatName() const = 0;
|
||||
virtual Triple::ArchType getArch() const = 0;
|
||||
virtual SubtargetFeatures getFeatures() const = 0;
|
||||
virtual Optional<StringRef> tryGetCPUName() const { return std::nullopt; };
|
||||
virtual std::optional<StringRef> tryGetCPUName() const {
|
||||
return std::nullopt;
|
||||
};
|
||||
virtual void setARMSubArch(Triple &TheTriple) const { }
|
||||
virtual Expected<uint64_t> getStartAddress() const {
|
||||
return errorCodeToError(object_error::parse_failed);
|
||||
|
||||
@@ -280,7 +280,7 @@ private:
|
||||
std::vector<wasm::WasmExport> Exports;
|
||||
std::vector<wasm::WasmElemSegment> ElemSegments;
|
||||
std::vector<WasmSegment> DataSegments;
|
||||
llvm::Optional<size_t> DataCount;
|
||||
std::optional<size_t> DataCount;
|
||||
std::vector<wasm::WasmFunction> Functions;
|
||||
std::vector<WasmSymbol> Symbols;
|
||||
std::vector<wasm::WasmDebugName> DebugNames;
|
||||
|
||||
@@ -835,15 +835,15 @@ public:
|
||||
|
||||
class XCOFFTracebackTable {
|
||||
const uint8_t *const TBPtr;
|
||||
Optional<SmallString<32>> ParmsType;
|
||||
Optional<uint32_t> TraceBackTableOffset;
|
||||
Optional<uint32_t> HandlerMask;
|
||||
Optional<uint32_t> NumOfCtlAnchors;
|
||||
Optional<SmallVector<uint32_t, 8>> ControlledStorageInfoDisp;
|
||||
Optional<StringRef> FunctionName;
|
||||
Optional<uint8_t> AllocaRegister;
|
||||
Optional<TBVectorExt> VecExt;
|
||||
Optional<uint8_t> ExtensionTable;
|
||||
std::optional<SmallString<32>> ParmsType;
|
||||
std::optional<uint32_t> TraceBackTableOffset;
|
||||
std::optional<uint32_t> HandlerMask;
|
||||
std::optional<uint32_t> NumOfCtlAnchors;
|
||||
std::optional<SmallVector<uint32_t, 8>> ControlledStorageInfoDisp;
|
||||
std::optional<StringRef> FunctionName;
|
||||
std::optional<uint8_t> AllocaRegister;
|
||||
std::optional<TBVectorExt> VecExt;
|
||||
std::optional<uint8_t> ExtensionTable;
|
||||
|
||||
XCOFFTracebackTable(const uint8_t *Ptr, uint64_t &Size, Error &Err);
|
||||
|
||||
@@ -895,19 +895,30 @@ public:
|
||||
uint8_t getNumberOfFPParms() const;
|
||||
bool hasParmsOnStack() const;
|
||||
|
||||
const Optional<SmallString<32>> &getParmsType() const { return ParmsType; }
|
||||
const Optional<uint32_t> &getTraceBackTableOffset() const {
|
||||
const std::optional<SmallString<32>> &getParmsType() const {
|
||||
return ParmsType;
|
||||
}
|
||||
const std::optional<uint32_t> &getTraceBackTableOffset() const {
|
||||
return TraceBackTableOffset;
|
||||
}
|
||||
const Optional<uint32_t> &getHandlerMask() const { return HandlerMask; }
|
||||
const Optional<uint32_t> &getNumOfCtlAnchors() { return NumOfCtlAnchors; }
|
||||
const Optional<SmallVector<uint32_t, 8>> &getControlledStorageInfoDisp() {
|
||||
const std::optional<uint32_t> &getHandlerMask() const { return HandlerMask; }
|
||||
const std::optional<uint32_t> &getNumOfCtlAnchors() {
|
||||
return NumOfCtlAnchors;
|
||||
}
|
||||
const std::optional<SmallVector<uint32_t, 8>> &
|
||||
getControlledStorageInfoDisp() {
|
||||
return ControlledStorageInfoDisp;
|
||||
}
|
||||
const Optional<StringRef> &getFunctionName() const { return FunctionName; }
|
||||
const Optional<uint8_t> &getAllocaRegister() const { return AllocaRegister; }
|
||||
const Optional<TBVectorExt> &getVectorExt() const { return VecExt; }
|
||||
const Optional<uint8_t> &getExtensionTable() const { return ExtensionTable; }
|
||||
const std::optional<StringRef> &getFunctionName() const {
|
||||
return FunctionName;
|
||||
}
|
||||
const std::optional<uint8_t> &getAllocaRegister() const {
|
||||
return AllocaRegister;
|
||||
}
|
||||
const std::optional<TBVectorExt> &getVectorExt() const { return VecExt; }
|
||||
const std::optional<uint8_t> &getExtensionTable() const {
|
||||
return ExtensionTable;
|
||||
}
|
||||
};
|
||||
|
||||
bool doesXCOFFTracebackTableBegin(ArrayRef<uint8_t> Bytes);
|
||||
|
||||
@@ -437,7 +437,7 @@ bool LLVMSymbolizer::getOrFindDebugBinary(const ArrayRef<uint8_t> BuildID,
|
||||
}
|
||||
if (!BIDFetcher)
|
||||
return false;
|
||||
if (Optional<std::string> Path = BIDFetcher->fetch(BuildID)) {
|
||||
if (std::optional<std::string> Path = BIDFetcher->fetch(BuildID)) {
|
||||
Result = *Path;
|
||||
auto InsertResult = BuildIDPaths.insert({BuildIDStr, Result});
|
||||
assert(InsertResult.second);
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
Optional<std::string>
|
||||
std::optional<std::string>
|
||||
DebuginfodFetcher::fetch(ArrayRef<uint8_t> BuildID) const {
|
||||
if (Optional<std::string> Path = BuildIDFetcher::fetch(BuildID))
|
||||
if (std::optional<std::string> Path = BuildIDFetcher::fetch(BuildID))
|
||||
return std::move(*Path);
|
||||
|
||||
Expected<std::string> PathOrErr = getCachedOrDownloadDebuginfo(BuildID);
|
||||
|
||||
@@ -403,7 +403,7 @@ Error DebuginfodCollection::findBinaries(StringRef Path) {
|
||||
if (!Object)
|
||||
continue;
|
||||
|
||||
Optional<BuildIDRef> ID = getBuildID(Object);
|
||||
std::optional<BuildIDRef> ID = getBuildID(Object);
|
||||
if (!ID)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Object/Archive.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
@@ -1145,7 +1144,7 @@ uint32_t Archive::getNumberOfSymbols() const {
|
||||
return read32le(buf);
|
||||
}
|
||||
|
||||
Expected<Optional<Archive::Child>> Archive::findSym(StringRef name) const {
|
||||
Expected<std::optional<Archive::Child>> Archive::findSym(StringRef name) const {
|
||||
Archive::symbol_iterator bs = symbol_begin();
|
||||
Archive::symbol_iterator es = symbol_end();
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace object {
|
||||
namespace {
|
||||
|
||||
template <typename ELFT>
|
||||
Optional<BuildIDRef> getBuildID(const ELFFile<ELFT> &Obj) {
|
||||
std::optional<BuildIDRef> getBuildID(const ELFFile<ELFT> &Obj) {
|
||||
auto PhdrsOrErr = Obj.program_headers();
|
||||
if (!PhdrsOrErr) {
|
||||
consumeError(PhdrsOrErr.takeError());
|
||||
@@ -45,7 +45,7 @@ Optional<BuildIDRef> getBuildID(const ELFFile<ELFT> &Obj) {
|
||||
|
||||
} // namespace
|
||||
|
||||
Optional<BuildIDRef> getBuildID(const ObjectFile *Obj) {
|
||||
std::optional<BuildIDRef> getBuildID(const ObjectFile *Obj) {
|
||||
if (auto *O = dyn_cast<ELFObjectFile<ELF32LE>>(Obj))
|
||||
return getBuildID(O->getELFFile());
|
||||
if (auto *O = dyn_cast<ELFObjectFile<ELF32BE>>(Obj))
|
||||
@@ -57,7 +57,7 @@ Optional<BuildIDRef> getBuildID(const ObjectFile *Obj) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
Optional<std::string> BuildIDFetcher::fetch(BuildIDRef BuildID) const {
|
||||
std::optional<std::string> BuildIDFetcher::fetch(BuildIDRef BuildID) const {
|
||||
auto GetDebugPath = [&](StringRef Directory) {
|
||||
SmallString<128> Path{Directory};
|
||||
sys::path::append(Path, ".build-id",
|
||||
|
||||
@@ -376,7 +376,7 @@ SubtargetFeatures ELFObjectFileBase::getFeatures() const {
|
||||
}
|
||||
}
|
||||
|
||||
Optional<StringRef> ELFObjectFileBase::tryGetCPUName() const {
|
||||
std::optional<StringRef> ELFObjectFileBase::tryGetCPUName() const {
|
||||
switch (getEMachine()) {
|
||||
case ELF::EM_AMDGPU:
|
||||
return getAMDGPUCPUName();
|
||||
@@ -619,7 +619,7 @@ void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const {
|
||||
TheTriple.setArchName(Triple);
|
||||
}
|
||||
|
||||
std::vector<std::pair<Optional<DataRefImpl>, uint64_t>>
|
||||
std::vector<std::pair<std::optional<DataRefImpl>, uint64_t>>
|
||||
ELFObjectFileBase::getPltAddresses() const {
|
||||
std::string Err;
|
||||
const auto Triple = makeTriple();
|
||||
@@ -678,7 +678,7 @@ ELFObjectFileBase::getPltAddresses() const {
|
||||
GotToPlt.insert(std::make_pair(Entry.second, Entry.first));
|
||||
// Find the relocations in the dynamic relocation table that point to
|
||||
// locations in the GOT for which we know the corresponding PLT entry.
|
||||
std::vector<std::pair<Optional<DataRefImpl>, uint64_t>> Result;
|
||||
std::vector<std::pair<std::optional<DataRefImpl>, uint64_t>> Result;
|
||||
for (const auto &Relocation : RelaPlt->relocations()) {
|
||||
if (Relocation.getType() != JumpSlotReloc)
|
||||
continue;
|
||||
@@ -696,7 +696,7 @@ ELFObjectFileBase::getPltAddresses() const {
|
||||
|
||||
template <class ELFT>
|
||||
Expected<std::vector<BBAddrMap>> static readBBAddrMapImpl(
|
||||
const ELFFile<ELFT> &EF, Optional<unsigned> TextSectionIndex) {
|
||||
const ELFFile<ELFT> &EF, std::optional<unsigned> TextSectionIndex) {
|
||||
using Elf_Shdr = typename ELFT::Shdr;
|
||||
std::vector<BBAddrMap> BBAddrMaps;
|
||||
const auto &Sections = cantFail(EF.sections());
|
||||
@@ -743,7 +743,7 @@ readDynsymVersionsImpl(const ELFFile<ELFT> &EF,
|
||||
if (!VerSec)
|
||||
return std::vector<VersionEntry>();
|
||||
|
||||
Expected<SmallVector<Optional<VersionEntry>, 0>> MapOrErr =
|
||||
Expected<SmallVector<std::optional<VersionEntry>, 0>> MapOrErr =
|
||||
EF.loadVersionMap(VerNeedSec, VerDefSec);
|
||||
if (!MapOrErr)
|
||||
return MapOrErr.takeError();
|
||||
@@ -792,8 +792,8 @@ ELFObjectFileBase::readDynsymVersions() const {
|
||||
Symbols);
|
||||
}
|
||||
|
||||
Expected<std::vector<BBAddrMap>>
|
||||
ELFObjectFileBase::readBBAddrMap(Optional<unsigned> TextSectionIndex) const {
|
||||
Expected<std::vector<BBAddrMap>> ELFObjectFileBase::readBBAddrMap(
|
||||
std::optional<unsigned> TextSectionIndex) const {
|
||||
if (const auto *Obj = dyn_cast<ELF32LEObjectFile>(this))
|
||||
return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex);
|
||||
if (const auto *Obj = dyn_cast<ELF64LEObjectFile>(this))
|
||||
|
||||
@@ -4957,7 +4957,7 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoExportsTrie() const {
|
||||
return makeArrayRef(Ptr, DyldInfo.export_size);
|
||||
}
|
||||
|
||||
Expected<Optional<MachO::linkedit_data_command>>
|
||||
Expected<std::optional<MachO::linkedit_data_command>>
|
||||
MachOObjectFile::getChainedFixupsLoadCommand() const {
|
||||
// Load the dyld chained fixups load command.
|
||||
if (!DyldChainedFixupsLoadCmd)
|
||||
@@ -4976,7 +4976,7 @@ MachOObjectFile::getChainedFixupsLoadCommand() const {
|
||||
return DyldChainedFixups;
|
||||
}
|
||||
|
||||
Expected<Optional<MachO::dyld_chained_fixups_header>>
|
||||
Expected<std::optional<MachO::dyld_chained_fixups_header>>
|
||||
MachOObjectFile::getChainedFixupsHeader() const {
|
||||
auto CFOrErr = getChainedFixupsLoadCommand();
|
||||
if (!CFOrErr)
|
||||
|
||||
@@ -14,7 +14,7 @@ using namespace llvm;
|
||||
using namespace llvm::object;
|
||||
using namespace llvm::minidump;
|
||||
|
||||
Optional<ArrayRef<uint8_t>>
|
||||
std::optional<ArrayRef<uint8_t>>
|
||||
MinidumpFile::getRawStream(minidump::StreamType Type) const {
|
||||
auto It = StreamMap.find(Type);
|
||||
if (It != StreamMap.end())
|
||||
@@ -55,7 +55,8 @@ Expected<std::string> MinidumpFile::getString(size_t Offset) const {
|
||||
|
||||
Expected<iterator_range<MinidumpFile::MemoryInfoIterator>>
|
||||
MinidumpFile::getMemoryInfoList() const {
|
||||
Optional<ArrayRef<uint8_t>> Stream = getRawStream(StreamType::MemoryInfoList);
|
||||
std::optional<ArrayRef<uint8_t>> Stream =
|
||||
getRawStream(StreamType::MemoryInfoList);
|
||||
if (!Stream)
|
||||
return createError("No such stream");
|
||||
auto ExpectedHeader =
|
||||
@@ -73,7 +74,7 @@ MinidumpFile::getMemoryInfoList() const {
|
||||
|
||||
template <typename T>
|
||||
Expected<ArrayRef<T>> MinidumpFile::getListStream(StreamType Type) const {
|
||||
Optional<ArrayRef<uint8_t>> Stream = getRawStream(Type);
|
||||
std::optional<ArrayRef<uint8_t>> Stream = getRawStream(Type);
|
||||
if (!Stream)
|
||||
return createError("No such stream");
|
||||
auto ExpectedSize = getDataSliceAs<support::ulittle32_t>(*Stream, 0, 1);
|
||||
|
||||
@@ -118,7 +118,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Find a debug file in local build ID directories and via debuginfod.
|
||||
std::string fetchDebugInfo(object::BuildIDRef BuildID) {
|
||||
if (Optional<std::string> Path =
|
||||
if (std::optional<std::string> Path =
|
||||
DebuginfodFetcher(DebugFileDirectory).fetch(BuildID))
|
||||
return *Path;
|
||||
errs() << "Build ID " << llvm::toHex(BuildID, /*Lowercase=*/true)
|
||||
|
||||
@@ -1272,12 +1272,12 @@ static void createFakeELFSections(ObjectFile &Obj) {
|
||||
|
||||
// Tries to fetch a more complete version of the given object file using its
|
||||
// Build ID. Returns None if nothing was found.
|
||||
static Optional<OwningBinary<Binary>>
|
||||
static std::optional<OwningBinary<Binary>>
|
||||
fetchBinaryByBuildID(const ObjectFile &Obj) {
|
||||
Optional<object::BuildIDRef> BuildID = getBuildID(&Obj);
|
||||
std::optional<object::BuildIDRef> BuildID = getBuildID(&Obj);
|
||||
if (!BuildID)
|
||||
return std::nullopt;
|
||||
Optional<std::string> Path = BIDFetcher->fetch(*BuildID);
|
||||
std::optional<std::string> Path = BIDFetcher->fetch(*BuildID);
|
||||
if (!Path)
|
||||
return std::nullopt;
|
||||
Expected<OwningBinary<Binary>> DebugBinary = createBinary(*Path);
|
||||
@@ -1423,7 +1423,8 @@ static void disassembleObject(const Target *TheTarget, ObjectFile &Obj,
|
||||
LLVM_DEBUG(LVP.dump());
|
||||
|
||||
std::unordered_map<uint64_t, BBAddrMap> AddrToBBAddrMap;
|
||||
auto ReadBBAddrMap = [&](Optional<unsigned> SectionIndex = std::nullopt) {
|
||||
auto ReadBBAddrMap = [&](std::optional<unsigned> SectionIndex =
|
||||
std::nullopt) {
|
||||
AddrToBBAddrMap.clear();
|
||||
if (const auto *Elf = dyn_cast<ELFObjectFileBase>(&Obj)) {
|
||||
auto BBAddrMapsOrErr = Elf->readBBAddrMap(SectionIndex);
|
||||
@@ -1975,7 +1976,7 @@ static void disassembleObject(ObjectFile *Obj, bool InlineRelocs) {
|
||||
// more complete binary and disassemble that instead.
|
||||
OwningBinary<Binary> FetchedBinary;
|
||||
if (Obj->symbols().empty()) {
|
||||
if (Optional<OwningBinary<Binary>> FetchedBinaryOpt =
|
||||
if (std::optional<OwningBinary<Binary>> FetchedBinaryOpt =
|
||||
fetchBinaryByBuildID(*Obj)) {
|
||||
if (auto *O = dyn_cast<ObjectFile>(FetchedBinaryOpt->getBinary())) {
|
||||
if (!O->symbols().empty() ||
|
||||
@@ -2092,7 +2093,7 @@ static void disassembleObject(ObjectFile *Obj, bool InlineRelocs) {
|
||||
|
||||
const ObjectFile *DbgObj = Obj;
|
||||
if (!FetchedBinary.getBinary() && !Obj->hasDebugInfo()) {
|
||||
if (Optional<OwningBinary<Binary>> DebugBinaryOpt =
|
||||
if (std::optional<OwningBinary<Binary>> DebugBinaryOpt =
|
||||
fetchBinaryByBuildID(*Obj)) {
|
||||
if (auto *FetchedObj =
|
||||
dyn_cast<const ObjectFile>(DebugBinaryOpt->getBinary())) {
|
||||
@@ -3099,7 +3100,7 @@ static void parseObjdumpOptions(const llvm::opt::InputArgList &InputArgs) {
|
||||
// Look up any provided build IDs, then append them to the input filenames.
|
||||
for (const opt::Arg *A : InputArgs.filtered(OBJDUMP_build_id)) {
|
||||
object::BuildID BuildID = parseBuildIDArg(A);
|
||||
Optional<std::string> Path = BIDFetcher->fetch(BuildID);
|
||||
std::optional<std::string> Path = BIDFetcher->fetch(BuildID);
|
||||
if (!Path) {
|
||||
reportCmdLineError(A->getSpelling() + ": could not find build ID '" +
|
||||
A->getValue() + "'");
|
||||
|
||||
@@ -356,7 +356,7 @@ protected:
|
||||
|
||||
Expected<StringRef> getSymbolVersion(const Elf_Sym &Sym,
|
||||
bool &IsDefault) const;
|
||||
Expected<SmallVector<Optional<VersionEntry>, 0> *> getVersionMap() const;
|
||||
Expected<SmallVector<std::optional<VersionEntry>, 0> *> getVersionMap() const;
|
||||
|
||||
DynRegionInfo DynRelRegion;
|
||||
DynRegionInfo DynRelaRegion;
|
||||
@@ -400,7 +400,7 @@ protected:
|
||||
ArrayRef<Elf_Word> getShndxTable(const Elf_Shdr *Symtab) const;
|
||||
|
||||
private:
|
||||
mutable SmallVector<Optional<VersionEntry>, 0> VersionMap;
|
||||
mutable SmallVector<std::optional<VersionEntry>, 0> VersionMap;
|
||||
};
|
||||
|
||||
template <class ELFT>
|
||||
@@ -760,14 +760,14 @@ std::unique_ptr<ObjDumper> createELFDumper(const object::ELFObjectFileBase &Obj,
|
||||
} // end namespace llvm
|
||||
|
||||
template <class ELFT>
|
||||
Expected<SmallVector<Optional<VersionEntry>, 0> *>
|
||||
Expected<SmallVector<std::optional<VersionEntry>, 0> *>
|
||||
ELFDumper<ELFT>::getVersionMap() const {
|
||||
// If the VersionMap has already been loaded or if there is no dynamic symtab
|
||||
// or version table, there is nothing to do.
|
||||
if (!VersionMap.empty() || !DynSymRegion || !SymbolVersionSection)
|
||||
return &VersionMap;
|
||||
|
||||
Expected<SmallVector<Optional<VersionEntry>, 0>> MapOrErr =
|
||||
Expected<SmallVector<std::optional<VersionEntry>, 0>> MapOrErr =
|
||||
Obj.loadVersionMap(SymbolVersionNeedSection, SymbolVersionDefSection);
|
||||
if (MapOrErr)
|
||||
VersionMap = *MapOrErr;
|
||||
@@ -805,7 +805,7 @@ Expected<StringRef> ELFDumper<ELFT>::getSymbolVersion(const Elf_Sym &Sym,
|
||||
return "";
|
||||
}
|
||||
|
||||
Expected<SmallVector<Optional<VersionEntry>, 0> *> MapOrErr =
|
||||
Expected<SmallVector<std::optional<VersionEntry>, 0> *> MapOrErr =
|
||||
getVersionMap();
|
||||
if (!MapOrErr)
|
||||
return MapOrErr.takeError();
|
||||
@@ -4617,8 +4617,8 @@ void GNUELFDumper<ELFT>::printVersionSymbolSection(const Elf_Shdr *Sec) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmallVector<Optional<VersionEntry>, 0> *VersionMap = nullptr;
|
||||
if (Expected<SmallVector<Optional<VersionEntry>, 0> *> MapOrErr =
|
||||
SmallVector<std::optional<VersionEntry>, 0> *VersionMap = nullptr;
|
||||
if (Expected<SmallVector<std::optional<VersionEntry>, 0> *> MapOrErr =
|
||||
this->getVersionMap())
|
||||
VersionMap = *MapOrErr;
|
||||
else
|
||||
|
||||
@@ -44,7 +44,7 @@ dumpDXContainer(MemoryBufferRef Source) {
|
||||
dxbc::PartType PT = dxbc::parsePartType(P.Part.getName());
|
||||
switch (PT) {
|
||||
case dxbc::PartType::DXIL: {
|
||||
Optional<DXContainer::DXILData> DXIL = Container.getDXIL();
|
||||
std::optional<DXContainer::DXILData> DXIL = Container.getDXIL();
|
||||
assert(DXIL && "Since we are iterating and found a DXIL part, "
|
||||
"this should never not have a value");
|
||||
NewPart.Program = DXContainerYAML::DXILProgram{
|
||||
@@ -61,14 +61,14 @@ dumpDXContainer(MemoryBufferRef Source) {
|
||||
break;
|
||||
}
|
||||
case dxbc::PartType::SFI0: {
|
||||
Optional<uint64_t> Flags = Container.getShaderFlags();
|
||||
std::optional<uint64_t> Flags = Container.getShaderFlags();
|
||||
// Omit the flags in the YAML if they are missing or zero.
|
||||
if (Flags && *Flags > 0)
|
||||
NewPart.Flags = DXContainerYAML::ShaderFlags(*Flags);
|
||||
break;
|
||||
}
|
||||
case dxbc::PartType::HASH: {
|
||||
Optional<dxbc::ShaderHash> Hash = Container.getShaderHash();
|
||||
std::optional<dxbc::ShaderHash> Hash = Container.getShaderHash();
|
||||
if (Hash && Hash->isPopulated())
|
||||
NewPart.Hash = DXContainerYAML::ShaderHash(*Hash);
|
||||
break;
|
||||
|
||||
@@ -672,7 +672,7 @@ Sections:
|
||||
std::vector<BBAddrMap> AllBBAddrMaps = {E1, E2, E3};
|
||||
|
||||
auto DoCheckSucceeds = [&](StringRef YamlString,
|
||||
Optional<unsigned> TextSectionIndex,
|
||||
std::optional<unsigned> TextSectionIndex,
|
||||
std::vector<BBAddrMap> ExpectedResult) {
|
||||
SmallString<0> Storage;
|
||||
Expected<ELFObjectFile<ELF64LE>> ElfOrErr =
|
||||
@@ -688,7 +688,7 @@ Sections:
|
||||
};
|
||||
|
||||
auto DoCheckFails = [&](StringRef YamlString,
|
||||
Optional<unsigned> TextSectionIndex,
|
||||
std::optional<unsigned> TextSectionIndex,
|
||||
const char *ErrMsg) {
|
||||
SmallString<0> Storage;
|
||||
Expected<ELFObjectFile<ELF64LE>> ElfOrErr =
|
||||
|
||||
Reference in New Issue
Block a user