From aadaaface2ec96ee30d92bf46faa41dd9e68b64d Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 2 Dec 2022 21:11:44 -0800 Subject: [llvm] 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 --- llvm/lib/Object/MachOObjectFile.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'llvm/lib/Object/MachOObjectFile.cpp') diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index f3ca2e9..e6ff7cb 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -4889,12 +4889,12 @@ MachOObjectFile::getLinkOptHintsLoadCommand() const { ArrayRef MachOObjectFile::getDyldInfoRebaseOpcodes() const { if (!DyldInfoLoadCmd) - return None; + return std::nullopt; auto DyldInfoOrErr = getStructOrErr(*this, DyldInfoLoadCmd); if (!DyldInfoOrErr) - return None; + return std::nullopt; MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get(); const uint8_t *Ptr = reinterpret_cast(getPtr(*this, DyldInfo.rebase_off)); @@ -4903,12 +4903,12 @@ ArrayRef MachOObjectFile::getDyldInfoRebaseOpcodes() const { ArrayRef MachOObjectFile::getDyldInfoBindOpcodes() const { if (!DyldInfoLoadCmd) - return None; + return std::nullopt; auto DyldInfoOrErr = getStructOrErr(*this, DyldInfoLoadCmd); if (!DyldInfoOrErr) - return None; + return std::nullopt; MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get(); const uint8_t *Ptr = reinterpret_cast(getPtr(*this, DyldInfo.bind_off)); @@ -4917,12 +4917,12 @@ ArrayRef MachOObjectFile::getDyldInfoBindOpcodes() const { ArrayRef MachOObjectFile::getDyldInfoWeakBindOpcodes() const { if (!DyldInfoLoadCmd) - return None; + return std::nullopt; auto DyldInfoOrErr = getStructOrErr(*this, DyldInfoLoadCmd); if (!DyldInfoOrErr) - return None; + return std::nullopt; MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get(); const uint8_t *Ptr = reinterpret_cast(getPtr(*this, DyldInfo.weak_bind_off)); @@ -4931,12 +4931,12 @@ ArrayRef MachOObjectFile::getDyldInfoWeakBindOpcodes() const { ArrayRef MachOObjectFile::getDyldInfoLazyBindOpcodes() const { if (!DyldInfoLoadCmd) - return None; + return std::nullopt; auto DyldInfoOrErr = getStructOrErr(*this, DyldInfoLoadCmd); if (!DyldInfoOrErr) - return None; + return std::nullopt; MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get(); const uint8_t *Ptr = reinterpret_cast(getPtr(*this, DyldInfo.lazy_bind_off)); @@ -4945,12 +4945,12 @@ ArrayRef MachOObjectFile::getDyldInfoLazyBindOpcodes() const { ArrayRef MachOObjectFile::getDyldInfoExportsTrie() const { if (!DyldInfoLoadCmd) - return None; + return std::nullopt; auto DyldInfoOrErr = getStructOrErr(*this, DyldInfoLoadCmd); if (!DyldInfoOrErr) - return None; + return std::nullopt; MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get(); const uint8_t *Ptr = reinterpret_cast(getPtr(*this, DyldInfo.export_off)); @@ -4961,7 +4961,7 @@ Expected> MachOObjectFile::getChainedFixupsLoadCommand() const { // Load the dyld chained fixups load command. if (!DyldChainedFixupsLoadCmd) - return llvm::None; + return std::nullopt; auto DyldChainedFixupsOrErr = getStructOrErr( *this, DyldChainedFixupsLoadCmd); if (!DyldChainedFixupsOrErr) @@ -4972,7 +4972,7 @@ MachOObjectFile::getChainedFixupsLoadCommand() const { // If the load command is present but the data offset has been zeroed out, // as is the case for dylib stubs, return None (no error). if (!DyldChainedFixups.dataoff) - return llvm::None; + return std::nullopt; return DyldChainedFixups; } @@ -4982,7 +4982,7 @@ MachOObjectFile::getChainedFixupsHeader() const { if (!CFOrErr) return CFOrErr.takeError(); if (!CFOrErr->has_value()) - return llvm::None; + return std::nullopt; const MachO::linkedit_data_command &DyldChainedFixups = **CFOrErr; @@ -5236,12 +5236,12 @@ MachOObjectFile::getDyldChainedFixupTargets() const { ArrayRef MachOObjectFile::getDyldExportsTrie() const { if (!DyldExportsTrieLoadCmd) - return None; + return std::nullopt; auto DyldExportsTrieOrError = getStructOrErr( *this, DyldExportsTrieLoadCmd); if (!DyldExportsTrieOrError) - return None; + return std::nullopt; MachO::linkedit_data_command DyldExportsTrie = DyldExportsTrieOrError.get(); const uint8_t *Ptr = reinterpret_cast(getPtr(*this, DyldExportsTrie.dataoff)); @@ -5265,7 +5265,7 @@ SmallVector MachOObjectFile::getFunctionStarts() const { ArrayRef MachOObjectFile::getUuid() const { if (!UuidLoadCmd) - return None; + return std::nullopt; // Returning a pointer is fine as uuid doesn't need endian swapping. const char *Ptr = UuidLoadCmd + offsetof(MachO::uuid_command, uuid); return makeArrayRef(reinterpret_cast(Ptr), 16); -- cgit v1.1