[llvm] r320737 - Fix isPodLike for MSVC and use it in TypeHashing.

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 11:59:33 PST 2017


The static_assert doesn't hold in Chromium's Linux build:

https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.clang%2FToTLinuxThinLTO%2F933%2F%2B%2Frecipes%2Fsteps%2Fgclient_runhooks%2F0%2Fstdout

Looks like some LLVM bots are sad too, e.g.
http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/12386/steps/build%20stage%201/logs/stdio

On Thu, Dec 14, 2017 at 11:41 AM, Zachary Turner via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: zturner
> Date: Thu Dec 14 11:41:28 2017
> New Revision: 320737
>
> URL: http://llvm.org/viewvc/llvm-project?rev=320737&view=rev
> Log:
> Fix isPodLike for MSVC and use it in TypeHashing.
>
> This should be a better check than using is_trivially_copyable
> behind an #ifdef _MSC_VER.
>
> Modified:
>     llvm/trunk/include/llvm/DebugInfo/CodeView/TypeHashing.h
>     llvm/trunk/include/llvm/Support/type_traits.h
>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeHashing.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeHashing.h?rev=320737&r1=320736&r2=320737&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeHashing.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeHashing.h Thu Dec 14 11:41:28 2017
> @@ -132,15 +132,10 @@ struct GloballyHashedType {
>      return Hashes;
>    }
>  };
> -#if defined(_MSC_VER)
> -// is_trivially_copyable is not available in older versions of libc++, but it is
> -// available in all supported versions of MSVC, so at least this gives us some
> -// coverage.
> -static_assert(std::is_trivially_copyable<GloballyHashedType>::value,
> +static_assert(isPodLike<GloballyHashedType>::value,
>                "GloballyHashedType must be trivially copyable so that we can "
>                "reinterpret_cast arrays of hash data to arrays of "
>                "GloballyHashedType");
> -#endif
>  } // namespace codeview
>
>  template <> struct DenseMapInfo<codeview::LocallyHashedType> {
>
> Modified: llvm/trunk/include/llvm/Support/type_traits.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/type_traits.h?rev=320737&r1=320736&r2=320737&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/type_traits.h (original)
> +++ llvm/trunk/include/llvm/Support/type_traits.h Thu Dec 14 11:41:28 2017
> @@ -30,9 +30,9 @@ namespace llvm {
>  template <typename T>
>  struct isPodLike {
>    // std::is_trivially_copyable is available in libc++ with clang, libstdc++
> -  // that comes with GCC 5.
> +  // that comes with GCC 5, and MSVC.
>  #if (__has_feature(is_trivially_copyable) && defined(_LIBCPP_VERSION)) ||      \
> -    (defined(__GNUC__) && __GNUC__ >= 5)
> +    (defined(__GNUC__) && __GNUC__ >= 5) || defined(_MSC_VER)
>    // If the compiler supports the is_trivially_copyable trait use it, as it
>    // matches the definition of isPodLike closely.
>    static const bool value = std::is_trivially_copyable<T>::value;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list