Fix LLP64 detection in SwapByteOrder.h
authorReid Kleckner <rnk@google.com>
Wed, 26 Feb 2020 18:41:59 +0000 (10:41 -0800)
committerReid Kleckner <rnk@google.com>
Wed, 26 Feb 2020 18:59:45 +0000 (10:59 -0800)
commit30dae38349cbe293bee0705b313dc747e53afd49
tree0b47b207fe1cc03470ee8c3b674621be0c2c85b7
parent7691790dfd1011d08f5468f63952d7690755aad4
Fix LLP64 detection in SwapByteOrder.h

MSVC does not define __LONG_MAX__, so we were just getting lucky in this
conditional:
  #if __LONG_MAX__ == __INT_MAX__

Undefined identifiers evaluate to zero in preprocessor conditionals, so
this became true, which happens to work for MSVC platforms.

Instead, use this pattern and let the compiler constant fold:
  return sizeof(long) == sizeof(int) ? SwapByteOrder_32((uint32_t)C)
                                     : SwapByteOrder_64((uint64_t)C);
llvm/include/llvm/Support/SwapByteOrder.h