mirror of
https://github.com/intel/llvm.git
synced 2026-02-06 06:31:50 +08:00
[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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user