[ELF] Change most llvm::Optional to std::optional

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
This commit is contained in:
Fangrui Song
2022-11-26 19:19:15 -08:00
parent 69acfaeef0
commit 4191fda69c
18 changed files with 83 additions and 83 deletions

View File

@@ -187,7 +187,7 @@ InputFile::InputFile(Kind k, MemoryBufferRef m)
++nextGroupId;
}
Optional<MemoryBufferRef> elf::readFile(StringRef path) {
std::optional<MemoryBufferRef> elf::readFile(StringRef path) {
llvm::TimeTraceScope timeScope("Load input files", path);
// The --chroot option changes our virtual root directory.
@@ -202,7 +202,7 @@ Optional<MemoryBufferRef> 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<std::string> s = searchLibraryBaseName(specifier))
if (std::optional<std::string> s = searchLibraryBaseName(specifier))
ctx.driver.addFile(saver().save(*s), /*withLOption=*/true);
else if (Optional<std::string> s = findFromSearchPaths(specifier))
else if (std::optional<std::string> s = findFromSearchPaths(specifier))
ctx.driver.addFile(saver().save(*s), /*withLOption=*/true);
else if (fs::exists(specifier))
ctx.driver.addFile(specifier, /*withLOption=*/false);