[Support] Use llvm::byteswap in SwapByteOrder.h (NFC)
authorKazu Hirata <kazu@google.com>
Mon, 23 Jan 2023 03:14:33 +0000 (19:14 -0800)
committerKazu Hirata <kazu@google.com>
Mon, 23 Jan 2023 03:14:33 +0000 (19:14 -0800)
commit8ab77a78ba059c0f5f357d7b1062b25b5ab0cb61
tree02c8419e4a81daa58a8daf721862ded387ff02c1
parent7db6a45e1650126fc5e1f1e3cdcc1cb7a0db4a00
[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.
llvm/include/llvm/Support/SwapByteOrder.h