summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-12-14 19:41:28 +0000
committerZachary Turner <zturner@google.com>2017-12-14 19:41:28 +0000
commit1fb1af18d27d5cab6db7a1ab5c9b7ba4f7668cd5 (patch)
tree6356c5af5b005332651d299bb5d6e929c8287fdb /include
parent44388667e99de222d3943ef56d099aa470d30925 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320737 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/DebugInfo/CodeView/TypeHashing.h7
-rw-r--r--include/llvm/Support/type_traits.h4
2 files changed, 3 insertions, 8 deletions
diff --git a/include/llvm/DebugInfo/CodeView/TypeHashing.h b/include/llvm/DebugInfo/CodeView/TypeHashing.h
index 74133753370..6b675e27036 100644
--- a/include/llvm/DebugInfo/CodeView/TypeHashing.h
+++ b/include/llvm/DebugInfo/CodeView/TypeHashing.h
@@ -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> {
diff --git a/include/llvm/Support/type_traits.h b/include/llvm/Support/type_traits.h
index cc087835880..4f1295f1b48 100644
--- a/include/llvm/Support/type_traits.h
+++ b/include/llvm/Support/type_traits.h
@@ -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;