diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index 9e7b93064ef2..24975c1e206a 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -27,6 +27,7 @@ #include "llvm/Support/PrettyStackTrace.h" #include #include +#include #include namespace lld::elf { @@ -310,7 +311,7 @@ struct Config { SeparateSegmentKind zSeparate; ELFKind ekind = ELFNoneKind; uint16_t emachine = llvm::ELF::EM_NONE; - llvm::Optional imageBase; + std::optional imageBase; uint64_t commonPageSize; uint64_t maxPageSize; uint64_t mipsGotSize; diff --git a/lld/ELF/DWARF.cpp b/lld/ELF/DWARF.cpp index 062f396d8227..99bb5e1cc6a9 100644 --- a/lld/ELF/DWARF.cpp +++ b/lld/ELF/DWARF.cpp @@ -107,7 +107,7 @@ LLDDwarfObj::findAux(const InputSectionBase &sec, uint64_t pos, auto it = partition_point(rels, [=](const RelTy &a) { return a.r_offset < pos; }); if (it == rels.end() || it->r_offset != pos) - return None; + return std::nullopt; const RelTy &rel = *it; const ObjFile *file = sec.getFile(); diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index b8cc8ef24b7e..20411d91c275 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -227,7 +227,7 @@ static bool isBitcode(MemoryBufferRef mb) { void LinkerDriver::addFile(StringRef path, bool withLOption) { using namespace sys::fs; - Optional buffer = readFile(path); + std::optional buffer = readFile(path); if (!buffer) return; MemoryBufferRef mbref = *buffer; @@ -314,7 +314,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) { // Add a given library by searching it from input search paths. void LinkerDriver::addLibrary(StringRef name) { - if (Optional path = searchLibrary(name)) + if (std::optional path = searchLibrary(name)) addFile(saver().save(*path), /*withLOption=*/true); else error("unable to find library -l" + name, ErrorTag::LibNotFound, {name}); @@ -1460,7 +1460,7 @@ static void readConfigs(opt::InputArgList &args) { if (args.hasArg(OPT_call_graph_ordering_file)) error("--symbol-ordering-file and --call-graph-order-file " "may not be used together"); - if (Optional buffer = readFile(arg->getValue())){ + if (std::optional buffer = readFile(arg->getValue())) { config->symbolOrderingFile = getSymbolOrderingFile(*buffer); // Also need to disable CallGraphProfileSort to prevent // LLD order symbols with CGProfile @@ -1479,7 +1479,7 @@ static void readConfigs(opt::InputArgList &args) { if (auto *arg = args.getLastArg(OPT_retain_symbols_file)) { config->versionDefinitions[VER_NDX_LOCAL].nonLocalPatterns.push_back( {"*", /*isExternCpp=*/false, /*hasWildcard=*/true}); - if (Optional buffer = readFile(arg->getValue())) + if (std::optional buffer = readFile(arg->getValue())) for (StringRef s : args::getLines(*buffer)) config->versionDefinitions[VER_NDX_GLOBAL].nonLocalPatterns.push_back( {s, /*isExternCpp=*/false, /*hasWildcard=*/false}); @@ -1510,12 +1510,12 @@ static void readConfigs(opt::InputArgList &args) { config->bsymbolic == BsymbolicKind::All || args.hasArg(OPT_dynamic_list); for (auto *arg : args.filtered(OPT_dynamic_list, OPT_export_dynamic_symbol_list)) - if (Optional buffer = readFile(arg->getValue())) + if (std::optional buffer = readFile(arg->getValue())) readDynamicList(*buffer); for (auto *arg : args.filtered(OPT_version_script)) - if (Optional path = searchScript(arg->getValue())) { - if (Optional buffer = readFile(*path)) + if (std::optional path = searchScript(arg->getValue())) { + if (std::optional buffer = readFile(*path)) readVersionScript(*buffer); } else { error(Twine("cannot find version script ") + arg->getValue()); @@ -1622,8 +1622,8 @@ void LinkerDriver::createFiles(opt::InputArgList &args) { break; } case OPT_script: - if (Optional path = searchScript(arg->getValue())) { - if (Optional mb = readFile(*path)) + if (std::optional path = searchScript(arg->getValue())) { + if (std::optional mb = readFile(*path)) readLinkerScript(*mb); break; } @@ -1653,7 +1653,7 @@ void LinkerDriver::createFiles(opt::InputArgList &args) { inWholeArchive = false; break; case OPT_just_symbols: - if (Optional mb = readFile(arg->getValue())) { + if (std::optional mb = readFile(arg->getValue())) { files.push_back(createObjFile(*mb)); files.back()->justSymbols = true; } @@ -1757,12 +1757,12 @@ static uint64_t getCommonPageSize(opt::InputArgList &args) { } // Parses --image-base option. -static Optional getImageBase(opt::InputArgList &args) { +static std::optional getImageBase(opt::InputArgList &args) { // Because we are using "Config->maxPageSize" here, this function has to be // called after the variable is initialized. auto *arg = args.getLastArg(OPT_image_base); if (!arg) - return None; + return std::nullopt; StringRef s = arg->getValue(); uint64_t v; @@ -2855,7 +2855,7 @@ void LinkerDriver::link(opt::InputArgList &args) { // Read the callgraph now that we know what was gced or icfed if (config->callGraphProfileSort) { if (auto *arg = args.getLastArg(OPT_call_graph_ordering_file)) - if (Optional buffer = readFile(arg->getValue())) + if (std::optional buffer = readFile(arg->getValue())) readCallGraph(*buffer); invokeELFT(readCallGraphsFromObjectFiles); } diff --git a/lld/ELF/Driver.h b/lld/ELF/Driver.h index 20a7a8edfd26..3f7272f20e7c 100644 --- a/lld/ELF/Driver.h +++ b/lld/ELF/Driver.h @@ -10,9 +10,9 @@ #define LLD_ELF_DRIVER_H #include "lld/Common/LLVM.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Option/ArgList.h" +#include namespace lld::elf { // Parses command line options. @@ -33,10 +33,10 @@ enum { void printHelp(); std::string createResponseFile(const llvm::opt::InputArgList &args); -llvm::Optional findFromSearchPaths(StringRef path); -llvm::Optional searchScript(StringRef path); -llvm::Optional searchLibraryBaseName(StringRef path); -llvm::Optional searchLibrary(StringRef path); +std::optional findFromSearchPaths(StringRef path); +std::optional searchScript(StringRef path); +std::optional searchLibraryBaseName(StringRef path); +std::optional searchLibrary(StringRef path); } // namespace lld::elf diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp index ec2f6ba8e6ed..1a856c1e07c3 100644 --- a/lld/ELF/DriverUtils.cpp +++ b/lld/ELF/DriverUtils.cpp @@ -16,7 +16,6 @@ #include "Driver.h" #include "lld/Common/CommonLinkerContext.h" #include "lld/Common/Reproduce.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/Triple.h" #include "llvm/Option/Option.h" #include "llvm/Support/CommandLine.h" @@ -24,6 +23,7 @@ #include "llvm/Support/Host.h" #include "llvm/Support/Path.h" #include "llvm/Support/TimeProfiler.h" +#include using namespace llvm; using namespace llvm::sys; @@ -207,7 +207,8 @@ std::string elf::createResponseFile(const opt::InputArgList &args) { // Find a file by concatenating given paths. If a resulting path // starts with "=", the character is replaced with a --sysroot value. -static Optional findFile(StringRef path1, const Twine &path2) { +static std::optional findFile(StringRef path1, + const Twine &path2) { SmallString<128> s; if (path1.startswith("=")) path::append(s, config->sysroot, path1.substr(1), path2); @@ -216,31 +217,31 @@ static Optional findFile(StringRef path1, const Twine &path2) { if (fs::exists(s)) return std::string(s); - return None; + return std::nullopt; } -Optional elf::findFromSearchPaths(StringRef path) { +std::optional elf::findFromSearchPaths(StringRef path) { for (StringRef dir : config->searchPaths) - if (Optional s = findFile(dir, path)) + if (std::optional s = findFile(dir, path)) return s; - return None; + return std::nullopt; } // This is for -l. We'll look for lib.so or lib.a from // search paths. -Optional elf::searchLibraryBaseName(StringRef name) { +std::optional elf::searchLibraryBaseName(StringRef name) { for (StringRef dir : config->searchPaths) { if (!config->isStatic) - if (Optional s = findFile(dir, "lib" + name + ".so")) + if (std::optional s = findFile(dir, "lib" + name + ".so")) return s; - if (Optional s = findFile(dir, "lib" + name + ".a")) + if (std::optional s = findFile(dir, "lib" + name + ".a")) return s; } - return None; + return std::nullopt; } // This is for -l. -Optional elf::searchLibrary(StringRef name) { +std::optional elf::searchLibrary(StringRef name) { llvm::TimeTraceScope timeScope("Locate library", name); if (name.startswith(":")) return findFromSearchPaths(name.substr(1)); @@ -250,7 +251,7 @@ Optional elf::searchLibrary(StringRef name) { // If a linker/version script doesn't exist in the current directory, we also // look for the script in the '-L' search paths. This matches the behaviour of // '-T', --version-script=, and linker script INPUT() command in ld.bfd. -Optional elf::searchScript(StringRef name) { +std::optional elf::searchScript(StringRef name) { if (fs::exists(name)) return name.str(); return findFromSearchPaths(name); diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 0b932dfab409..4b7b8f93a1f6 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -187,7 +187,7 @@ InputFile::InputFile(Kind k, MemoryBufferRef m) ++nextGroupId; } -Optional elf::readFile(StringRef path) { +std::optional elf::readFile(StringRef path) { llvm::TimeTraceScope timeScope("Load input files", path); // The --chroot option changes our virtual root directory. @@ -202,7 +202,7 @@ Optional elf::readFile(StringRef path) { /*RequiresNullTerminator=*/false); if (auto ec = mbOrErr.getError()) { error("cannot open " + path + ": " + ec.message()); - return None; + return std::nullopt; } MemoryBufferRef mbref = (*mbOrErr)->getMemBufferRef(); @@ -357,9 +357,9 @@ StringRef InputFile::getNameForScript() const { static void addDependentLibrary(StringRef specifier, const InputFile *f) { if (!config->dependentLibraries) return; - if (Optional s = searchLibraryBaseName(specifier)) + if (std::optional s = searchLibraryBaseName(specifier)) ctx.driver.addFile(saver().save(*s), /*withLOption=*/true); - else if (Optional s = findFromSearchPaths(specifier)) + else if (std::optional s = findFromSearchPaths(specifier)) ctx.driver.addFile(saver().save(*s), /*withLOption=*/true); else if (fs::exists(specifier)) ctx.driver.addFile(specifier, /*withLOption=*/false); diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h index c2b0f9d91579..b5d09d4ec588 100644 --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -43,7 +43,7 @@ class Symbol; extern std::unique_ptr tar; // Opens a given file. -llvm::Optional readFile(StringRef path); +std::optional readFile(StringRef path); // Add symbols in File to the symbol table. void parseFile(InputFile *file); diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index a8586330a7e9..9eff81b4ce0c 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -834,7 +834,7 @@ void InputSection::relocateNonAlloc(uint8_t *buf, ArrayRef rels) { const bool isDebugLocOrRanges = isDebug && (name == ".debug_loc" || name == ".debug_ranges"); const bool isDebugLine = isDebug && name == ".debug_line"; - Optional tombstone; + std::optional tombstone; for (const auto &patAndValue : llvm::reverse(config->deadRelocInNonAlloc)) if (patAndValue.first.match(this->name)) { tombstone = patAndValue.second; diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 7c34f02558fc..814794180d2c 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -1405,12 +1405,12 @@ ExprValue LinkerScript::getSymbolValue(StringRef name, const Twine &loc) { } // Returns the index of the segment named Name. -static Optional getPhdrIndex(ArrayRef vec, - StringRef name) { +static std::optional getPhdrIndex(ArrayRef vec, + StringRef name) { for (size_t i = 0; i < vec.size(); ++i) if (vec[i].name == name) return i; - return None; + return std::nullopt; } // Returns indices of ELF headers containing specific section. Each index is a @@ -1419,7 +1419,7 @@ SmallVector LinkerScript::getPhdrIndices(OutputSection *cmd) { SmallVector ret; for (StringRef s : cmd->phdrs) { - if (Optional idx = getPhdrIndex(phdrsCommands, s)) + if (std::optional idx = getPhdrIndex(phdrsCommands, s)) ret.push_back(*idx); else if (s != "NONE") error(cmd->location + ": program header '" + s + diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index f50b6c4cec29..4e566853de51 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -165,7 +165,7 @@ class SectionPattern { StringMatcher excludedFilePat; // Cache of the most recent input argument and result of excludesFile(). - mutable llvm::Optional> excludesFileCache; + mutable std::optional> excludesFileCache; public: SectionPattern(StringMatcher &&pat1, StringMatcher &&pat2) @@ -184,7 +184,7 @@ class InputSectionDescription : public SectionCommand { SingleStringMatcher filePat; // Cache of the most recent input argument and result of matchesFile(). - mutable llvm::Optional> matchesFileCache; + mutable std::optional> matchesFileCache; public: InputSectionDescription(StringRef filePattern, uint64_t withFlags = 0, @@ -251,7 +251,7 @@ struct PhdrsCommand { unsigned type = llvm::ELF::PT_NULL; bool hasFilehdr = false; bool hasPhdrs = false; - llvm::Optional flags; + std::optional flags; Expr lmaExpr = nullptr; }; diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index f7f5dc351482..c7931471a6ed 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -85,7 +85,7 @@ public: Expr subalignExpr; SmallVector commands; SmallVector phdrs; - llvm::Optional> filler; + std::optional> filler; ConstraintKind constraint = ConstraintKind::NoConstraint; std::string location; std::string memoryRegionName; diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 9212ae14a17f..bcb65c667ad5 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -64,19 +64,19 @@ using namespace llvm::support::endian; using namespace lld; using namespace lld::elf; -static Optional getLinkerScriptLocation(const Symbol &sym) { +static std::optional getLinkerScriptLocation(const Symbol &sym) { for (SectionCommand *cmd : script->sectionCommands) if (auto *assign = dyn_cast(cmd)) if (assign->sym == &sym) return assign->location; - return None; + return std::nullopt; } static std::string getDefinedLocation(const Symbol &sym) { const char msg[] = "\n>>> defined in "; if (sym.file) return msg + toString(sym.file); - if (Optional loc = getLinkerScriptLocation(sym)) + if (std::optional loc = getLinkerScriptLocation(sym)) return msg + *loc; return ""; } diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index a758fdcc52ec..29928d152748 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -330,7 +330,7 @@ void ScriptParser::addFile(StringRef s) { ctx.driver.addFile(s, /*withLOption=*/false); } else { // Finally, search in the list of library paths. - if (Optional path = findFromSearchPaths(s)) + if (std::optional path = findFromSearchPaths(s)) ctx.driver.addFile(saver().save(*path), /*withLOption=*/true); else setError("unable to find " + s); @@ -379,8 +379,8 @@ void ScriptParser::readInclude() { return; } - if (Optional path = searchScript(tok)) { - if (Optional mb = readFile(*path)) + if (std::optional path = searchScript(tok)) { + if (std::optional mb = readFile(*path)) tokenize(*mb); return; } @@ -1221,33 +1221,33 @@ Expr ScriptParser::readConstant() { // Parses Tok as an integer. It recognizes hexadecimal (prefixed with // "0x" or suffixed with "H") and decimal numbers. Decimal numbers may // have "K" (Ki) or "M" (Mi) suffixes. -static Optional parseInt(StringRef tok) { +static std::optional parseInt(StringRef tok) { // Hexadecimal uint64_t val; if (tok.startswith_insensitive("0x")) { if (!to_integer(tok.substr(2), val, 16)) - return None; + return std::nullopt; return val; } if (tok.endswith_insensitive("H")) { if (!to_integer(tok.drop_back(), val, 16)) - return None; + return std::nullopt; return val; } // Decimal if (tok.endswith_insensitive("K")) { if (!to_integer(tok.drop_back(), val, 10)) - return None; + return std::nullopt; return val * 1024; } if (tok.endswith_insensitive("M")) { if (!to_integer(tok.drop_back(), val, 10)) - return None; + return std::nullopt; return val * 1024 * 1024; } if (!to_integer(tok, val, 10)) - return None; + return std::nullopt; return val; } @@ -1269,11 +1269,11 @@ ByteCommand *ScriptParser::readByteCommand(StringRef tok) { return make(e, size, commandString); } -static llvm::Optional parseFlag(StringRef tok) { - if (llvm::Optional asInt = parseInt(tok)) +static std::optional parseFlag(StringRef tok) { + if (std::optional asInt = parseInt(tok)) return asInt; #define CASE_ENT(enum) #enum, ELF::enum - return StringSwitch>(tok) + return StringSwitch>(tok) .Case(CASE_ENT(SHF_WRITE)) .Case(CASE_ENT(SHF_ALLOC)) .Case(CASE_ENT(SHF_EXECINSTR)) @@ -1308,7 +1308,7 @@ std::pair ScriptParser::readInputSectionFlags() { while (!errorCount()) { StringRef tok = unquote(next()); bool without = tok.consume_front("!"); - if (llvm::Optional flag = parseFlag(tok)) { + if (std::optional flag = parseFlag(tok)) { if (without) withoutFlags |= *flag; else @@ -1521,7 +1521,7 @@ Expr ScriptParser::readPrimary() { return [=] { return script->getSymbolValue(tok, location); }; // Tok is a literal number. - if (Optional val = parseInt(tok)) + if (std::optional val = parseInt(tok)) return [=] { return *val; }; // Tok is a symbol name. @@ -1560,7 +1560,7 @@ SmallVector ScriptParser::readOutputSectionPhdrs() { // name of a program header type or a constant (e.g. "0x3"). unsigned ScriptParser::readPhdrType() { StringRef tok = next(); - if (Optional val = parseInt(tok)) + if (std::optional val = parseInt(tok)) return *val; unsigned ret = StringSwitch(tok) diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index 51a34c797497..5255e8bfad66 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -85,7 +85,7 @@ private: // This mapping is 1:N because two symbols with different versions // can have the same name. We use this map to handle "extern C++ {}" // directive in version scripts. - llvm::Optional>> demangledSyms; + std::optional>> demangledSyms; }; LLVM_LIBRARY_VISIBILITY extern SymbolTable symtab; diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 05f6ade29073..e80d05cbd51e 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1580,11 +1580,9 @@ RelocationBaseSection::RelocationBaseSection(StringRef name, uint32_t type, dynamicTag(dynamicTag), sizeDynamicTag(sizeDynamicTag), relocsVec(concurrency), combreloc(combreloc) {} -void RelocationBaseSection::addSymbolReloc(RelType dynType, - InputSectionBase &isec, - uint64_t offsetInSec, Symbol &sym, - int64_t addend, - Optional addendRelType) { +void RelocationBaseSection::addSymbolReloc( + RelType dynType, InputSectionBase &isec, uint64_t offsetInSec, Symbol &sym, + int64_t addend, std::optional addendRelType) { addReloc(DynamicReloc::AgainstSymbol, dynType, isec, offsetInSec, sym, addend, R_ADDEND, addendRelType ? *addendRelType : target->noneRel); } @@ -3432,11 +3430,11 @@ static bool isDuplicateArmExidxSec(InputSection *prev, InputSection *cur) { } // The .ARM.exidx table must be sorted in ascending order of the address of the -// functions the table describes. Optionally duplicate adjacent table entries -// can be removed. At the end of the function the executableSections must be -// sorted in ascending order of address, Sentinel is set to the InputSection -// with the highest address and any InputSections that have mergeable -// .ARM.exidx table entries are removed from it. +// functions the table describes. std::optionally duplicate adjacent table +// entries can be removed. At the end of the function the executableSections +// must be sorted in ascending order of address, Sentinel is set to the +// InputSection with the highest address and any InputSections that have +// mergeable .ARM.exidx table entries are removed from it. void ARMExidxSyntheticSection::finalizeContents() { // The executableSections and exidxSections that we use to derive the final // contents of this SyntheticSection are populated before @@ -3472,7 +3470,7 @@ void ARMExidxSyntheticSection::finalizeContents() { }; llvm::stable_sort(executableSections, compareByFilePosition); sentinel = executableSections.back(); - // Optionally merge adjacent duplicate entries. + // std::optionally merge adjacent duplicate entries. if (config->mergeArmExidx) { SmallVector selectedSections; selectedSections.reserve(executableSections.size()); @@ -3638,12 +3636,12 @@ uint64_t PPC64LongBranchTargetSection::getEntryVA(const Symbol *sym, return getVA() + entry_index.find({sym, addend})->second * 8; } -Optional PPC64LongBranchTargetSection::addEntry(const Symbol *sym, - int64_t addend) { +std::optional +PPC64LongBranchTargetSection::addEntry(const Symbol *sym, int64_t addend) { auto res = entry_index.try_emplace(std::make_pair(sym, addend), entries.size()); if (!res.second) - return None; + return std::nullopt; entries.emplace_back(sym, addend); return res.first->second; } diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index 58e5b1273eb5..0df9d6e241c4 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -500,7 +500,7 @@ public: /// Add a dynamic relocation against \p sym with an optional addend. void addSymbolReloc(RelType dynType, InputSectionBase &isec, uint64_t offsetInSec, Symbol &sym, int64_t addend = 0, - llvm::Optional addendRelType = llvm::None); + std::optional addendRelType = {}); /// Add a relative dynamic relocation that uses the target address of \p sym /// (i.e. InputSection::getRelocTargetVA()) + \p addend as the addend. /// This function should only be called for non-preemptible symbols or @@ -1163,7 +1163,7 @@ class PPC64LongBranchTargetSection final : public SyntheticSection { public: PPC64LongBranchTargetSection(); uint64_t getEntryVA(const Symbol *sym, int64_t addend); - llvm::Optional addEntry(const Symbol *sym, int64_t addend); + std::optional addEntry(const Symbol *sym, int64_t addend); size_t getSize() const override; void writeTo(uint8_t *buf) override; bool isNeeded() const override; diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index 9959e30f3e54..fb3d8ff71c88 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -148,7 +148,7 @@ public: // Stores the NOP instructions of different sizes for the target and is used // to pad sections that are relaxed. - llvm::Optional>> nopInstrs; + std::optional>> nopInstrs; // If a target needs to rewrite calls to __morestack to instead call // __morestack_non_split when a split-stack enabled caller calls a diff --git a/lld/ELF/Thunks.cpp b/lld/ELF/Thunks.cpp index 738eb24f2200..fc987dee481a 100644 --- a/lld/ELF/Thunks.cpp +++ b/lld/ELF/Thunks.cpp @@ -380,7 +380,7 @@ public: PPC64PILongBranchThunk(Symbol &dest, int64_t addend) : PPC64LongBranchThunk(dest, addend) { assert(!dest.isPreemptible); - if (Optional index = + if (std::optional index = in.ppc64LongBranchTarget->addEntry(&dest, addend)) { mainPart->relaDyn->addRelativeReloc( target->relativeRel, *in.ppc64LongBranchTarget, *index * UINT64_C(8),