Skip to content

[Support] Remove redundant forwarding functions read/write (NFC) #66051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions llvm/include/llvm/Support/Endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ inline value_type byte_swap(value_type value) {
}

/// Read a value of a particular endianness from memory.
template <typename value_type, std::size_t alignment>
template <typename value_type, std::size_t alignment = unaligned>
inline value_type read(const void *memory, endianness endian) {
value_type ret;

Expand Down Expand Up @@ -93,7 +93,7 @@ inline value_type readNext(const CharT *&memory) {
}

/// Write a value to memory with a particular endianness.
template <typename value_type, std::size_t alignment>
template <typename value_type, std::size_t alignment = unaligned>
inline void write(void *memory, value_type value, endianness endian) {
value = byte_swap<value_type>(value, endian);
memcpy(LLVM_ASSUME_ALIGNED(
Expand Down Expand Up @@ -349,10 +349,6 @@ using aligned_big_t = detail::packed_endian_specific_integral<T, big, aligned>;

namespace endian {

template <typename T> inline T read(const void *P, endianness E) {
return read<T, unaligned>(P, E);
}

template <typename T, endianness E> inline T read(const void *P) {
return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
}
Expand Down Expand Up @@ -384,10 +380,6 @@ inline uint16_t read16be(const void *P) { return read16<big>(P); }
inline uint32_t read32be(const void *P) { return read32<big>(P); }
inline uint64_t read64be(const void *P) { return read64<big>(P); }

template <typename T> inline void write(void *P, T V, endianness E) {
write<T, unaligned>(P, V, E);
}

template <typename T, endianness E> inline void write(void *P, T V) {
*(detail::packed_endian_specific_integral<T, E, unaligned> *)P = V;
}
Expand Down