diff options
author | Eric Fiselier <eric@efcs.ca> | 2019-01-16 01:51:12 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2019-01-16 01:51:12 +0000 |
commit | c2b831cab86e884b89c1363e4dd3ec7b96484f0c (patch) | |
tree | c3cf0575502e78c0b65f32e8c240db3f05287d7e /libcxx/include/type_traits | |
parent | bf56fcdacdbc098ed0b5dec92248db8ca8679f26 (diff) |
Move internal usages of `alignof`/`__alignof` to use `_LIBCPP_ALIGNOF`.
Summary:
Starting in Clang 8.0 and GCC 8.0, `alignof` and `__alignof` return different values in same cases. Specifically `alignof` and `_Alignof` return the minimum alignment for a type, where as `__alignof` returns the preferred alignment. libc++ currently uses `__alignof` but means to use `alignof`. See llvm.org/PR39713
This patch introduces the macro `_LIBCPP_ALIGNOF` so we can control which spelling gets used.
This patch does not introduce any ABI guard to provide the old behavior with newer compilers. However, if we decide that is needed, this patch makes it trivial to implement.
I think we should commit this change immediately, and decide what we want to do about the ABI afterwards.
Reviewers: ldionne, EricWF
Reviewed By: ldionne, EricWF
Subscribers: jyknight, christof, libcxx-commits
Differential Revision: https://reviews.llvm.org/D54814
Diffstat (limited to 'libcxx/include/type_traits')
-rw-r--r-- | libcxx/include/type_traits | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index ab010716f00..8b30511a4ec 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -1652,7 +1652,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v // alignment_of template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of - : public integral_constant<size_t, __alignof__(_Tp)> {}; + : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {}; #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) template <class _Tp> @@ -1682,7 +1682,7 @@ struct __nat template <class _Tp> struct __align_type { - static const size_t value = alignment_of<_Tp>::value; + static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp); typedef _Tp type; }; @@ -1815,8 +1815,8 @@ struct __static_max<_I0, _I1, _In...> template <size_t _Len, class _Type0, class ..._Types> struct aligned_union { - static const size_t alignment_value = __static_max<__alignof__(_Type0), - __alignof__(_Types)...>::value; + static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), + _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value; static const size_t __len = __static_max<_Len, sizeof(_Type0), sizeof(_Types)...>::value; typedef typename aligned_storage<__len, alignment_value>::type type; |