aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/MachOObjectFile.cpp
diff options
context:
space:
mode:
authorserge-sans-paille <sguelton@mozilla.com>2023-01-04 08:28:45 +0100
committerserge-sans-paille <sguelton@mozilla.com>2023-01-05 14:11:08 +0100
commit38818b60c58c76ba89b990978cdfd2d7b6799260 (patch)
tree63c85a12b00f87ec07dd8ad566970361e88f6fa4 /llvm/lib/Object/MachOObjectFile.cpp
parent11be5cc00110eaff473cd41714120a11878326fc (diff)
downloadllvm-38818b60c58c76ba89b990978cdfd2d7b6799260.zip
llvm-38818b60c58c76ba89b990978cdfd2d7b6799260.tar.gz
llvm-38818b60c58c76ba89b990978cdfd2d7b6799260.tar.bz2
Move from llvm::makeArrayRef to ArrayRef deduction guides - llvm/ part
Use deduction guides instead of helper functions. The only non-automatic changes have been: 1. ArrayRef(some_uint8_pointer, 0) needs to be changed into ArrayRef(some_uint8_pointer, (size_t)0) to avoid an ambiguous call with ArrayRef((uint8_t*), (uint8_t*)) 2. CVSymbol sym(makeArrayRef(symStorage)); needed to be rewritten as CVSymbol sym{ArrayRef(symStorage)}; otherwise the compiler is confused and thinks we have a (bad) function prototype. There was a few similar situation across the codebase. 3. ADL doesn't seem to work the same for deduction-guides and functions, so at some point the llvm namespace must be explicitly stated. 4. The "reference mode" of makeArrayRef(ArrayRef<T> &) that acts as no-op is not supported (a constructor cannot achieve that). Per reviewers' comment, some useless makeArrayRef have been removed in the process. This is a follow-up to https://reviews.llvm.org/D140896 that introduced the deduction guides. Differential Revision: https://reviews.llvm.org/D140955
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index bd021c5..9c0b85c 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -4517,7 +4517,7 @@ MachOObjectFile::getSectionRawName(DataRefImpl Sec) const {
assert(Sec.d.a < Sections.size() && "Should have detected this earlier");
const section_base *Base =
reinterpret_cast<const section_base *>(Sections[Sec.d.a]);
- return makeArrayRef(Base->sectname);
+ return ArrayRef(Base->sectname);
}
ArrayRef<char>
@@ -4525,7 +4525,7 @@ MachOObjectFile::getSectionRawFinalSegmentName(DataRefImpl Sec) const {
assert(Sec.d.a < Sections.size() && "Should have detected this earlier");
const section_base *Base =
reinterpret_cast<const section_base *>(Sections[Sec.d.a]);
- return makeArrayRef(Base->segname);
+ return ArrayRef(Base->segname);
}
bool
@@ -4901,7 +4901,7 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoRebaseOpcodes() const {
MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get();
const uint8_t *Ptr =
reinterpret_cast<const uint8_t *>(getPtr(*this, DyldInfo.rebase_off));
- return makeArrayRef(Ptr, DyldInfo.rebase_size);
+ return ArrayRef(Ptr, DyldInfo.rebase_size);
}
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoBindOpcodes() const {
@@ -4915,7 +4915,7 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoBindOpcodes() const {
MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get();
const uint8_t *Ptr =
reinterpret_cast<const uint8_t *>(getPtr(*this, DyldInfo.bind_off));
- return makeArrayRef(Ptr, DyldInfo.bind_size);
+ return ArrayRef(Ptr, DyldInfo.bind_size);
}
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoWeakBindOpcodes() const {
@@ -4929,7 +4929,7 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoWeakBindOpcodes() const {
MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get();
const uint8_t *Ptr =
reinterpret_cast<const uint8_t *>(getPtr(*this, DyldInfo.weak_bind_off));
- return makeArrayRef(Ptr, DyldInfo.weak_bind_size);
+ return ArrayRef(Ptr, DyldInfo.weak_bind_size);
}
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoLazyBindOpcodes() const {
@@ -4943,7 +4943,7 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoLazyBindOpcodes() const {
MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get();
const uint8_t *Ptr =
reinterpret_cast<const uint8_t *>(getPtr(*this, DyldInfo.lazy_bind_off));
- return makeArrayRef(Ptr, DyldInfo.lazy_bind_size);
+ return ArrayRef(Ptr, DyldInfo.lazy_bind_size);
}
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoExportsTrie() const {
@@ -4957,7 +4957,7 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoExportsTrie() const {
MachO::dyld_info_command DyldInfo = DyldInfoOrErr.get();
const uint8_t *Ptr =
reinterpret_cast<const uint8_t *>(getPtr(*this, DyldInfo.export_off));
- return makeArrayRef(Ptr, DyldInfo.export_size);
+ return ArrayRef(Ptr, DyldInfo.export_size);
}
Expected<std::optional<MachO::linkedit_data_command>>
@@ -5248,7 +5248,7 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldExportsTrie() const {
MachO::linkedit_data_command DyldExportsTrie = DyldExportsTrieOrError.get();
const uint8_t *Ptr =
reinterpret_cast<const uint8_t *>(getPtr(*this, DyldExportsTrie.dataoff));
- return makeArrayRef(Ptr, DyldExportsTrie.datasize);
+ return ArrayRef(Ptr, DyldExportsTrie.datasize);
}
SmallVector<uint64_t> MachOObjectFile::getFunctionStarts() const {
@@ -5271,7 +5271,7 @@ ArrayRef<uint8_t> MachOObjectFile::getUuid() const {
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<const uint8_t *>(Ptr), 16);
+ return ArrayRef(reinterpret_cast<const uint8_t *>(Ptr), 16);
}
StringRef MachOObjectFile::getStringTableData() const {