[lld] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
This commit is contained in:
parent
34b8daf4a8
commit
c68af42fa8
|
@ -288,7 +288,7 @@ static std::optional<ArrayRef<uint8_t>> getDebugH(ObjFile *file) {
|
|||
SectionChunk *sec =
|
||||
SectionChunk::findByName(file->getDebugChunks(), ".debug$H");
|
||||
if (!sec)
|
||||
return llvm::None;
|
||||
return std::nullopt;
|
||||
ArrayRef<uint8_t> contents = sec->getContents();
|
||||
if (!canUseDebugH(contents))
|
||||
return std::nullopt;
|
||||
|
|
|
@ -116,7 +116,7 @@ static lto::Config createConfig() {
|
|||
if (auto relocModel = getRelocModelFromCMModel())
|
||||
c.RelocModel = *relocModel;
|
||||
else if (config->relocatable)
|
||||
c.RelocModel = None;
|
||||
c.RelocModel = std::nullopt;
|
||||
else if (config->isPic)
|
||||
c.RelocModel = Reloc::PIC_;
|
||||
else
|
||||
|
|
|
@ -1287,7 +1287,7 @@ static std::optional<uint64_t> parseFlag(StringRef tok) {
|
|||
.Case(CASE_ENT(SHF_COMPRESSED))
|
||||
.Case(CASE_ENT(SHF_EXCLUDE))
|
||||
.Case(CASE_ENT(SHF_ARM_PURECODE))
|
||||
.Default(None);
|
||||
.Default(std::nullopt);
|
||||
#undef CASE_ENT
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ std::optional<MemoryBufferRef> macho::readFile(StringRef path) {
|
|||
ErrorOr<std::unique_ptr<MemoryBuffer>> mbOrErr = MemoryBuffer::getFile(path);
|
||||
if (std::error_code ec = mbOrErr.getError()) {
|
||||
error("cannot open " + path + ": " + ec.message());
|
||||
return None;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::unique_ptr<MemoryBuffer> &mb = *mbOrErr;
|
||||
|
@ -228,7 +228,7 @@ std::optional<MemoryBufferRef> macho::readFile(StringRef path) {
|
|||
if (reinterpret_cast<const char *>(arch + i + 1) >
|
||||
buf + mbref.getBufferSize()) {
|
||||
error(path + ": fat_arch struct extends beyond end of file");
|
||||
return None;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (read32be(&arch[i].cputype) != static_cast<uint32_t>(target->cpuType) ||
|
||||
|
@ -246,7 +246,7 @@ std::optional<MemoryBufferRef> macho::readFile(StringRef path) {
|
|||
}
|
||||
|
||||
error("unable to find matching architecture in " + path);
|
||||
return None;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
InputFile::InputFile(Kind kind, const InterfaceFile &interface)
|
||||
|
|
|
@ -168,7 +168,7 @@ std::vector<ObjFile *> BitcodeCompiler::compile() {
|
|||
// not use the cached MemoryBuffer directly to ensure dsymutil does not
|
||||
// race with the cache pruner.
|
||||
StringRef objBuf;
|
||||
std::optional<StringRef> cachePath = llvm::None;
|
||||
std::optional<StringRef> cachePath = std::nullopt;
|
||||
if (files[i]) {
|
||||
objBuf = files[i]->getBuffer();
|
||||
cachePath = files[i]->getBufferIdentifier();
|
||||
|
|
|
@ -252,11 +252,11 @@ DenseMap<const InputSection *, size_t> CallGraphSort::run() {
|
|||
std::optional<size_t>
|
||||
macho::PriorityBuilder::getSymbolPriority(const Defined *sym) {
|
||||
if (sym->isAbsolute())
|
||||
return None;
|
||||
return std::nullopt;
|
||||
|
||||
auto it = priorities.find(sym->getName());
|
||||
if (it == priorities.end())
|
||||
return None;
|
||||
return std::nullopt;
|
||||
const SymbolPriorityEntry &entry = it->second;
|
||||
const InputFile *f = sym->isec->getFile();
|
||||
if (!f)
|
||||
|
|
|
@ -116,7 +116,7 @@ static Optional<std::string> findFile(StringRef path1, const Twine &path2) {
|
|||
sys::path::append(s, path1, path2);
|
||||
if (sys::fs::exists(s))
|
||||
return std::string(s);
|
||||
return None;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// This is for -lfoo. We'll look for libfoo.dll.a or libfoo.a from search paths.
|
||||
|
|
|
@ -164,7 +164,7 @@ static Optional<std::string> findFile(StringRef path1, const Twine &path2) {
|
|||
path::append(s, path1, path2);
|
||||
if (fs::exists(s))
|
||||
return std::string(s);
|
||||
return None;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
opt::InputArgList WasmOptTable::parse(ArrayRef<const char *> argv) {
|
||||
|
@ -283,7 +283,7 @@ static Optional<std::string> findFromSearchPaths(StringRef path) {
|
|||
for (StringRef dir : config->searchPaths)
|
||||
if (Optional<std::string> s = findFile(dir, path))
|
||||
return s;
|
||||
return None;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// This is for -l<basename>. We'll look for lib<basename>.a from
|
||||
|
@ -298,7 +298,7 @@ static Optional<std::string> searchLibraryBaseName(StringRef name) {
|
|||
if (Optional<std::string> s = findFile(dir, "lib" + name + ".a"))
|
||||
return s;
|
||||
}
|
||||
return None;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// This is for -l<namespec>.
|
||||
|
@ -659,9 +659,9 @@ static void demoteLazySymbols() {
|
|||
if (s->signature) {
|
||||
LLVM_DEBUG(llvm::dbgs()
|
||||
<< "demoting lazy func: " << s->getName() << "\n");
|
||||
replaceSymbol<UndefinedFunction>(s, s->getName(), None, None,
|
||||
WASM_SYMBOL_BINDING_WEAK, s->getFile(),
|
||||
s->signature);
|
||||
replaceSymbol<UndefinedFunction>(s, s->getName(), std::nullopt,
|
||||
std::nullopt, WASM_SYMBOL_BINDING_WEAK,
|
||||
s->getFile(), s->signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ static void demoteLazySymbols() {
|
|||
static UndefinedGlobal *
|
||||
createUndefinedGlobal(StringRef name, llvm::wasm::WasmGlobalType *type) {
|
||||
auto *sym = cast<UndefinedGlobal>(symtab->addUndefinedGlobal(
|
||||
name, None, None, WASM_SYMBOL_UNDEFINED, nullptr, type));
|
||||
name, std::nullopt, std::nullopt, WASM_SYMBOL_UNDEFINED, nullptr, type));
|
||||
config->allowUndefinedSymbols.insert(sym->getName());
|
||||
sym->isUsedInRegularObj = true;
|
||||
return sym;
|
||||
|
@ -844,8 +844,9 @@ struct WrappedSymbol {
|
|||
};
|
||||
|
||||
static Symbol *addUndefined(StringRef name) {
|
||||
return symtab->addUndefinedFunction(name, None, None, WASM_SYMBOL_UNDEFINED,
|
||||
nullptr, nullptr, false);
|
||||
return symtab->addUndefinedFunction(name, std::nullopt, std::nullopt,
|
||||
WASM_SYMBOL_UNDEFINED, nullptr, nullptr,
|
||||
false);
|
||||
}
|
||||
|
||||
// Handles -wrap option.
|
||||
|
|
|
@ -61,7 +61,7 @@ Optional<MemoryBufferRef> readFile(StringRef path) {
|
|||
auto mbOrErr = MemoryBuffer::getFile(path);
|
||||
if (auto ec = mbOrErr.getError()) {
|
||||
error("cannot open " + path + ": " + ec.message());
|
||||
return None;
|
||||
return std::nullopt;
|
||||
}
|
||||
std::unique_ptr<MemoryBuffer> &mb = *mbOrErr;
|
||||
MemoryBufferRef mbref = mb->getMemBufferRef();
|
||||
|
@ -739,8 +739,8 @@ static Symbol *createBitcodeSymbol(const std::vector<bool> &keptComdats,
|
|||
if (objSym.isUndefined() || excludedByComdat) {
|
||||
flags |= WASM_SYMBOL_UNDEFINED;
|
||||
if (objSym.isExecutable())
|
||||
return symtab->addUndefinedFunction(name, None, None, flags, &f, nullptr,
|
||||
true);
|
||||
return symtab->addUndefinedFunction(name, std::nullopt, std::nullopt,
|
||||
flags, &f, nullptr, true);
|
||||
return symtab->addUndefinedData(name, flags, &f);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ static std::unique_ptr<lto::LTO> createLTO() {
|
|||
c.DebugPassManager = config->ltoDebugPassManager;
|
||||
|
||||
if (config->relocatable)
|
||||
c.RelocModel = None;
|
||||
c.RelocModel = std::nullopt;
|
||||
else if (config->isPic)
|
||||
c.RelocModel = Reloc::PIC_;
|
||||
else
|
||||
|
@ -76,8 +76,9 @@ BitcodeCompiler::~BitcodeCompiler() = default;
|
|||
|
||||
static void undefine(Symbol *s) {
|
||||
if (auto f = dyn_cast<DefinedFunction>(s))
|
||||
replaceSymbol<UndefinedFunction>(f, f->getName(), None, None, 0,
|
||||
f->getFile(), f->signature);
|
||||
replaceSymbol<UndefinedFunction>(f, f->getName(), std::nullopt,
|
||||
std::nullopt, 0, f->getFile(),
|
||||
f->signature);
|
||||
else if (isa<DefinedData>(s))
|
||||
replaceSymbol<UndefinedData>(s, s->getName(), 0, s->getFile());
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue