Index: llvm/trunk/include/llvm/ADT/bit.h =================================================================== --- llvm/trunk/include/llvm/ADT/bit.h +++ llvm/trunk/include/llvm/ADT/bit.h @@ -14,15 +14,29 @@ #ifndef LLVM_ADT_BIT_H #define LLVM_ADT_BIT_H -#include "llvm/Support/type_traits.h" +#include "llvm/Support/Compiler.h" #include +#include namespace llvm { -template ::type, - typename = typename std::enable_if::value>::type, - typename = typename std::enable_if::value>::type> +template ::type +#if (__has_feature(is_trivially_copyable) && defined(_LIBCPP_VERSION)) || \ + (defined(__GNUC__) && __GNUC__ >= 5) + , typename = typename std::enable_if::value>::type + , typename = typename std::enable_if::value>::type +#elif __has_feature(is_trivially_copyable) + , typename = typename std::enable_if<__is_trivially_copyable::value>::type + , typename = typename std::enable_if<__is_trivially_copyable::value>::type +#else + // This case is GCC 4.x. clang with libc++ or libstdc++ never get here. Unlike + // llvm/Support/type_traits.h's isPodLike we don't want to provide a + // good-enough answer here: developers in that configuration will hit + // compilation failures on the bots instead of locally. That's acceptable + // because it's very few developers, and only until we move past C++11. +#endif +> inline To bit_cast(const From &from) noexcept { alignas(To) unsigned char storage[sizeof(To)]; std::memcpy(&storage, &from, sizeof(To));