diff options
author | Jay Foad <jay.foad@amd.com> | 2024-09-19 16:16:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-19 16:16:38 +0100 |
commit | e03f427196ec67a8a5cfbdd658f9eabe9bce83ce (patch) | |
tree | 5c39989033e45fe09b7d589f923e0b6c9d20f917 /llvm/lib/Object/MachOObjectFile.cpp | |
parent | 14120227a34365e829d05c1413033d235d7d272c (diff) | |
download | llvm-e03f427196ec67a8a5cfbdd658f9eabe9bce83ce.zip llvm-e03f427196ec67a8a5cfbdd658f9eabe9bce83ce.tar.gz llvm-e03f427196ec67a8a5cfbdd658f9eabe9bce83ce.tar.bz2 |
[LLVM] Use {} instead of std::nullopt to initialize empty ArrayRef (#109133)
It is almost always simpler to use {} instead of std::nullopt to
initialize an empty ArrayRef. This patch changes all occurrences I could
find in LLVM itself. In future the ArrayRef(std::nullopt_t) constructor
could be deprecated or removed.
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 8fa3f67..46ed3b2 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -4906,12 +4906,12 @@ MachOObjectFile::getLinkOptHintsLoadCommand() const { ArrayRef<uint8_t> MachOObjectFile::getDyldInfoRebaseOpcodes() const { if (!DyldInfoLoadCmd) - return std::nullopt; + return {}; auto DyldInfoOrErr = getStructOrErr<MachO::dyld_info_command>(*this, DyldInfoLoadCmd); if (!DyldInfoOrErr) - return std::nullopt; + return {}; MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get(); const uint8_t *Ptr = reinterpret_cast<const uint8_t *>(getPtr(*this, DyldInfo.rebase_off)); @@ -4920,12 +4920,12 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoRebaseOpcodes() const { ArrayRef<uint8_t> MachOObjectFile::getDyldInfoBindOpcodes() const { if (!DyldInfoLoadCmd) - return std::nullopt; + return {}; auto DyldInfoOrErr = getStructOrErr<MachO::dyld_info_command>(*this, DyldInfoLoadCmd); if (!DyldInfoOrErr) - return std::nullopt; + return {}; MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get(); const uint8_t *Ptr = reinterpret_cast<const uint8_t *>(getPtr(*this, DyldInfo.bind_off)); @@ -4934,12 +4934,12 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoBindOpcodes() const { ArrayRef<uint8_t> MachOObjectFile::getDyldInfoWeakBindOpcodes() const { if (!DyldInfoLoadCmd) - return std::nullopt; + return {}; auto DyldInfoOrErr = getStructOrErr<MachO::dyld_info_command>(*this, DyldInfoLoadCmd); if (!DyldInfoOrErr) - return std::nullopt; + return {}; MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get(); const uint8_t *Ptr = reinterpret_cast<const uint8_t *>(getPtr(*this, DyldInfo.weak_bind_off)); @@ -4948,12 +4948,12 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoWeakBindOpcodes() const { ArrayRef<uint8_t> MachOObjectFile::getDyldInfoLazyBindOpcodes() const { if (!DyldInfoLoadCmd) - return std::nullopt; + return {}; auto DyldInfoOrErr = getStructOrErr<MachO::dyld_info_command>(*this, DyldInfoLoadCmd); if (!DyldInfoOrErr) - return std::nullopt; + return {}; MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get(); const uint8_t *Ptr = reinterpret_cast<const uint8_t *>(getPtr(*this, DyldInfo.lazy_bind_off)); @@ -4962,12 +4962,12 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoLazyBindOpcodes() const { ArrayRef<uint8_t> MachOObjectFile::getDyldInfoExportsTrie() const { if (!DyldInfoLoadCmd) - return std::nullopt; + return {}; auto DyldInfoOrErr = getStructOrErr<MachO::dyld_info_command>(*this, DyldInfoLoadCmd); if (!DyldInfoOrErr) - return std::nullopt; + return {}; MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get(); const uint8_t *Ptr = reinterpret_cast<const uint8_t *>(getPtr(*this, DyldInfo.export_off)); @@ -5248,12 +5248,12 @@ MachOObjectFile::getDyldChainedFixupTargets() const { ArrayRef<uint8_t> MachOObjectFile::getDyldExportsTrie() const { if (!DyldExportsTrieLoadCmd) - return std::nullopt; + return {}; auto DyldExportsTrieOrError = getStructOrErr<MachO::linkedit_data_command>( *this, DyldExportsTrieLoadCmd); if (!DyldExportsTrieOrError) - return std::nullopt; + return {}; MachO::linkedit_data_command DyldExportsTrie = DyldExportsTrieOrError.get(); const uint8_t *Ptr = reinterpret_cast<const uint8_t *>(getPtr(*this, DyldExportsTrie.dataoff)); @@ -5277,7 +5277,7 @@ SmallVector<uint64_t> MachOObjectFile::getFunctionStarts() const { ArrayRef<uint8_t> MachOObjectFile::getUuid() const { if (!UuidLoadCmd) - return std::nullopt; + return {}; // Returning a pointer is fine as uuid doesn't need endian swapping. const char *Ptr = UuidLoadCmd + offsetof(MachO::uuid_command, uuid); return ArrayRef(reinterpret_cast<const uint8_t *>(Ptr), 16); |