[libcxx-commits] [libcxx] ed65318 - Revert "[libc++] Make rotate a constexpr."
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 14 14:53:53 PDT 2020
Author: zoecarver
Date: 2020-09-14T14:53:17-07:00
New Revision: ed653184ac6385945e32535feb7af2876ec52d40
URL: https://github.com/llvm/llvm-project/commit/ed653184ac6385945e32535feb7af2876ec52d40
DIFF: https://github.com/llvm/llvm-project/commit/ed653184ac6385945e32535feb7af2876ec52d40.diff
LOG: Revert "[libc++] Make rotate a constexpr."
This reverts commit 1ec02efee9b1d01cde89f31ca9ba6a46b7662ac5.
Added:
Modified:
libcxx/include/algorithm
libcxx/include/iterator
libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp
libcxx/www/cxx2a_status.html
Removed:
################################################################################
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 5d09b6c3c015..8c8bc748606d 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -1631,7 +1631,7 @@ search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const
// copy
template <class _Iter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_Iter
__unwrap_iter(_Iter __i)
{
@@ -1639,7 +1639,7 @@ __unwrap_iter(_Iter __i)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1653,7 +1653,7 @@ __unwrap_iter(move_iterator<_Tp*> __i)
#if _LIBCPP_DEBUG_LEVEL < 2
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1665,7 +1665,7 @@ __unwrap_iter(__wrap_iter<_Tp*> __i)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1679,7 +1679,7 @@ __unwrap_iter(__wrap_iter<const _Tp*> __i)
#else
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1859,28 +1859,18 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
// move
-// __move_constexpr exists so that __move doesn't call itself when delegating to the constexpr
-// version of __move.
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
-__move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
for (; __first != __last; ++__first, (void) ++__result)
*__result = _VSTD::move(*__first);
return __result;
}
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_OutputIterator
-__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- return __move_constexpr(__first, __last, __result);
-}
-
template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_same<typename remove_const<_Tp>::type, _Up>::value &&
@@ -1889,8 +1879,6 @@ typename enable_if
>::type
__move(_Tp* __first, _Tp* __last, _Up* __result)
{
- if (__libcpp_is_constant_evaluated())
- return __move_constexpr(__first, __last, __result);
const size_t __n = static_cast<size_t>(__last - __first);
if (__n > 0)
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
@@ -1898,7 +1886,7 @@ __move(_Tp* __first, _Tp* __last, _Up* __result)
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
@@ -1907,28 +1895,18 @@ move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
// move_backward
-// __move_backward_constexpr exists so that __move_backward doesn't call itself when delegating to
-// the constexpr version of __move_backward.
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
-__move_backward_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
while (__first != __last)
*--__result = _VSTD::move(*--__last);
return __result;
}
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_OutputIterator
-__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- return __move_backward_constexpr(__first, __last, __result);
-}
-
template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_same<typename remove_const<_Tp>::type, _Up>::value &&
@@ -1937,8 +1915,6 @@ typename enable_if
>::type
__move_backward(_Tp* __first, _Tp* __last, _Up* __result)
{
- if (__libcpp_is_constant_evaluated())
- return __move_backward_constexpr(__first, __last, __result);
const size_t __n = static_cast<size_t>(__last - __first);
if (__n > 0)
{
@@ -1949,7 +1925,7 @@ __move_backward(_Tp* __first, _Tp* __last, _Up* __result)
}
template <class _BidirectionalIterator1, class _BidirectionalIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY
_BidirectionalIterator2
move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
_BidirectionalIterator2 __result)
@@ -2357,7 +2333,7 @@ reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _Out
// rotate
template <class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+_ForwardIterator
__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
{
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
@@ -2368,7 +2344,7 @@ __rotate_left(_ForwardIterator __first, _ForwardIterator __last)
}
template <class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
+_BidirectionalIterator
__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
@@ -2380,7 +2356,7 @@ __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
}
template <class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator
+_ForwardIterator
__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
{
_ForwardIterator __i = __middle;
@@ -2416,7 +2392,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
template<typename _Integral>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX14 _Integral
+_Integral
__algo_gcd(_Integral __x, _Integral __y)
{
do
@@ -2429,7 +2405,7 @@ __algo_gcd(_Integral __x, _Integral __y)
}
template<typename _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator
+_RandomAccessIterator
__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
{
typedef typename iterator_traits<_RandomAccessIterator>::
diff erence_type
diff erence_type;
@@ -2465,7 +2441,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
template <class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+_ForwardIterator
__rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
_VSTD::forward_iterator_tag)
{
@@ -2480,7 +2456,7 @@ __rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator _
template <class _BidirectionalIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
+_BidirectionalIterator
__rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
_VSTD::bidirectional_iterator_tag)
{
@@ -2497,7 +2473,7 @@ __rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _Bidir
template <class _RandomAccessIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
+_RandomAccessIterator
__rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
_VSTD::random_access_iterator_tag)
{
@@ -2515,7 +2491,7 @@ __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomA
template <class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_ForwardIterator
rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
{
if (__first == __middle)
diff --git a/libcxx/include/iterator b/libcxx/include/iterator
index 45516db24e7c..36571a50b8bc 100644
--- a/libcxx/include/iterator
+++ b/libcxx/include/iterator
@@ -1393,13 +1393,13 @@ operator+(typename __wrap_iter<_Iter>::
diff erence_type, __wrap_iter<_Iter>) _NOE
template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy(_Ip, _Ip, _Op);
template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy_backward(_B1, _B1, _B2);
-template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 move(_Ip, _Ip, _Op);
-template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 move_backward(_B1, _B1, _B2);
+template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY move(_Ip, _Ip, _Op);
+template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY move_backward(_B1, _B1, _B2);
#if _LIBCPP_DEBUG_LEVEL < 2
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1410,7 +1410,7 @@ __unwrap_iter(__wrap_iter<_Tp*>);
#else
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1604,12 +1604,12 @@ private:
template <class _Ip, class _Op> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _Op copy(_Ip, _Ip, _Op);
template <class _B1, class _B2> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _B2 copy_backward(_B1, _B1, _B2);
- template <class _Ip, class _Op> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _Op move(_Ip, _Ip, _Op);
- template <class _B1, class _B2> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _B2 move_backward(_B1, _B1, _B2);
+ template <class _Ip, class _Op> friend _Op move(_Ip, _Ip, _Op);
+ template <class _B1, class _B2> friend _B2 move_backward(_B1, _B1, _B2);
#if _LIBCPP_DEBUG_LEVEL < 2
template <class _Tp>
- _LIBCPP_CONSTEXPR friend
+ _LIBCPP_CONSTEXPR_IF_NODEBUG friend
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
@@ -1618,7 +1618,7 @@ private:
__unwrap_iter(__wrap_iter<_Tp*>);
#else
template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
index 721a568750f1..cdb126d4942c 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
@@ -13,10 +13,6 @@
// OutIter
// move(InIter first, InIter last, OutIter result);
-// UNSUPPORTED: clang-6, clang-7
-// UNSUPPORTED: apple-clang-9, apple-clang-10, apple-clang-11
-// UNSUPPORTED: gcc-5, gcc-6, gcc-7, gcc-8
-
#include <algorithm>
#include <cassert>
#include <memory>
@@ -25,11 +21,11 @@
#include "test_iterators.h"
template <class InIter, class OutIter>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+void
test()
{
const unsigned N = 1000;
- int ia[N] = {};
+ int ia[N];
for (unsigned i = 0; i < N; ++i)
ia[i] = i;
int ib[N] = {0};
@@ -38,8 +34,6 @@ test()
assert(base(r) == ib+N);
for (unsigned i = 0; i < N; ++i)
assert(ia[i] == ib[i]);
-
- return true;
}
#if TEST_STD_VER >= 11
@@ -134,37 +128,5 @@ int main(int, char**)
test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
#endif // TEST_STD_VER >= 11
-#if TEST_STD_VER > 17
- static_assert(test<input_iterator<const int*>, input_iterator<int*> >());
- static_assert(test<input_iterator<const int*>, forward_iterator<int*> >());
- static_assert(test<input_iterator<const int*>, bidirectional_iterator<int*> >());
- static_assert(test<input_iterator<const int*>, random_access_iterator<int*> >());
- static_assert(test<input_iterator<const int*>, int*>());
-
- static_assert(test<forward_iterator<const int*>, input_iterator<int*> >());
- static_assert(test<forward_iterator<const int*>, forward_iterator<int*> >());
- static_assert(test<forward_iterator<const int*>, bidirectional_iterator<int*> >());
- static_assert(test<forward_iterator<const int*>, random_access_iterator<int*> >());
- static_assert(test<forward_iterator<const int*>, int*>());
-
- static_assert(test<bidirectional_iterator<const int*>, input_iterator<int*> >());
- static_assert(test<bidirectional_iterator<const int*>, forward_iterator<int*> >());
- static_assert(test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >());
- static_assert(test<bidirectional_iterator<const int*>, random_access_iterator<int*> >());
- static_assert(test<bidirectional_iterator<const int*>, int*>());
-
- static_assert(test<random_access_iterator<const int*>, input_iterator<int*> >());
- static_assert(test<random_access_iterator<const int*>, forward_iterator<int*> >());
- static_assert(test<random_access_iterator<const int*>, bidirectional_iterator<int*> >());
- static_assert(test<random_access_iterator<const int*>, random_access_iterator<int*> >());
- static_assert(test<random_access_iterator<const int*>, int*>());
-
- static_assert(test<const int*, input_iterator<int*> >());
- static_assert(test<const int*, forward_iterator<int*> >());
- static_assert(test<const int*, bidirectional_iterator<int*> >());
- static_assert(test<const int*, random_access_iterator<int*> >());
- static_assert(test<const int*, int*>());
-#endif // TEST_STD_VER > 17
-
return 0;
}
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
index 1a845cc1a88f..365c1a1158d7 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
@@ -21,11 +21,11 @@
#include "test_iterators.h"
template <class InIter, class OutIter>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+void
test()
{
const unsigned N = 1000;
- int ia[N] = {};
+ int ia[N];
for (unsigned i = 0; i < N; ++i)
ia[i] = i;
int ib[N] = {0};
@@ -34,8 +34,6 @@ test()
assert(base(r) == ib);
for (unsigned i = 0; i < N; ++i)
assert(ia[i] == ib[i]);
-
- return true;
}
#if TEST_STD_VER >= 11
@@ -84,19 +82,5 @@ int main(int, char**)
test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
#endif // TEST_STD_VER >= 11
-#if TEST_STD_VER > 17
- static_assert(test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >());
- static_assert(test<bidirectional_iterator<const int*>, random_access_iterator<int*> >());
- static_assert(test<bidirectional_iterator<const int*>, int*>());
-
- static_assert(test<random_access_iterator<const int*>, bidirectional_iterator<int*> >());
- static_assert(test<random_access_iterator<const int*>, random_access_iterator<int*> >());
- static_assert(test<random_access_iterator<const int*>, int*>());
-
- static_assert(test<const int*, bidirectional_iterator<int*> >());
- static_assert(test<const int*, random_access_iterator<int*> >());
- static_assert(test<const int*, int*>());
-#endif // TEST_STD_VER > 17
-
return 0;
}
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp
index 7c905bc83f0f..007faf685bfc 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp
@@ -20,7 +20,7 @@
#include "test_iterators.h"
template <class Iter>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+void
test()
{
int ia[] = {0};
@@ -209,8 +209,6 @@ test()
assert(ig[3] == 0);
assert(ig[4] == 1);
assert(ig[5] == 2);
-
- return true;
}
#if TEST_STD_VER >= 11
@@ -437,12 +435,5 @@ int main(int, char**)
#endif
-#if TEST_STD_VER > 17
- static_assert(test<forward_iterator<int*> >());
- static_assert(test<bidirectional_iterator<int*> >());
- static_assert(test<random_access_iterator<int*> >());
- static_assert(test<int*>());
-#endif // TEST_STD_VER > 17
-
return 0;
}
diff --git a/libcxx/www/cxx2a_status.html b/libcxx/www/cxx2a_status.html
index 88df02bcb117..f4fdba219bfc 100644
--- a/libcxx/www/cxx2a_status.html
+++ b/libcxx/www/cxx2a_status.html
@@ -261,8 +261,7 @@ <h3>Paper Status</h3>
<p>The missing bits in P0600 are in [mem.res.class], [mem.poly.allocator.class], and [container.node.overview]</p>
-<p>The missing bits in P0202 are in <tt>copy</tt> and <tt>copy_backwards</tt> (and the ones that call them: <tt>copy_n</tt>, <tt>set_union</tt>, <tt>set_
diff erence</tt>, and <tt>set_symmetric_
diff erence</tt>). This is because the first two algorithms have specializations that call <tt>memmove</tt> which is not constexpr. See <a href="https://bugs.llvm.org/show_bug.cgi?id=25165">Bug 25165</a></p>
-
+<p>The missing bits in P0202 are in <tt>copy</tt>, <tt>copy_backwards</tt>, <tt>move</tt>, and <tt>move_backwards</tt> (and the ones that call them: <tt>copy_n</tt>, <tt>rotate_copy</tt>, <tt>merge</tt>, <tt>set_union</tt>, <tt>set_
diff erence</tt>, and <tt>set_symmetric_
diff erence</tt>). This is because the first four algorithms have specializations that call <tt>memmove</tt> which is not constexpr. See <a href="https://bugs.llvm.org/show_bug.cgi?id=25165">Bug 25165</a></p>
<h3>Library Working group Issues Status</h3>
<!-- <I>Note: "NAD" means that the issue was deemed "Not a defect"</I> -->
More information about the libcxx-commits
mailing list