forked from OSchip/llvm-project
Rename and rework `_LIBCPP_TRIVIAL_PAIR_COPY_CTOR`. Move FreeBSD configuration in-tree.
This patch does the following: * It renames `_LIBCPP_TRIVIAL_PAIR_COPY_CTOR` to `_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR`. * It automatically enables this option on FreeBSD in ABI V1, since that's the current ABI FreeBSD ships. * It cleans up the handling of this option in `std::pair`. I would like the sign off from the FreeBSD maintainers. They will no longer need to keep their `__config` changes downstream. I'm still hoping to come up with a better way to maintain the ABI without needing these constructors. Reviewed in https://reviews.llvm.org/D21329 llvm-svn: 275749
This commit is contained in:
parent
1447da3383
commit
35b6413d1b
|
@ -44,6 +44,17 @@
|
|||
#define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
|
||||
#define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
|
||||
#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
|
||||
#elif _LIBCPP_ABI_VERSION == 1
|
||||
// Feature macros for disabling pre ABI v1 features. All of these options
|
||||
// are deprecated.
|
||||
#if defined(__FreeBSD__)
|
||||
#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
|
||||
#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \
|
||||
use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
|
||||
|
@ -746,10 +757,6 @@ template <unsigned> struct __static_assert_check {};
|
|||
#define _LIBCPP_WCTYPE_IS_MASK
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
|
||||
# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_STD_VER
|
||||
# if __cplusplus <= 201103L
|
||||
# define _LIBCPP_STD_VER 11
|
||||
|
|
|
@ -285,9 +285,6 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
|
|||
_T1 first;
|
||||
_T2 second;
|
||||
|
||||
// pair(const pair&) = default;
|
||||
// pair(pair&&) = default;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
|
||||
template <bool _Dummy = true, class = typename enable_if<
|
||||
__dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
|
||||
|
@ -310,10 +307,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
|
|||
)
|
||||
: first(__p.first), second(__p.second) {}
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair(const pair& __p) = default;
|
||||
#elif !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) || !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR
|
||||
#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair(const pair& __p)
|
||||
_NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
|
||||
|
@ -322,6 +316,21 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
|
|||
second(__p.second)
|
||||
{
|
||||
}
|
||||
|
||||
# ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<first_type>::value &&
|
||||
is_nothrow_move_constructible<second_type>::value)
|
||||
: first(_VSTD::forward<first_type>(__p.first)),
|
||||
second(_VSTD::forward<second_type>(__p.second))
|
||||
{
|
||||
}
|
||||
# endif
|
||||
#elif !defined(_LIBCPP_CXX03_LANG)
|
||||
pair(pair const&) = default;
|
||||
pair(pair&&) = default;
|
||||
#else
|
||||
// Use the implicitly declared copy constructor in C++03
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
|
@ -353,19 +362,6 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
|
|||
: first(_VSTD::forward<_U1>(__p.first)),
|
||||
second(_VSTD::forward<_U2>(__p.second)) {}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair(pair&& __p) = default;
|
||||
#else
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<first_type>::value &&
|
||||
is_nothrow_move_constructible<second_type>::value)
|
||||
: first(_VSTD::forward<first_type>(__p.first)),
|
||||
second(_VSTD::forward<second_type>(__p.second))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair&
|
||||
operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <utility>
|
||||
|
||||
// template <class T1, class T2> struct pair
|
||||
|
||||
// Doesn't pass due to use of is_trivially_* trait.
|
||||
// XFAIL: gcc-4.9
|
||||
|
||||
// Test that we properly provide the old non-trivial copy operations
|
||||
// when the ABI macro is defined.
|
||||
|
||||
#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
struct Dummy {
|
||||
Dummy(Dummy const&) = delete;
|
||||
Dummy(Dummy &&) = default;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<int, short> P;
|
||||
{
|
||||
static_assert(std::is_copy_constructible<P>::value, "");
|
||||
static_assert(!std::is_trivially_copy_constructible<P>::value, "");
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
static_assert(std::is_move_constructible<P>::value, "");
|
||||
static_assert(!std::is_trivially_move_constructible<P>::value, "");
|
||||
}
|
||||
{
|
||||
using P1 = std::pair<Dummy, int>;
|
||||
// This line fails because the non-trivial constructors do not provide
|
||||
// SFINAE.
|
||||
// static_assert(!std::is_copy_constructible<P1>::value, "");
|
||||
static_assert(!std::is_trivially_copy_constructible<P1>::value, "");
|
||||
static_assert(std::is_move_constructible<P1>::value, "");
|
||||
static_assert(!std::is_trivially_move_constructible<P1>::value, "");
|
||||
}
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue