https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Expected<unsigned> getDwarfFile(StringRef Directory, StringRef FileName,
unsigned FileNumber,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source,
unsigned CUID, unsigned DWARFVersion);
/// Emit the Dwarf file and the line tables for a given CU.
void emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params,
- Optional<MCDwarfLineStr> &LineStr, BinaryContext &BC) const;
+ std::optional<MCDwarfLineStr> &LineStr, BinaryContext &BC) const;
Expected<unsigned> tryGetFile(StringRef &Directory, StringRef &FileName,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source,
uint16_t DwarfVersion,
unsigned FileNumber = 0) {
/// Sets the root file \p Directory, \p FileName, optional \p CheckSum, and
/// optional \p Source.
void setRootFile(StringRef Directory, StringRef FileName,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source) {
Header.setRootFile(Directory, FileName, Checksum, Source);
}
#include <vector>
namespace llvm {
+
+template <typename T, typename = decltype(std::declval<raw_ostream &>()
+ << std::declval<const T &>())>
+raw_ostream &operator<<(raw_ostream &OS, const std::optional<T> &O) {
+ if (O)
+ OS << *O;
+ else
+ OS << std::nullopt;
+ return OS;
+}
+
namespace bolt {
// NOTE: using SmallVector for instruction list results in a memory regression.
Expected<unsigned> BinaryContext::getDwarfFile(
StringRef Directory, StringRef FileName, unsigned FileNumber,
- Optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
+ std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
unsigned CUID, unsigned DWARFVersion) {
DwarfLineTable &Table = DwarfLineTablesCUMap[CUID];
return Table.tryGetFile(Directory, FileName, Checksum, Source, DWARFVersion,
uint16_t DwarfVersion = LineTable->Prologue.getVersion();
if (DwarfVersion >= 5) {
- Optional<MD5::MD5Result> Checksum;
+ std::optional<MD5::MD5Result> Checksum;
if (LineTable->Prologue.ContentTypes.HasMD5)
Checksum = LineTable->Prologue.FileNames[0].Checksum;
Optional<const char *> Name =
if (Optional<const char *> FName = dwarf::toString(FileNames[I].Name))
FileName = *FName;
assert(FileName != "");
- Optional<MD5::MD5Result> Checksum;
+ std::optional<MD5::MD5Result> Checksum;
if (DwarfVersion >= 5 && LineTable->Prologue.ContentTypes.HasMD5)
Checksum = LineTable->Prologue.FileNames[I].Checksum;
cantFail(getDwarfFile(Dir, FileName, 0, Checksum, std::nullopt, CUID,
}
void DwarfLineTable::emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params,
- Optional<MCDwarfLineStr> &LineStr,
+ std::optional<MCDwarfLineStr> &LineStr,
BinaryContext &BC) const {
if (!RawData.empty()) {
assert(MCLineSections.getMCLineEntries().empty() &&
if (LineTables.empty())
return;
// In a v5 non-split line table, put the strings in a separate section.
- Optional<MCDwarfLineStr> LineStr(std::nullopt);
+ std::optional<MCDwarfLineStr> LineStr;
ErrorOr<BinarySection &> LineStrSection =
BC.getUniqueSectionByName(".debug_line_str");
// Some versions of GCC output DWARF5 .debug_info, but DWARF4 or lower
virtual unsigned getNumFixupKinds() const = 0;
/// Map a relocation name used in .reloc to a fixup kind.
- virtual Optional<MCFixupKind> getFixupKind(StringRef Name) const;
+ virtual std::optional<MCFixupKind> getFixupKind(StringRef Name) const;
/// Get information on a fixup kind.
virtual const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const;
/// Return the unique ID of the section with the given name, flags and entry
/// size, if it exists.
- Optional<unsigned> getELFUniqueIDForEntsize(StringRef SectionName,
- unsigned Flags,
- unsigned EntrySize);
+ std::optional<unsigned> getELFUniqueIDForEntsize(StringRef SectionName,
+ unsigned Flags,
+ unsigned EntrySize);
MCSectionGOFF *getGOFFSection(StringRef Section, SectionKind Kind,
MCSection *Parent, const MCExpr *SubsectionId);
bool hasXCOFFSection(StringRef Section,
XCOFF::CsectProperties CsectProp) const;
- MCSectionXCOFF *
- getXCOFFSection(StringRef Section, SectionKind K,
- Optional<XCOFF::CsectProperties> CsectProp = std::nullopt,
- bool MultiSymbolsAllowed = false,
- const char *BeginSymName = nullptr,
- Optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSubtypeFlags =
- std::nullopt);
+ MCSectionXCOFF *getXCOFFSection(
+ StringRef Section, SectionKind K,
+ std::optional<XCOFF::CsectProperties> CsectProp = std::nullopt,
+ bool MultiSymbolsAllowed = false, const char *BeginSymName = nullptr,
+ std::optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSubtypeFlags =
+ std::nullopt);
// Create and save a copy of STI and return a reference to the copy.
MCSubtargetInfo &getSubtargetCopy(const MCSubtargetInfo &STI);
void setMainFileName(StringRef S) { MainFileName = std::string(S); }
/// Creates an entry in the dwarf file and directory tables.
- Expected<unsigned> getDwarfFile(
- StringRef Directory, StringRef FileName, unsigned FileNumber,
- Optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
- unsigned CUID);
+ Expected<unsigned> getDwarfFile(StringRef Directory, StringRef FileName,
+ unsigned FileNumber,
+ std::optional<MD5::MD5Result> Checksum,
+ std::optional<StringRef> Source,
+ unsigned CUID);
bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID = 0);
/// These are "file 0" and "directory 0" in DWARF v5.
void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir,
StringRef Filename,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source) {
getMCDwarfLineTable(CUID).setRootFile(CompilationDir, Filename, Checksum,
Source);
namespace llvm {
struct XCOFFSymbolInfo {
- Optional<XCOFF::StorageMappingClass> StorageMappingClass;
- Optional<uint32_t> Index;
+ std::optional<XCOFF::StorageMappingClass> StorageMappingClass;
+ std::optional<uint32_t> Index;
bool IsLabel;
- XCOFFSymbolInfo(Optional<XCOFF::StorageMappingClass> Smc,
- Optional<uint32_t> Idx, bool Label)
+ XCOFFSymbolInfo(std::optional<XCOFF::StorageMappingClass> Smc,
+ std::optional<uint32_t> Idx, bool Label)
: StorageMappingClass(Smc), Index(Idx), IsLabel(Label) {}
bool operator<(const XCOFFSymbolInfo &SymInfo) const;
public:
SymbolInfoTy(uint64_t Addr, StringRef Name,
- Optional<XCOFF::StorageMappingClass> Smc, Optional<uint32_t> Idx,
- bool Label)
+ std::optional<XCOFF::StorageMappingClass> Smc,
+ std::optional<uint32_t> Idx, bool Label)
: Addr(Addr), Name(Name), XCOFFSymInfo(Smc, Idx, Label), IsXCOFF(true),
HasType(false) {}
SymbolInfoTy(uint64_t Addr, StringRef Name, uint8_t Type,
/// done by buffering the output if needed.
/// - None if the target doesn't want to handle the symbol
/// separately. Value of Size is ignored in this case.
- virtual Optional<DecodeStatus>
+ virtual std::optional<DecodeStatus>
onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef<uint8_t> Bytes,
uint64_t Address, raw_ostream &CStream) const;
// TODO:
/// The MD5 checksum, if there is one. Non-owning pointer to data allocated
/// in MCContext.
- Optional<MD5::MD5Result> Checksum;
+ std::optional<MD5::MD5Result> Checksum;
/// The source code of the file. Non-owning reference to data allocated in
/// MCContext.
MCDwarfLineTableHeader() = default;
Expected<unsigned> tryGetFile(StringRef &Directory, StringRef &FileName,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source,
- uint16_t DwarfVersion,
- unsigned FileNumber = 0);
+ uint16_t DwarfVersion, unsigned FileNumber = 0);
std::pair<MCSymbol *, MCSymbol *>
Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
- Optional<MCDwarfLineStr> &LineStr) const;
+ std::optional<MCDwarfLineStr> &LineStr) const;
std::pair<MCSymbol *, MCSymbol *>
Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
ArrayRef<char> SpecialOpcodeLengths,
- Optional<MCDwarfLineStr> &LineStr) const;
+ std::optional<MCDwarfLineStr> &LineStr) const;
void resetMD5Usage() {
HasAllMD5 = true;
HasAnyMD5 = false;
}
void setRootFile(StringRef Directory, StringRef FileName,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source) {
CompilationDir = std::string(Directory);
RootFile.Name = std::string(FileName);
private:
void emitV2FileDirTables(MCStreamer *MCOS) const;
- void emitV5FileDirTables(MCStreamer *MCOS, Optional<MCDwarfLineStr> &LineStr) const;
+ void emitV5FileDirTables(MCStreamer *MCOS,
+ std::optional<MCDwarfLineStr> &LineStr) const;
};
class MCDwarfDwoLineTable {
public:
void maybeSetRootFile(StringRef Directory, StringRef FileName,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source) {
if (!Header.RootFile.Name.empty())
return;
}
unsigned getFile(StringRef Directory, StringRef FileName,
- Optional<MD5::MD5Result> Checksum, uint16_t DwarfVersion,
- std::optional<StringRef> Source) {
+ std::optional<MD5::MD5Result> Checksum,
+ uint16_t DwarfVersion, std::optional<StringRef> Source) {
HasSplitLineTable = true;
return cantFail(Header.tryGetFile(Directory, FileName, Checksum, Source,
DwarfVersion));
// This emits the Dwarf file and the line tables for a given Compile Unit.
void emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params,
- Optional<MCDwarfLineStr> &LineStr) const;
+ std::optional<MCDwarfLineStr> &LineStr) const;
// This emits a single line table associated with a given Section.
static void
const MCLineSection::MCDwarfLineEntryCollection &LineEntries);
Expected<unsigned> tryGetFile(StringRef &Directory, StringRef &FileName,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source,
- uint16_t DwarfVersion,
- unsigned FileNumber = 0);
+ uint16_t DwarfVersion, unsigned FileNumber = 0);
unsigned getFile(StringRef &Directory, StringRef &FileName,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source, uint16_t DwarfVersion,
unsigned FileNumber = 0) {
return cantFail(tryGetFile(Directory, FileName, Checksum, Source,
}
void setRootFile(StringRef Directory, StringRef FileName,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source) {
Header.CompilationDir = std::string(Directory);
Header.RootFile.Name = std::string(FileName);
/// Given an instruction tries to get the address of a memory operand. Returns
/// the address on success.
- virtual Optional<uint64_t>
+ virtual std::optional<uint64_t>
evaluateMemoryOperandAddress(const MCInst &Inst, const MCSubtargetInfo *STI,
uint64_t Addr, uint64_t Size) const;
/// Given an instruction with a memory operand that could require relocation,
/// returns the offset within the instruction of that relocation.
- virtual Optional<uint64_t>
+ virtual std::optional<uint64_t>
getMemoryOperandRelocationOffset(const MCInst &Inst, uint64_t Size) const;
/// Returns (PLT virtual address, GOT virtual address) pairs for PLT entries.
#ifndef LLVM_MC_MCOBJECTFILEINFO_H
#define LLVM_MC_MCOBJECTFILEINFO_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/Triple.h"
#include "llvm/BinaryFormat/Swift.h"
#include "llvm/MC/MCSection.h"
#include "llvm/Support/VersionTuple.h"
#include <array>
+#include <optional>
namespace llvm {
class MCContext;
bool PositionIndependent = false;
MCContext *Ctx = nullptr;
VersionTuple SDKVersion;
- Optional<Triple> DarwinTargetVariantTriple;
+ std::optional<Triple> DarwinTargetVariantTriple;
VersionTuple DarwinTargetVariantSDKVersion;
void initMachOMCObjectFileInfo(const Triple &T);
void emitTPRel64Value(const MCExpr *Value) override;
void emitGPRel32Value(const MCExpr *Value) override;
void emitGPRel64Value(const MCExpr *Value) override;
- Optional<std::pair<bool, std::string>>
+ std::optional<std::pair<bool, std::string>>
emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr,
SMLoc Loc, const MCSubtargetInfo &STI) override;
using MCStreamer::emitFill;
/// Map a dwarf register back to a target register. Returns None is there is
/// no mapping.
- Optional<unsigned> getLLVMRegNum(unsigned RegNum, bool isEH) const;
+ std::optional<unsigned> getLLVMRegNum(unsigned RegNum, bool isEH) const;
/// Map a target EH register number to an equivalent DWARF register
/// number.
class MCSectionXCOFF final : public MCSection {
friend class MCContext;
- Optional<XCOFF::CsectProperties> CsectProp;
+ std::optional<XCOFF::CsectProperties> CsectProp;
MCSymbolXCOFF *const QualName;
StringRef SymbolTableName;
- Optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSubtypeFlags;
+ std::optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSubtypeFlags;
bool MultiSymbolsAllowed;
static constexpr unsigned DefaultAlignVal = 4;
static constexpr unsigned DefaultTextAlignVal = 32;
bool isMultiSymbolsAllowed() const { return MultiSymbolsAllowed; }
bool isCsect() const { return CsectProp.has_value(); }
bool isDwarfSect() const { return DwarfSubtypeFlags.has_value(); }
- Optional<XCOFF::DwarfSectionSubtypeFlags> getDwarfSubtypeFlags() const {
+ std::optional<XCOFF::DwarfSectionSubtypeFlags> getDwarfSubtypeFlags() const {
return DwarfSubtypeFlags;
}
- Optional<XCOFF::CsectProperties> getCsectProp() const { return CsectProp; }
+ std::optional<XCOFF::CsectProperties> getCsectProp() const {
+ return CsectProp;
+ }
};
} // end namespace llvm
/// implements the DWARF2 '.file 4 "foo.c"' assembler directive.
unsigned emitDwarfFileDirective(
unsigned FileNo, StringRef Directory, StringRef Filename,
- Optional<MD5::MD5Result> Checksum = std::nullopt,
+ std::optional<MD5::MD5Result> Checksum = std::nullopt,
std::optional<StringRef> Source = std::nullopt, unsigned CUID = 0) {
return cantFail(
tryEmitDwarfFileDirective(FileNo, Directory, Filename, Checksum,
/// '.file 4 "dir/foo.c" md5 "..." source "..."' assembler directive.
virtual Expected<unsigned> tryEmitDwarfFileDirective(
unsigned FileNo, StringRef Directory, StringRef Filename,
- Optional<MD5::MD5Result> Checksum = std::nullopt,
+ std::optional<MD5::MD5Result> Checksum = std::nullopt,
std::optional<StringRef> Source = std::nullopt, unsigned CUID = 0);
/// Specify the "root" file of the compilation, using the ".file 0" extension.
virtual void emitDwarfFile0Directive(StringRef Directory, StringRef Filename,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source,
unsigned CUID = 0);
/// Record a relocation described by the .reloc directive. Return None if
/// succeeded. Otherwise, return a pair (Name is invalid, error message).
- virtual Optional<std::pair<bool, std::string>>
+ virtual std::optional<std::pair<bool, std::string>>
emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr,
SMLoc Loc, const MCSubtargetInfo &STI) {
return std::nullopt;
/// Return the target cache line size in bytes at a given level.
///
- virtual Optional<unsigned> getCacheLineSize(unsigned Level) const;
+ virtual std::optional<unsigned> getCacheLineSize(unsigned Level) const;
/// Return the target cache line size in bytes. By default, return
/// the line size for the bottom-most level of cache. This provides
/// cache model.
///
virtual unsigned getCacheLineSize() const {
- Optional<unsigned> Size = getCacheLineSize(0);
+ std::optional<unsigned> Size = getCacheLineSize(0);
if (Size)
return *Size;
namespace llvm {
class MCSymbolWasm : public MCSymbol {
- Optional<wasm::WasmSymbolType> Type;
+ std::optional<wasm::WasmSymbolType> Type;
bool IsWeak = false;
bool IsHidden = false;
bool IsComdat = false;
bool OmitFromLinkingSection = false;
mutable bool IsUsedInInitArray = false;
mutable bool IsUsedInGOT = false;
- Optional<StringRef> ImportModule;
- Optional<StringRef> ImportName;
- Optional<StringRef> ExportName;
+ std::optional<StringRef> ImportModule;
+ std::optional<StringRef> ImportName;
+ std::optional<StringRef> ExportName;
wasm::WasmSignature *Signature = nullptr;
- Optional<wasm::WasmGlobalType> GlobalType;
- Optional<wasm::WasmTableType> TableType;
+ std::optional<wasm::WasmGlobalType> GlobalType;
+ std::optional<wasm::WasmTableType> TableType;
/// An expression describing how to calculate the size of a symbol. If a
/// symbol has no size this field will be NULL.
bool isSection() const { return Type == wasm::WASM_SYMBOL_TYPE_SECTION; }
bool isTag() const { return Type == wasm::WASM_SYMBOL_TYPE_TAG; }
- Optional<wasm::WasmSymbolType> getType() const { return Type; }
+ std::optional<wasm::WasmSymbolType> getType() const { return Type; }
void setType(wasm::WasmSymbolType type) { Type = type; }
}
private:
- Optional<XCOFF::StorageClass> StorageClass;
+ std::optional<XCOFF::StorageClass> StorageClass;
MCSectionXCOFF *RepresentedCsect = nullptr;
XCOFF::VisibilityType VisibilityType = XCOFF::SYM_V_UNSPECIFIED;
StringRef SymbolTableName;
namespace mc {
bool getRelaxAll();
-Optional<bool> getExplicitRelaxAll();
+std::optional<bool> getExplicitRelaxAll();
bool getIncrementalLinkerCompatible();
AddrPool.getIndex(S);
}
-Optional<MD5::MD5Result> DwarfDebug::getMD5AsBytes(const DIFile *File) const {
+std::optional<MD5::MD5Result>
+DwarfDebug::getMD5AsBytes(const DIFile *File) const {
assert(File);
if (getDwarfVersion() < 5)
return std::nullopt;
/// If the \p File has an MD5 checksum, return it as an MD5Result
/// allocated in the MCContext.
- Optional<MD5::MD5Result> getMD5AsBytes(const DIFile *File) const;
+ std::optional<MD5::MD5Result> getMD5AsBytes(const DIFile *File) const;
};
} // end namespace llvm
return;
}
- if (Optional<unsigned> Reg = TRI->getLLVMRegNum(DwarfReg, true))
+ if (std::optional<unsigned> Reg = TRI->getLLVMRegNum(DwarfReg, true))
OS << printReg(*Reg, TRI);
else
OS << "<badreg>";
static void printRegister(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH,
unsigned RegNum) {
if (MRI) {
- if (Optional<unsigned> LLVMRegNum = MRI->getLLVMRegNum(RegNum, IsEH)) {
+ if (std::optional<unsigned> LLVMRegNum = MRI->getLLVMRegNum(RegNum, IsEH)) {
if (const char *RegName = MRI->getName(*LLVMRegNum)) {
OS << RegName;
return;
else
DwarfRegNum = Opcode - DW_OP_reg0;
- if (Optional<unsigned> LLVMRegNum = MRI->getLLVMRegNum(DwarfRegNum, isEH)) {
+ if (std::optional<unsigned> LLVMRegNum =
+ MRI->getLLVMRegNum(DwarfRegNum, isEH)) {
if (const char *RegName = MRI->getName(*LLVMRegNum)) {
if ((Opcode >= DW_OP_breg0 && Opcode <= DW_OP_breg31) ||
Opcode == DW_OP_bregx)
// DW_OP_regx: A register, with the register num given as an operand.
// Printed as the plain register name.
uint64_t DwarfRegNum = Op.getRawOperand(0);
- Optional<unsigned> LLVMRegNum = MRI.getLLVMRegNum(DwarfRegNum, false);
+ std::optional<unsigned> LLVMRegNum =
+ MRI.getLLVMRegNum(DwarfRegNum, false);
if (!LLVMRegNum) {
OS << "<unknown register " << DwarfRegNum << ">";
return false;
case dwarf::DW_OP_bregx: {
int DwarfRegNum = Op.getRawOperand(0);
int64_t Offset = Op.getRawOperand(1);
- Optional<unsigned> LLVMRegNum = MRI.getLLVMRegNum(DwarfRegNum, false);
+ std::optional<unsigned> LLVMRegNum =
+ MRI.getLLVMRegNum(DwarfRegNum, false);
if (!LLVMRegNum) {
OS << "<unknown register " << DwarfRegNum << ">";
return false;
// DW_OP_reg<N>: A register, with the register num implied by the
// opcode. Printed as the plain register name.
uint64_t DwarfRegNum = Opcode - dwarf::DW_OP_reg0;
- Optional<unsigned> LLVMRegNum = MRI.getLLVMRegNum(DwarfRegNum, false);
+ std::optional<unsigned> LLVMRegNum =
+ MRI.getLLVMRegNum(DwarfRegNum, false);
if (!LLVMRegNum) {
OS << "<unknown register " << DwarfRegNum << ">";
return false;
Opcode <= dwarf::DW_OP_breg31) {
int DwarfRegNum = Opcode - dwarf::DW_OP_breg0;
int64_t Offset = Op.getRawOperand(0);
- Optional<unsigned> LLVMRegNum = MRI.getLLVMRegNum(DwarfRegNum, false);
+ std::optional<unsigned> LLVMRegNum =
+ MRI.getLLVMRegNum(DwarfRegNum, false);
if (!LLVMRegNum) {
OS << "<unknown register " << DwarfRegNum << ">";
return false;
}
}
-Optional<MCFixupKind> MCAsmBackend::getFixupKind(StringRef Name) const {
+std::optional<MCFixupKind> MCAsmBackend::getFixupKind(StringRef Name) const {
return std::nullopt;
}
void PrintQuotedString(StringRef Data, raw_ostream &OS) const;
void printDwarfFileDirective(unsigned FileNo, StringRef Directory,
StringRef Filename,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source,
bool UseDwarfDirectory,
raw_svector_ostream &OS) const;
void emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
SMLoc Loc = SMLoc()) override;
- void emitAlignmentDirective(unsigned ByteAlignment, Optional<int64_t> Value,
- unsigned ValueSize, unsigned MaxBytesToEmit);
+ void emitAlignmentDirective(unsigned ByteAlignment,
+ std::optional<int64_t> Value, unsigned ValueSize,
+ unsigned MaxBytesToEmit);
void emitValueToAlignment(Align Alignment, int64_t Value = 0,
unsigned ValueSize = 1,
void emitFileDirective(StringRef Filename) override;
void emitFileDirective(StringRef Filename, StringRef CompilerVerion,
StringRef TimeStamp, StringRef Description) override;
- Expected<unsigned>
- tryEmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
- StringRef Filename,
- Optional<MD5::MD5Result> Checksum = std::nullopt,
- std::optional<StringRef> Source = std::nullopt,
- unsigned CUID = 0) override;
+ Expected<unsigned> tryEmitDwarfFileDirective(
+ unsigned FileNo, StringRef Directory, StringRef Filename,
+ std::optional<MD5::MD5Result> Checksum = std::nullopt,
+ std::optional<StringRef> Source = std::nullopt,
+ unsigned CUID = 0) override;
void emitDwarfFile0Directive(StringRef Directory, StringRef Filename,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source,
unsigned CUID = 0) override;
void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column,
void emitBundleLock(bool AlignToEnd) override;
void emitBundleUnlock() override;
- Optional<std::pair<bool, std::string>>
+ std::optional<std::pair<bool, std::string>>
emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr,
SMLoc Loc, const MCSubtargetInfo &STI) override;
}
void MCAsmStreamer::emitAlignmentDirective(unsigned ByteAlignment,
- Optional<int64_t> Value,
+ std::optional<int64_t> Value,
unsigned ValueSize,
unsigned MaxBytesToEmit) {
if (MAI->useDotAlignForAlignment()) {
void MCAsmStreamer::printDwarfFileDirective(
unsigned FileNo, StringRef Directory, StringRef Filename,
- Optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
+ std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
bool UseDwarfDirectory, raw_svector_ostream &OS) const {
SmallString<128> FullPathName;
Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
unsigned FileNo, StringRef Directory, StringRef Filename,
- Optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
+ std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
unsigned CUID) {
assert(CUID == 0 && "multiple CUs not supported by MCAsmStreamer");
return FileNo;
}
-void MCAsmStreamer::emitDwarfFile0Directive(StringRef Directory,
- StringRef Filename,
- Optional<MD5::MD5Result> Checksum,
- std::optional<StringRef> Source,
- unsigned CUID) {
+void MCAsmStreamer::emitDwarfFile0Directive(
+ StringRef Directory, StringRef Filename,
+ std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
+ unsigned CUID) {
assert(CUID == 0);
// .file 0 is new for DWARF v5.
if (getContext().getDwarfVersion() < 5)
// just ones that map to LLVM register numbers and have known names.
// Fall back to using the original number directly if no name is known.
const MCRegisterInfo *MRI = getContext().getRegisterInfo();
- if (Optional<unsigned> LLVMRegister = MRI->getLLVMRegNum(Register, true)) {
+ if (std::optional<unsigned> LLVMRegister =
+ MRI->getLLVMRegNum(Register, true)) {
InstPrinter->printRegName(OS, *LLVMRegister);
return;
}
EmitEOL();
}
-Optional<std::pair<bool, std::string>>
+std::optional<std::pair<bool, std::string>>
MCAsmStreamer::emitRelocDirective(const MCExpr &Offset, StringRef Name,
const MCExpr *Expr, SMLoc,
const MCSubtargetInfo &STI) {
ELFSeenGenericMergeableSections.count(SectionName);
}
-Optional<unsigned> MCContext::getELFUniqueIDForEntsize(StringRef SectionName,
- unsigned Flags,
- unsigned EntrySize) {
+std::optional<unsigned>
+MCContext::getELFUniqueIDForEntsize(StringRef SectionName, unsigned Flags,
+ unsigned EntrySize) {
auto I = ELFEntrySizeMap.find(
MCContext::ELFEntrySizeKey{SectionName, Flags, EntrySize});
- return (I != ELFEntrySizeMap.end()) ? Optional<unsigned>(I->second)
+ return (I != ELFEntrySizeMap.end()) ? std::optional<unsigned>(I->second)
: std::nullopt;
}
MCSectionXCOFF *MCContext::getXCOFFSection(
StringRef Section, SectionKind Kind,
- Optional<XCOFF::CsectProperties> CsectProp, bool MultiSymbolsAllowed,
+ std::optional<XCOFF::CsectProperties> CsectProp, bool MultiSymbolsAllowed,
const char *BeginSymName,
- Optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSectionSubtypeFlags) {
+ std::optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSectionSubtypeFlags) {
bool IsDwarfSec = DwarfSectionSubtypeFlags.has_value();
assert((IsDwarfSec != CsectProp.has_value()) && "Invalid XCOFF section!");
void MCContext::setGenDwarfRootFile(StringRef InputFileName, StringRef Buffer) {
// MCDwarf needs the root file as well as the compilation directory.
// If we find a '.file 0' directive that will supersede these values.
- Optional<MD5::MD5Result> Cksum;
+ std::optional<MD5::MD5Result> Cksum;
if (getDwarfVersion() >= 5) {
MD5 Hash;
MD5::MD5Result Sum;
/// directory tables. If the file number has already been allocated it is an
/// error and zero is returned and the client reports the error, else the
/// allocated file number is returned. The file numbers may be in any order.
-Expected<unsigned> MCContext::getDwarfFile(StringRef Directory,
- StringRef FileName,
- unsigned FileNumber,
- Optional<MD5::MD5Result> Checksum,
- std::optional<StringRef> Source,
- unsigned CUID) {
+Expected<unsigned>
+MCContext::getDwarfFile(StringRef Directory, StringRef FileName,
+ unsigned FileNumber,
+ std::optional<MD5::MD5Result> Checksum,
+ std::optional<StringRef> Source, unsigned CUID) {
MCDwarfLineTable &Table = MCDwarfLineTablesCUMap[CUID];
return Table.tryGetFile(Directory, FileName, Checksum, Source, DwarfVersion,
FileNumber);
MCDisassembler::~MCDisassembler() = default;
-Optional<MCDisassembler::DecodeStatus>
+std::optional<MCDisassembler::DecodeStatus>
MCDisassembler::onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &CStream) const {
return;
// In a v5 non-split line table, put the strings in a separate section.
- Optional<MCDwarfLineStr> LineStr;
+ std::optional<MCDwarfLineStr> LineStr;
if (context.getDwarfVersion() >= 5)
LineStr.emplace(context);
MCSection *Section) const {
if (!HasSplitLineTable)
return;
- Optional<MCDwarfLineStr> NoLineStr(std::nullopt);
+ std::optional<MCDwarfLineStr> NoLineStr(std::nullopt);
MCOS.switchSection(Section);
MCOS.emitLabel(Header.Emit(&MCOS, Params, std::nullopt, NoLineStr).second);
}
std::pair<MCSymbol *, MCSymbol *>
MCDwarfLineTableHeader::Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
- Optional<MCDwarfLineStr> &LineStr) const {
+ std::optional<MCDwarfLineStr> &LineStr) const {
static const char StandardOpcodeLengths[] = {
0, // length of DW_LNS_copy
1, // length of DW_LNS_advance_pc
static void emitOneV5FileEntry(MCStreamer *MCOS, const MCDwarfFile &DwarfFile,
bool EmitMD5, bool HasSource,
- Optional<MCDwarfLineStr> &LineStr) {
+ std::optional<MCDwarfLineStr> &LineStr) {
assert(!DwarfFile.Name.empty());
if (LineStr)
LineStr->emitRef(MCOS, DwarfFile.Name);
}
void MCDwarfLineTableHeader::emitV5FileDirTables(
- MCStreamer *MCOS, Optional<MCDwarfLineStr> &LineStr) const {
+ MCStreamer *MCOS, std::optional<MCDwarfLineStr> &LineStr) const {
// The directory format, which is just a list of the directory paths. In a
// non-split object, these are references to .debug_line_str; in a split
// object, they are inline strings.
std::pair<MCSymbol *, MCSymbol *>
MCDwarfLineTableHeader::Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
ArrayRef<char> StandardOpcodeLengths,
- Optional<MCDwarfLineStr> &LineStr) const {
+ std::optional<MCDwarfLineStr> &LineStr) const {
MCContext &context = MCOS->getContext();
// Create a symbol at the beginning of the line table.
}
void MCDwarfLineTable::emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params,
- Optional<MCDwarfLineStr> &LineStr) const {
+ std::optional<MCDwarfLineStr> &LineStr) const {
MCSymbol *LineEndSym = Header.Emit(MCOS, Params, LineStr).second;
// Put out the line tables.
MCOS->emitLabel(LineEndSym);
}
-Expected<unsigned> MCDwarfLineTable::tryGetFile(StringRef &Directory,
- StringRef &FileName,
- Optional<MD5::MD5Result> Checksum,
- std::optional<StringRef> Source,
- uint16_t DwarfVersion,
- unsigned FileNumber) {
+Expected<unsigned>
+MCDwarfLineTable::tryGetFile(StringRef &Directory, StringRef &FileName,
+ std::optional<MD5::MD5Result> Checksum,
+ std::optional<StringRef> Source,
+ uint16_t DwarfVersion, unsigned FileNumber) {
return Header.tryGetFile(Directory, FileName, Checksum, Source, DwarfVersion,
FileNumber);
}
static bool isRootFile(const MCDwarfFile &RootFile, StringRef &Directory,
- StringRef &FileName, Optional<MD5::MD5Result> Checksum) {
+ StringRef &FileName,
+ std::optional<MD5::MD5Result> Checksum) {
if (RootFile.Name.empty() || StringRef(RootFile.Name) != FileName)
return false;
return RootFile.Checksum == Checksum;
}
Expected<unsigned>
-MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
- StringRef &FileName,
- Optional<MD5::MD5Result> Checksum,
+MCDwarfLineTableHeader::tryGetFile(StringRef &Directory, StringRef &FileName,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source,
- uint16_t DwarfVersion,
- unsigned FileNumber) {
+ uint16_t DwarfVersion, unsigned FileNumber) {
if (Directory == CompilationDir)
Directory = "";
if (FileName.empty()) {
}
const MCConstantExpr *MCOffset = MCConstantExpr::create(Offset, getContext());
MCObjectStreamer::visitUsedExpr(*SRE);
- if (Optional<std::pair<bool, std::string>> Err =
+ if (std::optional<std::pair<bool, std::string>> Err =
MCObjectStreamer::emitRelocDirective(
*MCOffset, "BFD_RELOC_NONE", SRE, SRE->getLoc(),
*getContext().getSubtargetInfo()))
return false;
}
-Optional<uint64_t> MCInstrAnalysis::evaluateMemoryOperandAddress(
+std::optional<uint64_t> MCInstrAnalysis::evaluateMemoryOperandAddress(
const MCInst &Inst, const MCSubtargetInfo *STI, uint64_t Addr,
uint64_t Size) const {
return std::nullopt;
}
-Optional<uint64_t>
+std::optional<uint64_t>
MCInstrAnalysis::getMemoryOperandRelocationOffset(const MCInst &Inst,
uint64_t Size) const {
return std::nullopt;
// As a compile-time optimization, avoid allocating and evaluating an MCExpr
// tree for (Hi - Lo) when Hi and Lo are offsets into the same fragment.
-static Optional<uint64_t> absoluteSymbolDiff(const MCSymbol *Hi,
- const MCSymbol *Lo) {
+static std::optional<uint64_t> absoluteSymbolDiff(const MCSymbol *Hi,
+ const MCSymbol *Lo) {
assert(Hi && Lo);
if (!Hi->getFragment() || Hi->getFragment() != Lo->getFragment() ||
Hi->isVariable() || Lo->isVariable())
const MCSymbol *Lo,
unsigned Size) {
if (!getAssembler().getContext().getTargetTriple().isRISCV())
- if (Optional<uint64_t> Diff = absoluteSymbolDiff(Hi, Lo))
+ if (std::optional<uint64_t> Diff = absoluteSymbolDiff(Hi, Lo))
return emitIntValue(*Diff, Size);
MCStreamer::emitAbsoluteSymbolDiff(Hi, Lo, Size);
}
void MCObjectStreamer::emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi,
const MCSymbol *Lo) {
if (!getAssembler().getContext().getTargetTriple().isRISCV())
- if (Optional<uint64_t> Diff = absoluteSymbolDiff(Hi, Lo))
+ if (std::optional<uint64_t> Diff = absoluteSymbolDiff(Hi, Lo))
return emitULEB128IntValue(*Diff);
MCStreamer::emitAbsoluteSymbolDiffAsULEB128(Hi, Lo);
}
DF->getContents().resize(DF->getContents().size() + 8, 0);
}
-static Optional<std::pair<bool, std::string>>
+static std::optional<std::pair<bool, std::string>>
getOffsetAndDataFragment(const MCSymbol &Symbol, uint32_t &RelocOffset,
MCDataFragment *&DF) {
if (Symbol.isVariable()) {
return std::nullopt;
}
-Optional<std::pair<bool, std::string>>
+std::optional<std::pair<bool, std::string>>
MCObjectStreamer::emitRelocDirective(const MCExpr &Offset, StringRef Name,
const MCExpr *Expr, SMLoc Loc,
const MCSubtargetInfo &STI) {
- Optional<MCFixupKind> MaybeKind = Assembler->getBackend().getFixupKind(Name);
+ std::optional<MCFixupKind> MaybeKind =
+ Assembler->getBackend().getFixupKind(Name);
if (!MaybeKind)
return std::make_pair(true, std::string("unknown relocation name"));
const MCSymbol &Symbol = SRE.getSymbol();
if (Symbol.isDefined()) {
uint32_t SymbolOffset = 0;
- Optional<std::pair<bool, std::string>> Error;
- Error = getOffsetAndDataFragment(Symbol, SymbolOffset, DF);
+ std::optional<std::pair<bool, std::string>> Error =
+ getOffsetAndDataFragment(Symbol, SymbolOffset, DF);
if (Error != std::nullopt)
return Error;
const MCTargetAsmParser &MCT = getTargetParser();
const MCSubtargetInfo &STI = MCT.getSTI();
- if (Optional<std::pair<bool, std::string>> Err =
+ if (std::optional<std::pair<bool, std::string>> Err =
getStreamer().emitRelocDirective(*Offset, Name, Expr, DirectiveLoc,
STI))
return Error(Err->first ? NameLoc : OffsetLoc, Err->second);
Ctx.setGenDwarfForAssembly(false);
}
- Optional<MD5::MD5Result> CKMem;
+ std::optional<MD5::MD5Result> CKMem;
if (HasMD5) {
MD5::MD5Result Sum;
for (unsigned i = 0; i != 8; ++i) {
const MCExpr *evaluateBuiltinValue(BuiltinSymbol Symbol, SMLoc StartLoc);
- llvm::Optional<std::string> evaluateBuiltinTextMacro(BuiltinSymbol Symbol,
- SMLoc StartLoc);
+ std::optional<std::string> evaluateBuiltinTextMacro(BuiltinSymbol Symbol,
+ SMLoc StartLoc);
// ".ascii", ".asciz", ".string"
bool parseDirectiveAscii(StringRef IDVal, bool ZeroTerminated);
return false;
}
- llvm::Optional<std::string> ExpandedValue;
+ std::optional<std::string> ExpandedValue;
auto BuiltinIt = BuiltinSymbolMap.find(IDLower);
if (BuiltinIt != BuiltinSymbolMap.end()) {
ExpandedValue =
// Try to resolve as a built-in text macro
auto BuiltinIt = BuiltinSymbolMap.find(ID.lower());
if (BuiltinIt != BuiltinSymbolMap.end()) {
- llvm::Optional<std::string> BuiltinText =
+ std::optional<std::string> BuiltinText =
evaluateBuiltinTextMacro(BuiltinIt->getValue(), StartLoc);
if (!BuiltinText) {
// Not a text macro; break without substituting
Ctx.setGenDwarfForAssembly(false);
}
- Optional<MD5::MD5Result> CKMem;
+ std::optional<MD5::MD5Result> CKMem;
if (HasMD5) {
MD5::MD5Result Sum;
for (unsigned i = 0; i != 8; ++i) {
StringMap<std::string> BuiltinValues;
for (const auto &S : BuiltinSymbolMap) {
const BuiltinSymbol &Sym = S.getValue();
- if (llvm::Optional<std::string> Text = evaluateBuiltinTextMacro(Sym, Loc)) {
+ if (std::optional<std::string> Text = evaluateBuiltinTextMacro(Sym, Loc)) {
BuiltinValues[S.getKey().lower()] = std::move(*Text);
}
}
llvm_unreachable("unhandled built-in symbol");
}
-llvm::Optional<std::string>
+std::optional<std::string>
MasmParser::evaluateBuiltinTextMacro(BuiltinSymbol Symbol, SMLoc StartLoc) {
switch (Symbol) {
default:
return I->ToReg;
}
-Optional<unsigned> MCRegisterInfo::getLLVMRegNum(unsigned RegNum,
- bool isEH) const {
+std::optional<unsigned> MCRegisterInfo::getLLVMRegNum(unsigned RegNum,
+ bool isEH) const {
const DwarfLLVMRegPair *M = isEH ? EHDwarf2LRegs : Dwarf2LRegs;
unsigned Size = isEH ? EHDwarf2LRegsSize : Dwarf2LRegsSize;
// a corresponding LLVM register number at all. So if we can't map the
// EH register number to an LLVM register number, assume it's just a
// valid DWARF register number as is.
- if (Optional<unsigned> LRegNum = getLLVMRegNum(RegNum, true))
+ if (std::optional<unsigned> LRegNum = getLLVMRegNum(RegNum, true))
return getDwarfRegNum(*LRegNum, false);
return RegNum;
}
/// The implementation in this class just redirects to emitFill.
void MCStreamer::emitZeros(uint64_t NumBytes) { emitFill(NumBytes, 0); }
-Expected<unsigned>
-MCStreamer::tryEmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
- StringRef Filename,
- Optional<MD5::MD5Result> Checksum,
- std::optional<StringRef> Source,
- unsigned CUID) {
+Expected<unsigned> MCStreamer::tryEmitDwarfFileDirective(
+ unsigned FileNo, StringRef Directory, StringRef Filename,
+ std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
+ unsigned CUID) {
return getContext().getDwarfFile(Directory, Filename, FileNo, Checksum,
Source, CUID);
}
void MCStreamer::emitDwarfFile0Directive(StringRef Directory,
StringRef Filename,
- Optional<MD5::MD5Result> Checksum,
+ std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source,
unsigned CUID) {
getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
return std::nullopt;
}
-Optional<unsigned> MCSubtargetInfo::getCacheLineSize(unsigned Level) const {
+std::optional<unsigned>
+MCSubtargetInfo::getCacheLineSize(unsigned Level) const {
return std::nullopt;
}
#define MCOPT_EXP(TY, NAME) \
MCOPT(TY, NAME) \
- Optional<TY> llvm::mc::getExplicit##NAME() { \
+ std::optional<TY> llvm::mc::getExplicit##NAME() { \
if (NAME##View->getNumOccurrences()) { \
TY res = *NAME##View; \
return res; \
return Expr;
}
-static Optional<int64_t> GetOptionalAbsDifference(MCStreamer &Streamer,
- const MCSymbol *LHS,
- const MCSymbol *RHS) {
+static std::optional<int64_t> GetOptionalAbsDifference(MCStreamer &Streamer,
+ const MCSymbol *LHS,
+ const MCSymbol *RHS) {
MCContext &Context = Streamer.getContext();
const MCExpr *Diff =
MCBinaryExpr::createSub(MCSymbolRefExpr::create(LHS, Context),
static int64_t GetAbsDifference(MCStreamer &Streamer, const MCSymbol *LHS,
const MCSymbol *RHS) {
- Optional<int64_t> MaybeDiff = GetOptionalAbsDifference(Streamer, LHS, RHS);
+ std::optional<int64_t> MaybeDiff =
+ GetOptionalAbsDifference(Streamer, LHS, RHS);
if (!MaybeDiff)
report_fatal_error("Failed to evaluate function length in SEH unwind info");
return *MaybeDiff;
StringRef Name, StringRef Type) {
if (!End)
return;
- Optional<int64_t> MaybeDistance =
+ std::optional<int64_t> MaybeDistance =
GetOptionalAbsDifference(Streamer, End, Begin);
if (!MaybeDistance)
return;
StringRef Name, StringRef Type) {
if (!End)
return;
- Optional<int64_t> MaybeDistance =
+ std::optional<int64_t> MaybeDistance =
GetOptionalAbsDifference(Streamer, End, Begin);
if (!MaybeDistance)
return;
// Check that the epilog actually is at the very end of the function,
// otherwise it can't be packed.
- Optional<int64_t> MaybeDistance = GetOptionalAbsDifference(
+ std::optional<int64_t> MaybeDistance = GetOptionalAbsDifference(
streamer, info->FuncletOrFuncEnd, info->EpilogMap.begin()->first);
if (!MaybeDistance)
return -1;
if (EpilogInfo.Condition != 0xe) // ARMCC::AL
return false;
const std::vector<WinEH::Instruction> &Epilog = EpilogInfo.Instructions;
- Optional<int64_t> MaybeDistance = GetOptionalAbsDifference(
+ std::optional<int64_t> MaybeDistance = GetOptionalAbsDifference(
streamer, info->FuncletOrFuncEnd, info->EpilogMap.begin()->first);
if (!MaybeDistance)
return false;
" not correctly terminated");
}
- Optional<int64_t> RawFuncLength;
+ std::optional<int64_t> RawFuncLength;
const MCExpr *FuncLengthExpr = nullptr;
if (!info->FuncletOrFuncEnd) {
report_fatal_error("FuncletOrFuncEnd not set");
MCSymbol *EpilogStart = I.first;
uint32_t EpilogIndex = I.second;
- Optional<int64_t> MaybeEpilogOffset =
+ std::optional<int64_t> MaybeEpilogOffset =
GetOptionalAbsDifference(streamer, EpilogStart, info->Begin);
const MCExpr *OffsetExpr = nullptr;
uint32_t EpilogOffset = 0;
return AArch64::NumTargetFixupKinds;
}
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override {
const static MCFixupKindInfo Infos[AArch64::NumTargetFixupKinds] = {
}
}
-Optional<MCFixupKind> AArch64AsmBackend::getFixupKind(StringRef Name) const {
+std::optional<MCFixupKind>
+AArch64AsmBackend::getFixupKind(StringRef Name) const {
if (!TheTriple.isOSBinFormatELF())
return std::nullopt;
return MCDisassembler::Success;
}
-Optional<MCDisassembler::DecodeStatus>
+std::optional<MCDisassembler::DecodeStatus>
AMDGPUDisassembler::onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &CStream) const {
return MCDisassembler::Fail;
}
- Optional<DecodeStatus> onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
- ArrayRef<uint8_t> Bytes,
- uint64_t Address,
- raw_ostream &CStream) const override;
+ std::optional<DecodeStatus>
+ onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef<uint8_t> Bytes,
+ uint64_t Address, raw_ostream &CStream) const override;
DecodeStatus decodeKernelDescriptor(StringRef KdName, ArrayRef<uint8_t> Bytes,
uint64_t KdAddress) const;
bool writeNopData(raw_ostream &OS, uint64_t Count,
const MCSubtargetInfo *STI) const override;
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
const MCValue &Target) override;
Data[Offset + i] |= static_cast<uint8_t>((Value >> (i * 8)) & 0xff);
}
-Optional<MCFixupKind> AMDGPUAsmBackend::getFixupKind(StringRef Name) const {
- return StringSwitch<Optional<MCFixupKind>>(Name)
+std::optional<MCFixupKind>
+AMDGPUAsmBackend::getFixupKind(StringRef Name) const {
+ return StringSwitch<std::optional<MCFixupKind>>(Name)
#define ELF_RELOC(Name, Value) \
.Case(#Name, MCFixupKind(FirstLiteralRelocationKind + Value))
#include "llvm/BinaryFormat/ELFRelocs/AMDGPU.def"
};
} // end anonymous namespace
-Optional<MCFixupKind> ARMAsmBackend::getFixupKind(StringRef Name) const {
+std::optional<MCFixupKind> ARMAsmBackend::getFixupKind(StringRef Name) const {
return std::nullopt;
}
-Optional<MCFixupKind> ARMAsmBackendELF::getFixupKind(StringRef Name) const {
+std::optional<MCFixupKind>
+ARMAsmBackendELF::getFixupKind(StringRef Name) const {
unsigned Type = llvm::StringSwitch<unsigned>(Name)
#define ELF_RELOC(X, Y) .Case(#X, Y)
#include "llvm/BinaryFormat/ELFRelocs/ARM.def"
return STI->getFeatureBits()[ARM::HasV6T2Ops];
}
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
return createARMELFObjectWriter(OSABI);
}
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
};
}
return false;
}
- Optional<uint64_t> evaluateMemoryOperandAddress(const MCInst &Inst,
- const MCSubtargetInfo *STI,
- uint64_t Addr,
- uint64_t Size) const override;
+ std::optional<uint64_t>
+ evaluateMemoryOperandAddress(const MCInst &Inst, const MCSubtargetInfo *STI,
+ uint64_t Addr, uint64_t Size) const override;
};
} // namespace
-static Optional<uint64_t>
+static std::optional<uint64_t>
// NOLINTNEXTLINE(readability-identifier-naming)
evaluateMemOpAddrForAddrMode_i12(const MCInst &Inst, const MCInstrDesc &Desc,
unsigned MemOpIndex, uint64_t Addr) {
return Addr + OffImm;
}
-static Optional<uint64_t> evaluateMemOpAddrForAddrMode3(const MCInst &Inst,
- const MCInstrDesc &Desc,
- unsigned MemOpIndex,
- uint64_t Addr) {
+static std::optional<uint64_t>
+evaluateMemOpAddrForAddrMode3(const MCInst &Inst, const MCInstrDesc &Desc,
+ unsigned MemOpIndex, uint64_t Addr) {
if (MemOpIndex + 2 >= Desc.getNumOperands())
return std::nullopt;
return Addr + ImmOffs;
}
-static Optional<uint64_t> evaluateMemOpAddrForAddrMode5(const MCInst &Inst,
- const MCInstrDesc &Desc,
- unsigned MemOpIndex,
- uint64_t Addr) {
+static std::optional<uint64_t>
+evaluateMemOpAddrForAddrMode5(const MCInst &Inst, const MCInstrDesc &Desc,
+ unsigned MemOpIndex, uint64_t Addr) {
if (MemOpIndex + 1 >= Desc.getNumOperands())
return std::nullopt;
return Addr + ImmOffs * 4;
}
-static Optional<uint64_t>
+static std::optional<uint64_t>
evaluateMemOpAddrForAddrMode5FP16(const MCInst &Inst, const MCInstrDesc &Desc,
unsigned MemOpIndex, uint64_t Addr) {
if (MemOpIndex + 1 >= Desc.getNumOperands())
return Addr + ImmOffs * 2;
}
-static Optional<uint64_t>
+static std::optional<uint64_t>
// NOLINTNEXTLINE(readability-identifier-naming)
evaluateMemOpAddrForAddrModeT2_i8s4(const MCInst &Inst, const MCInstrDesc &Desc,
unsigned MemOpIndex, uint64_t Addr) {
return Addr + OffImm;
}
-static Optional<uint64_t>
+static std::optional<uint64_t>
// NOLINTNEXTLINE(readability-identifier-naming)
evaluateMemOpAddrForAddrModeT2_pc(const MCInst &Inst, const MCInstrDesc &Desc,
unsigned MemOpIndex, uint64_t Addr) {
return Addr + OffImm;
}
-static Optional<uint64_t>
+static std::optional<uint64_t>
// NOLINTNEXTLINE(readability-identifier-naming)
evaluateMemOpAddrForAddrModeT1_s(const MCInst &Inst, const MCInstrDesc &Desc,
unsigned MemOpIndex, uint64_t Addr) {
return evaluateMemOpAddrForAddrModeT2_pc(Inst, Desc, MemOpIndex, Addr);
}
-Optional<uint64_t> ARMMCInstrAnalysis::evaluateMemoryOperandAddress(
+std::optional<uint64_t> ARMMCInstrAnalysis::evaluateMemoryOperandAddress(
const MCInst &Inst, const MCSubtargetInfo *STI, uint64_t Addr,
uint64_t Size) const {
const MCInstrDesc &Desc = Info->get(Inst.getOpcode());
using namespace llvm;
-Optional<MCFixupKind> LoongArchAsmBackend::getFixupKind(StringRef Name) const {
+std::optional<MCFixupKind>
+LoongArchAsmBackend::getFixupKind(StringRef Name) const {
if (STI.getTargetTriple().isOSBinFormatELF()) {
auto Type = llvm::StringSwitch<unsigned>(Name)
#define ELF_RELOC(X, Y) .Case(#X, Y)
return LoongArch::NumTargetFixupKinds;
}
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
}
}
-Optional<MCFixupKind> MipsAsmBackend::getFixupKind(StringRef Name) const {
+std::optional<MCFixupKind> MipsAsmBackend::getFixupKind(StringRef Name) const {
unsigned Type = llvm::StringSwitch<unsigned>(Name)
.Case("BFD_RELOC_NONE", ELF::R_MIPS_NONE)
.Case("BFD_RELOC_16", ELF::R_MIPS_16)
if (Type != -1u)
return static_cast<MCFixupKind>(FirstLiteralRelocationKind + Type);
- return StringSwitch<Optional<MCFixupKind>>(Name)
+ return StringSwitch<std::optional<MCFixupKind>>(Name)
.Case("R_MIPS_NONE", FK_NONE)
.Case("R_MIPS_32", FK_Data_4)
.Case("R_MIPS_CALL_HI16", (MCFixupKind)Mips::fixup_Mips_CALL_HI16)
uint64_t Value, bool IsResolved,
const MCSubtargetInfo *STI) const override;
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
unsigned getNumFixupKinds() const override {
return createPPCELFObjectWriter(Is64, OSABI);
}
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
};
class XCOFFPPCAsmBackend : public PPCAsmBackend {
} // end anonymous namespace
-Optional<MCFixupKind> ELFPPCAsmBackend::getFixupKind(StringRef Name) const {
+std::optional<MCFixupKind>
+ELFPPCAsmBackend::getFixupKind(StringRef Name) const {
if (TT.isOSBinFormatELF()) {
unsigned Type;
if (TT.isPPC64()) {
using namespace llvm;
-Optional<MCFixupKind> RISCVAsmBackend::getFixupKind(StringRef Name) const {
+std::optional<MCFixupKind> RISCVAsmBackend::getFixupKind(StringRef Name) const {
if (STI.getTargetTriple().isOSBinFormatELF()) {
unsigned Type;
Type = llvm::StringSwitch<unsigned>(Name)
return RISCV::NumTargetFixupKinds;
}
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
return Sparc::NumTargetFixupKinds;
}
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override {
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override {
unsigned Type;
Type = llvm::StringSwitch<unsigned>(Name)
#define ELF_RELOC(X, Y) .Case(#X, Y)
unsigned getNumFixupKinds() const override {
return SystemZ::NumTargetFixupKinds;
}
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
const MCValue &Target) override;
};
} // end anonymous namespace
-Optional<MCFixupKind> SystemZMCAsmBackend::getFixupKind(StringRef Name) const {
+std::optional<MCFixupKind>
+SystemZMCAsmBackend::getFixupKind(StringRef Name) const {
unsigned Type = llvm::StringSwitch<unsigned>(Name)
#define ELF_RELOC(X, Y) .Case(#X, Y)
#include "llvm/BinaryFormat/ELFRelocs/SystemZ.def"
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &CStream) const override;
- Optional<DecodeStatus> onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
- ArrayRef<uint8_t> Bytes,
- uint64_t Address,
- raw_ostream &CStream) const override;
+ std::optional<DecodeStatus>
+ onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef<uint8_t> Bytes,
+ uint64_t Address, raw_ostream &CStream) const override;
public:
WebAssemblyDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx,
return true;
}
-Optional<MCDisassembler::DecodeStatus> WebAssemblyDisassembler::onSymbolStart(
- SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef<uint8_t> Bytes,
- uint64_t Address, raw_ostream &CStream) const {
+std::optional<MCDisassembler::DecodeStatus>
+WebAssemblyDisassembler::onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
+ ArrayRef<uint8_t> Bytes,
+ uint64_t Address,
+ raw_ostream &CStream) const {
Size = 0;
if (Address == 0) {
// Start of a code section: we're parsing only the function count.
}
void WebAssemblyAsmPrinter::emitSymbolType(const MCSymbolWasm *Sym) {
- Optional<wasm::WasmSymbolType> WasmTy = Sym->getType();
+ std::optional<wasm::WasmSymbolType> WasmTy = Sym->getType();
if (!WasmTy)
return;
return X86::NumTargetFixupKinds;
}
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
Sec->ensureMinAlignment(AlignBoundary);
}
-Optional<MCFixupKind> X86AsmBackend::getFixupKind(StringRef Name) const {
+std::optional<MCFixupKind> X86AsmBackend::getFixupKind(StringRef Name) const {
if (STI.getTargetTriple().isOSBinFormatELF()) {
unsigned Type;
if (STI.getTargetTriple().getArch() == Triple::x86_64) {
, Is64Bit(is64Bit) {
}
- Optional<MCFixupKind> getFixupKind(StringRef Name) const override {
- return StringSwitch<Optional<MCFixupKind>>(Name)
+ std::optional<MCFixupKind> getFixupKind(StringRef Name) const override {
+ return StringSwitch<std::optional<MCFixupKind>>(Name)
.Case("dir32", FK_Data_4)
.Case("secrel32", FK_SecRel_4)
.Case("secidx", FK_SecRel_2)
bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size,
uint64_t &Target) const override;
- Optional<uint64_t> evaluateMemoryOperandAddress(const MCInst &Inst,
- const MCSubtargetInfo *STI,
- uint64_t Addr,
- uint64_t Size) const override;
- Optional<uint64_t>
+ std::optional<uint64_t>
+ evaluateMemoryOperandAddress(const MCInst &Inst, const MCSubtargetInfo *STI,
+ uint64_t Addr, uint64_t Size) const override;
+ std::optional<uint64_t>
getMemoryOperandRelocationOffset(const MCInst &Inst,
uint64_t Size) const override;
};
return true;
}
-Optional<uint64_t> X86MCInstrAnalysis::evaluateMemoryOperandAddress(
+std::optional<uint64_t> X86MCInstrAnalysis::evaluateMemoryOperandAddress(
const MCInst &Inst, const MCSubtargetInfo *STI, uint64_t Addr,
uint64_t Size) const {
const MCInstrDesc &MCID = Info->get(Inst.getOpcode());
return std::nullopt;
}
-Optional<uint64_t>
+std::optional<uint64_t>
X86MCInstrAnalysis::getMemoryOperandRelocationOffset(const MCInst &Inst,
uint64_t Size) const {
if (Inst.getOpcode() != X86::LEA64r)
return Error::success();
}
-Optional<XCOFF::StorageMappingClass>
+std::optional<XCOFF::StorageMappingClass>
objdump::getXCOFFSymbolCsectSMC(const XCOFFObjectFile &Obj,
const SymbolRef &Sym) {
const XCOFFSymbolRef SymRef = Obj.toSymbolRef(Sym.getRawDataRefImpl());
return CsectAuxEntOrErr.get().getStorageMappingClass();
}
-Optional<object::SymbolRef>
+std::optional<object::SymbolRef>
objdump::getXCOFFSymbolContainingSymbolRef(const XCOFFObjectFile &Obj,
const SymbolRef &Sym) {
const XCOFFSymbolRef SymRef = Obj.toSymbolRef(Sym.getRawDataRefImpl());
struct SymbolInfoTy;
namespace objdump {
-Optional<XCOFF::StorageMappingClass>
+std::optional<XCOFF::StorageMappingClass>
getXCOFFSymbolCsectSMC(const object::XCOFFObjectFile &Obj,
const object::SymbolRef &Sym);
-Optional<object::SymbolRef>
+std::optional<object::SymbolRef>
getXCOFFSymbolContainingSymbolRef(const object::XCOFFObjectFile &Obj,
const object::SymbolRef &Sym);
llvm_unreachable("Unsupported binary format");
}
-static Optional<SectionRef> getWasmCodeSection(const WasmObjectFile &Obj) {
+static std::optional<SectionRef> getWasmCodeSection(const WasmObjectFile &Obj) {
for (auto SecI : Obj.sections()) {
const WasmSection &Section = Obj.getWasmSection(SecI);
if (Section.Type == wasm::WASM_SEC_CODE)
static void
addMissingWasmCodeSymbols(const WasmObjectFile &Obj,
std::map<SectionRef, SectionSymbolsTy> &AllSymbols) {
- Optional<SectionRef> Section = getWasmCodeSection(Obj);
+ std::optional<SectionRef> Section = getWasmCodeSection(Obj);
if (!Section)
return;
SectionSymbolsTy &Symbols = AllSymbols[*Section];
DataRefImpl SymbolDRI = Symbol.getRawDataRefImpl();
const uint32_t SymbolIndex = XCOFFObj.getSymbolIndex(SymbolDRI.p);
- Optional<XCOFF::StorageMappingClass> Smc =
+ std::optional<XCOFF::StorageMappingClass> Smc =
getXCOFFSymbolCsectSMC(XCOFFObj, Symbol);
return SymbolInfoTy(Addr, Name, Smc, SymbolIndex,
isLabel(XCOFFObj, Symbol));
bool PrintTarget =
MIA->evaluateBranch(Inst, SectionAddr + Index, Size, Target);
if (!PrintTarget)
- if (Optional<uint64_t> MaybeTarget =
+ if (std::optional<uint64_t> MaybeTarget =
MIA->evaluateMemoryOperandAddress(
Inst, STI, SectionAddr + Index, Size)) {
Target = *MaybeTarget;
StringRef SectionName = unwrapOrError(Section->getName(), FileName);
outs() << SectionName;
if (O.isXCOFF()) {
- Optional<SymbolRef> SymRef =
+ std::optional<SymbolRef> SymRef =
getXCOFFSymbolContainingSymbolRef(cast<XCOFFObjectFile>(O), Symbol);
if (SymRef) {
TheStreamer->switchSection(C.MOFI->getDwarfLineSection());
MCDwarfLineTableHeader Header;
MCDwarfLineTableParams Params = Assembler.getDWARFLinetableParams();
- Optional<MCDwarfLineStr> LineStr(std::nullopt);
+ std::optional<MCDwarfLineStr> LineStr(std::nullopt);
if (Ctx.getDwarfVersion() >= 5) {
LineStr.emplace(Ctx);
Header.setRootFile("dir", "file", std::nullopt, std::nullopt);