[all-commits] [llvm/llvm-project] 8ab77a: [Support] Use llvm::byteswap in SwapByteOrder.h (NFC)

kazutakahirata via All-commits all-commits at lists.llvm.org
Sun Jan 22 19:14:47 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8ab77a78ba059c0f5f357d7b1062b25b5ab0cb61
      https://github.com/llvm/llvm-project/commit/8ab77a78ba059c0f5f357d7b1062b25b5ab0cb61
  Author: Kazu Hirata <kazu at google.com>
  Date:   2023-01-22 (Sun, 22 Jan 2023)

  Changed paths:
    M llvm/include/llvm/Support/SwapByteOrder.h

  Log Message:
  -----------
  [Support] Use llvm::byteswap in SwapByteOrder.h (NFC)

This patch defines ByteSwap_{32,64} and getSwappedBytes with
llvm::byteswap.

It's tempting to define something like:

  template <typename T,
            typename = std::enable_if_t<std::is_integral_v<T>>>
  inline T getSwappedBytes(T C) { return llvm::byteswap(C); }

But this doesn't work.  The host compiler would issue:

  error: call to 'getSwappedBytes' is ambiguous

while compiling lldb/source/Utility/UUID.cpp.




More information about the All-commits mailing list