Vendor import of libc++ trunk r301441:

https://llvm.org/svn/llvm-project/libcxx/trunk@301441
This commit is contained in:
Dimitry Andric 2017-04-26 19:24:31 +00:00
parent 1c3313bd02
commit 2fa809d9ea
33 changed files with 262 additions and 54 deletions

View File

@ -120,21 +120,19 @@ if (LIBCXX_CXX_ABI STREQUAL "default")
${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include
NO_DEFAULT_PATH
)
if ((NOT LIBCXX_STANDALONE_BUILD OR HAVE_LIBCXXABI) AND
IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
if (LIBCXX_TARGETING_MSVC)
# FIXME: Figure out how to configure the ABI library on Windows.
set(LIBCXX_CXX_ABI_LIBNAME "vcruntime")
elseif ((NOT LIBCXX_STANDALONE_BUILD OR HAVE_LIBCXXABI) AND
IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
set(LIBCXX_CXX_ABI_INTREE 1)
elseif (APPLE)
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
set(LIBCXX_CXX_ABI_SYSTEM 1)
else()
if (LIBCXX_TARGETING_MSVC)
# FIXME: Figure out how to configure the ABI library on Windows.
set(LIBCXX_CXX_ABI_LIBNAME "vcruntime")
elseif(APPLE)
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
set(LIBCXX_CXX_ABI_SYSTEM 1)
else()
set(LIBCXX_CXX_ABI_LIBNAME "default")
endif()
set(LIBCXX_CXX_ABI_LIBNAME "default")
endif()
else()
set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")

View File

@ -861,16 +861,29 @@ kill_dependency(_Tp __y) _NOEXCEPT
return __y;
}
#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
#if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE)
# define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE
# define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE
# define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE
# define ATOMIC_CHAR32_T_LOCK_FREE __CLANG_ATOMIC_CHAR32_T_LOCK_FREE
# define ATOMIC_WCHAR_T_LOCK_FREE __CLANG_ATOMIC_WCHAR_T_LOCK_FREE
# define ATOMIC_SHORT_LOCK_FREE __CLANG_ATOMIC_SHORT_LOCK_FREE
# define ATOMIC_INT_LOCK_FREE __CLANG_ATOMIC_INT_LOCK_FREE
# define ATOMIC_LONG_LOCK_FREE __CLANG_ATOMIC_LONG_LOCK_FREE
# define ATOMIC_LLONG_LOCK_FREE __CLANG_ATOMIC_LLONG_LOCK_FREE
# define ATOMIC_POINTER_LOCK_FREE __CLANG_ATOMIC_POINTER_LOCK_FREE
#else
# define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
# define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
# define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
# define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
# define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
# define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
# define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
# define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
# define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
# define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
#endif
// general atomic<T>

View File

@ -307,6 +307,7 @@ long double truncl(long double x);
extern "C++" {
#include <type_traits>
#include <limits>
// signbit
@ -324,22 +325,50 @@ __libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
signbit(_A1 __lcpp_x) _NOEXCEPT
{
return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<
std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
signbit(_A1 __lcpp_x) _NOEXCEPT
{ return __lcpp_x < 0; }
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<
std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
signbit(_A1) _NOEXCEPT
{ return false; }
#elif defined(_LIBCPP_MSVCRT)
template <typename _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
signbit(_A1 __lcpp_x) _NOEXCEPT
{
return ::signbit(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<
std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
signbit(_A1 __lcpp_x) _NOEXCEPT
{ return __lcpp_x < 0; }
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<
std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
signbit(_A1) _NOEXCEPT
{ return false; }
#endif // signbit
// fpclassify
@ -358,22 +387,34 @@ __libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_arithmetic<_A1>::value, int>::type
typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
fpclassify(_A1 __lcpp_x) _NOEXCEPT
{
return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, int>::type
fpclassify(_A1 __lcpp_x) _NOEXCEPT
{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
#elif defined(_LIBCPP_MSVCRT)
template <typename _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_arithmetic<_A1>::value, int>::type
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
fpclassify(_A1 __lcpp_x) _NOEXCEPT
{
return ::fpclassify(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, int>::type
fpclassify(_A1 __lcpp_x) _NOEXCEPT
{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
#endif // fpclassify
// isfinite
@ -392,12 +433,22 @@ __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
typename std::enable_if<
std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
bool>::type
isfinite(_A1 __lcpp_x) _NOEXCEPT
{
return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<
std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
bool>::type
isfinite(_A1) _NOEXCEPT
{ return true; }
#endif // isfinite
// isinf
@ -416,12 +467,22 @@ __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
typename std::enable_if<
std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
bool>::type
isinf(_A1 __lcpp_x) _NOEXCEPT
{
return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<
std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
bool>::type
isinf(_A1) _NOEXCEPT
{ return false; }
#endif // isinf
// isnan
@ -440,12 +501,18 @@ __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
isnan(_A1 __lcpp_x) _NOEXCEPT
{
return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, bool>::type
isnan(_A1) _NOEXCEPT
{ return false; }
#endif // isnan
// isnormal
@ -464,12 +531,18 @@ __libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
isnormal(_A1 __lcpp_x) _NOEXCEPT
{
return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, bool>::type
isnormal(_A1 __lcpp_x) _NOEXCEPT
{ return __lcpp_x != 0; }
#endif // isnormal
// isgreater

View File

@ -685,7 +685,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void
call_once(once_flag& __flag, const _Callable& __func)
{
if (__flag.__state_ != ~0ul)
if (__libcpp_acquire_load(&__flag.__state_) != ~0ul)
{
__call_once_param<const _Callable> __p(__func);
__call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// This test fails because diagnose_if doesn't emit all of the diagnostics
// when -fdelayed-template-parsing is enabled, like it is on Windows.
// XFAIL: LIBCXX-WINDOWS-FIXME
// REQUIRES: verify-support, diagnose-if-support
// UNSUPPORTED: libcpp-has-no-threads

View File

@ -10,6 +10,10 @@
// test libc++'s implementation of align_val_t, and the relevent new/delete
// overloads in all dialects when -faligned-allocation is present.
// Libc++ defers to the underlying MSVC library to provide the new/delete
// definitions, which does not yet provide aligned allocation
// XFAIL: LIBCXX-WINDOWS-FIXME
// REQUIRES: -faligned-allocation
// RUN: %build -faligned-allocation
@ -74,4 +78,4 @@ int main() {
assert(typeid(std::align_val_t).name() == std::string("St11align_val_t"));
}
#endif
}
}

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// 'do_bytes' throws a std::range_error unexpectedly
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: c++98, c++03
// <locale>

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// This test fails on Windows because the underlying libc headers on Windows
// are not modular
// XFAIL: LIBCXX-WINDOWS-FIXME
// REQUIRES: modules-support
// Test that <cinttypes> re-exports <cstdint>

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// This test fails on Windows because the underlying libc headers on Windows
// are not modular
// XFAIL: LIBCXX-WINDOWS-FIXME
// REQUIRES: modules-support
// UNSUPPORTED: c++98, c++03

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// This test fails on Windows because the underlying libc headers on Windows
// are not modular
// XFAIL: LIBCXX-WINDOWS-FIXME
// REQUIRES: modules-support
// Test that <cstdint> re-exports <stdint.h>

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// This test fails on Windows because the underlying libc headers on Windows
// are not modular
// XFAIL: LIBCXX-WINDOWS-FIXME
// REQUIRES: modules-support
// Test that intypes.h re-exports stdint.h

View File

@ -8,6 +8,9 @@
//===----------------------------------------------------------------------===//
//
// This test depends on std::exception_ptr which has not yet been implemented.
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-no-exceptions
// UNSUPPORTED: libcpp-has-no-threads
// UNSUPPORTED: c++98, c++03

View File

@ -6,7 +6,9 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This test depends on std::exception_ptr which has not yet been implemented.
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-no-exceptions
// UNSUPPORTED: libcpp-has-no-threads

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// On Windows Clang bugs out when both __declspec and __attribute__ are present,
// the processing goes awry preventing the definition of the types.
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-has-no-threads
// REQUIRES: thread-safety

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// On Windows Clang bugs out when both __declspec and __attribute__ are present,
// the processing goes awry preventing the definition of the types.
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-has-no-threads
// REQUIRES: thread-safety

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// On Windows Clang bugs out when both __declspec and __attribute__ are present,
// the processing goes awry preventing the definition of the types.
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-has-no-threads
// REQUIRES: thread-safety

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// On Windows Clang bugs out when both __declspec and __attribute__ are present,
// the processing goes awry preventing the definition of the types.
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-has-no-threads
// REQUIRES: thread-safety

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// exception_ptr has not been implemented on Windows
// XFAIL: LIBCXX-WINDOWS-FIXME
// <exception>
// class nested_exception;

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// exception_ptr has not been implemented on Windows
// XFAIL: LIBCXX-WINDOWS-FIXME
// <exception>
// class nested_exception;

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// exception_ptr has not been implemented on Windows
// XFAIL: LIBCXX-WINDOWS-FIXME
// <exception>
// class nested_exception;

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// exception_ptr has not been implemented on Windows
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-no-exceptions
// <exception>
@ -43,7 +46,7 @@ class C
{
public:
virtual ~C() {}
C * operator&() const { assert(false); } // should not be called
C * operator&() const { assert(false); return nullptr; } // should not be called
};
class D : private std::nested_exception {};

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// exception_ptr has not been implemented on Windows
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-no-exceptions
// <exception>

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// exception_ptr has not been implemented on Windows
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-no-exceptions
// <exception>

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// exception_ptr has not been implemented on Windows
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-no-exceptions
// <exception>

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// exception_ptr has not been implemented on Windows
// XFAIL: LIBCXX-WINDOWS-FIXME
// <exception>
// typedef unspecified exception_ptr;

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// exception_ptr has not been implemented on Windows
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-no-exceptions
// <exception>

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// exception_ptr has not been implemented on Windows
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-no-exceptions
// <exception>

View File

@ -10,6 +10,7 @@
// <cmath>
#include <cmath>
#include <limits>
#include <type_traits>
#include <cassert>
@ -551,6 +552,13 @@ void test_signbit()
static_assert((std::is_same<decltype(std::signbit((long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(signbit(Ambiguous())), Ambiguous>::value), "");
assert(std::signbit(-1.0) == true);
assert(std::signbit(0u) == false);
assert(std::signbit(std::numeric_limits<unsigned>::max()) == false);
assert(std::signbit(0) == false);
assert(std::signbit(1) == false);
assert(std::signbit(-1) == true);
assert(std::signbit(std::numeric_limits<int>::max()) == false);
assert(std::signbit(std::numeric_limits<int>::min()) == true);
}
void test_fpclassify()
@ -564,6 +572,11 @@ void test_fpclassify()
static_assert((std::is_same<decltype(std::fpclassify((long double)0)), int>::value), "");
static_assert((std::is_same<decltype(fpclassify(Ambiguous())), Ambiguous>::value), "");
assert(std::fpclassify(-1.0) == FP_NORMAL);
assert(std::fpclassify(0) == FP_ZERO);
assert(std::fpclassify(1) == FP_NORMAL);
assert(std::fpclassify(-1) == FP_NORMAL);
assert(std::fpclassify(std::numeric_limits<int>::max()) == FP_NORMAL);
assert(std::fpclassify(std::numeric_limits<int>::min()) == FP_NORMAL);
}
void test_isfinite()
@ -577,6 +590,11 @@ void test_isfinite()
static_assert((std::is_same<decltype(std::isfinite((long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isfinite(Ambiguous())), Ambiguous>::value), "");
assert(std::isfinite(-1.0) == true);
assert(std::isfinite(0) == true);
assert(std::isfinite(1) == true);
assert(std::isfinite(-1) == true);
assert(std::isfinite(std::numeric_limits<int>::max()) == true);
assert(std::isfinite(std::numeric_limits<int>::min()) == true);
}
void test_isnormal()
@ -590,6 +608,11 @@ void test_isnormal()
static_assert((std::is_same<decltype(std::isnormal((long double)0)), bool>::value), "");
static_assert((std::is_same<decltype(isnormal(Ambiguous())), Ambiguous>::value), "");
assert(std::isnormal(-1.0) == true);
assert(std::isnormal(0) == false);
assert(std::isnormal(1) == true);
assert(std::isnormal(-1) == true);
assert(std::isnormal(std::numeric_limits<int>::max()) == true);
assert(std::isnormal(std::numeric_limits<int>::min()) == true);
}
void test_isgreater()
@ -651,6 +674,11 @@ void test_isinf()
static_assert((std::is_same<decltype(std::isinf(0)), bool>::value), "");
static_assert((std::is_same<decltype(std::isinf((long double)0)), bool>::value), "");
assert(std::isinf(-1.0) == false);
assert(std::isinf(0) == false);
assert(std::isinf(1) == false);
assert(std::isinf(-1) == false);
assert(std::isinf(std::numeric_limits<int>::max()) == false);
assert(std::isinf(std::numeric_limits<int>::min()) == false);
}
void test_isless()
@ -731,6 +759,11 @@ void test_isnan()
static_assert((std::is_same<decltype(std::isnan(0)), bool>::value), "");
static_assert((std::is_same<decltype(std::isnan((long double)0)), bool>::value), "");
assert(std::isnan(-1.0) == false);
assert(std::isnan(0) == false);
assert(std::isnan(1) == false);
assert(std::isnan(-1) == false);
assert(std::isnan(std::numeric_limits<int>::max()) == false);
assert(std::isnan(std::numeric_limits<int>::min()) == false);
}
void test_isunordered()

View File

@ -63,7 +63,6 @@ void
test(SV sv, unsigned pos, unsigned n, const typename S::allocator_type& a)
{
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
if (pos <= sv.size())
{
S s2(sv, pos, n, a);

View File

@ -44,7 +44,7 @@ void test_emplace_type() {
auto &v = a.emplace<Type>();
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(&v == std::any_cast<Type>(&a));
assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assert(Type::count == 1);
@ -60,7 +60,7 @@ void test_emplace_type() {
auto &v = a.emplace<Type>(101);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(&v == std::any_cast<Type>(&a));
assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assert(Type::count == 1);
@ -76,7 +76,7 @@ void test_emplace_type() {
auto &v = a.emplace<Type>(-1, 42, -1);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(&v == std::any_cast<Type>(&a));
assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assert(Type::count == 1);
@ -97,7 +97,7 @@ void test_emplace_type_tracked() {
assert(Tracked::count == 1);
auto &v = a.emplace<Type>();
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(&v == std::any_cast<Type>(&a));
assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assertArgsMatch<Type>(a);
@ -107,7 +107,7 @@ void test_emplace_type_tracked() {
assert(Tracked::count == 1);
auto &v = a.emplace<Type>(-1, 42, -1);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(&v == std::any_cast<Type>(&a));
assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assertArgsMatch<Type, int, int, int>(a);
@ -118,7 +118,7 @@ void test_emplace_type_tracked() {
assert(Tracked::count == 1);
auto &v = a.emplace<Type>({-1, 42, -1});
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(&v == std::any_cast<Type>(&a));
assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assertArgsMatch<Type, std::initializer_list<int>>(a);
@ -129,7 +129,7 @@ void test_emplace_type_tracked() {
assert(Tracked::count == 1);
auto &v = a.emplace<Type>({-1, 42, -1}, x);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(&v == std::any_cast<Type>(&a));
assert(&v == std::any_cast<Type>(&a));
assert(Tracked::count == 0);
assertArgsMatch<Type, std::initializer_list<int>, int&>(a);
@ -159,7 +159,8 @@ void test_emplace_throws()
std::any a(small{42});
assert(small::count == 1);
try {
a.emplace<Type>(101);
auto &v = a.emplace<Type>(101);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(false);
} catch (int const&) {
}
@ -169,7 +170,8 @@ void test_emplace_throws()
std::any a(small{42});
assert(small::count == 1);
try {
a.emplace<Type>({1, 2, 3}, 101);
auto &v = a.emplace<Type>({1, 2, 3}, 101);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(false);
} catch (int const&) {
}
@ -180,7 +182,8 @@ void test_emplace_throws()
std::any a(large{42});
assert(large::count == 1);
try {
a.emplace<Type>(101);
auto &v = a.emplace<Type>(101);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(false);
} catch (int const&) {
}
@ -190,7 +193,8 @@ void test_emplace_throws()
std::any a(large{42});
assert(large::count == 1);
try {
a.emplace<Type>({1, 2, 3}, 101);
auto &v = a.emplace<Type>({1, 2, 3}, 101);
static_assert( std::is_same_v<Type&, decltype(v)>, "" );
assert(false);
} catch (int const&) {
}

View File

@ -254,7 +254,9 @@ int main()
{
assert(static_cast<bool>(opt) == true);
assert(Y::dtor_called == false);
opt.emplace(1);
auto &v = opt.emplace(1);
static_assert( std::is_same_v<Y&, decltype(v)>, "" );
assert(false);
}
catch (int i)
{

View File

@ -11,7 +11,7 @@
// <optional>
// template <class U, class... Args>
// void optional<T>::emplace(initializer_list<U> il, Args&&... args);
// T& optional<T>::emplace(initializer_list<U> il, Args&&... args);
#include <optional>
#include <type_traits>
@ -76,21 +76,27 @@ int main()
X x;
optional<X> opt(x);
assert(X::dtor_called == false);
opt.emplace({1, 2});
auto &v = opt.emplace({1, 2});
static_assert( std::is_same_v<X&, decltype(v)>, "" );
assert(X::dtor_called == true);
assert(*opt == X({1, 2}));
assert(&v == &*opt);
}
{
optional<std::vector<int>> opt;
opt.emplace({1, 2, 3}, std::allocator<int>());
auto &v = opt.emplace({1, 2, 3}, std::allocator<int>());
static_assert( std::is_same_v<std::vector<int>&, decltype(v)>, "" );
assert(static_cast<bool>(opt) == true);
assert(*opt == std::vector<int>({1, 2, 3}));
assert(&v == &*opt);
}
{
optional<Y> opt;
opt.emplace({1, 2});
auto &v = opt.emplace({1, 2});
static_assert( std::is_same_v<Y&, decltype(v)>, "" );
assert(static_cast<bool>(opt) == true);
assert(*opt == Y({1, 2}));
assert(&v == &*opt);
}
#ifndef TEST_HAS_NO_EXCEPTIONS
{
@ -100,7 +106,9 @@ int main()
{
assert(static_cast<bool>(opt) == true);
assert(Z::dtor_called == false);
opt.emplace({1, 2});
auto &v = opt.emplace({1, 2});
static_assert( std::is_same_v<Z&, decltype(v)>, "" );
assert(false);
}
catch (int i)
{

View File

@ -311,10 +311,10 @@ class Configuration(object):
# NOTE: We do not test for the -verify flag directly because
# -verify will always exit with non-zero on an empty file.
self.use_clang_verify = self.cxx.isVerifySupported()
if self.use_clang_verify:
self.config.available_features.add('verify-support')
self.lit_config.note(
"inferred use_clang_verify as: %r" % self.use_clang_verify)
if self.use_clang_verify:
self.config.available_features.add('verify-support')
def configure_use_thread_safety(self):
'''If set, run clang with -verify on failing tests.'''
@ -418,7 +418,7 @@ class Configuration(object):
# initial Windows failures until they can be properly diagnosed
# and fixed. This allows easier detection of new test failures
# and regressions. Note: New failures should not be suppressed
# using this feature.
# using this feature. (Also see llvm.org/PR32730)
self.config.available_features.add('LIBCXX-WINDOWS-FIXME')
# Attempt to detect the glibc version by querying for __GLIBC__