diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-04-28 16:22:31 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-04-28 16:22:31 +0000 |
commit | 18883037a98240a7831c0d7c01dbe502fc5cfbd9 (patch) | |
tree | 4c781fd023c2492b0a263d7b22d4a8c50eb66c9c /include/llvm/Support | |
parent | 1dd346ad05d2adbbd787c3bef8c335567f969b82 (diff) | |
download | external_llvm-18883037a98240a7831c0d7c01dbe502fc5cfbd9.zip external_llvm-18883037a98240a7831c0d7c01dbe502fc5cfbd9.tar.gz external_llvm-18883037a98240a7831c0d7c01dbe502fc5cfbd9.tar.bz2 |
If the __is_trivially_copyable type trait is available use it as the baseline for isPodLike.
This way we can enable the POD-like class optimization for a lot more classes,
saving ~120k of code in clang/i386/Release+Asserts when selfhosting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155761 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support')
-rw-r--r-- | include/llvm/Support/type_traits.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/llvm/Support/type_traits.h b/include/llvm/Support/type_traits.h index a3a551f..7b97547 100644 --- a/include/llvm/Support/type_traits.h +++ b/include/llvm/Support/type_traits.h @@ -21,6 +21,11 @@ #include <cstddef> #include <utility> +#ifndef __has_feature +#define LLVM_DEFINED_HAS_FEATURE +#define __has_feature(x) 0 +#endif + // This is actually the conforming implementation which works with abstract // classes. However, enough compilers have trouble with it that most will use // the one in boost/type_traits/object_traits.hpp. This implementation actually @@ -58,9 +63,15 @@ struct is_class /// type can be copied around with memcpy instead of running ctors etc. template <typename T> struct isPodLike { +#if __has_feature(is_trivially_copyable) + // If the compiler supports the is_trivially_copyable trait use it, as it + // matches the definition of isPodLike closely. + static const bool value = __is_trivially_copyable(T); +#else // If we don't know anything else, we can (at least) assume that all non-class // types are PODs. static const bool value = !is_class<T>::value; +#endif }; // std::pair's are pod-like if their elements are. @@ -202,4 +213,8 @@ struct conditional<false, T, F> { typedef F type; }; } +#ifdef LLVM_DEFINED_HAS_FEATURE +#undef __has_feature +#endif + #endif |