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


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@275749 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-07-18 01:58:37 +00:00
parent c79e8b692d
commit c71c304663
3 changed files with 82 additions and 24 deletions

View File

@@ -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
}