[llvm-branch-commits] [libcxx] 3fbd3ea - [libc++] Implement [P0769] "Add shift to algorithm" (shift_left, shift_right)

2021-01-25 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-01-25T12:57:04-05:00
New Revision: 3fbd3eaf28c1e6f2bb9519022611829dfe3b0464

URL: 
https://github.com/llvm/llvm-project/commit/3fbd3eaf28c1e6f2bb9519022611829dfe3b0464
DIFF: 
https://github.com/llvm/llvm-project/commit/3fbd3eaf28c1e6f2bb9519022611829dfe3b0464.diff

LOG: [libc++] Implement [P0769] "Add shift to algorithm" (shift_left, 
shift_right)

I believe this is a complete implementation of std::shift_left and 
std::shift_right from
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0769r2.pdf

Some test cases copied-with-modification from D60027.

Differential Revision: https://reviews.llvm.org/D93819

Added: 

libcxx/test/std/algorithms/alg.modifying.operations/alg.shift/shift_left.pass.cpp

libcxx/test/std/algorithms/alg.modifying.operations/alg.shift/shift_right.pass.cpp

Modified: 
libcxx/docs/Cxx2aStatusPaperStatus.csv
libcxx/docs/FeatureTestMacroTable.rst
libcxx/include/algorithm
libcxx/include/version

libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
libcxx/utils/generate_feature_test_macro_components.py

Removed: 




diff  --git a/libcxx/docs/Cxx2aStatusPaperStatus.csv 
b/libcxx/docs/Cxx2aStatusPaperStatus.csv
index 8991a03b2a5c..e30a289470d3 100644
--- a/libcxx/docs/Cxx2aStatusPaperStatus.csv
+++ b/libcxx/docs/Cxx2aStatusPaperStatus.csv
@@ -38,7 +38,7 @@
 "`P0722R3 `__","CWG","Efficient sized delete for 
variable sized classes","Rapperswil","|Complete|","9.0"
 "`P0758R1 `__","LWG","Implicit conversion traits 
and utility functions","Rapperswil","|Complete|",""
 "`P0759R1 `__","LWG","fpos 
Requirements","Rapperswil","|Complete|","11.0"
-"`P0769R2 `__","LWG","Add shift to 
","Rapperswil","",""
+"`P0769R2 `__","LWG","Add shift to 
","Rapperswil","|Complete|","12.0"
 "`P0788R3 `__","LWG","Standard Library 
Specification in a Concepts and Contracts World","Rapperswil","*Removed in 
Cologne*","n/a"
 "`P0879R0 `__","LWG","Constexpr for swap and swap 
related functions Also resolves LWG issue 2800.","Rapperswil","",""
 "`P0887R1 `__","LWG","The identity 
metafunction","Rapperswil","|Complete|","8.0"

diff  --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index b5db1e08d7bf..ed05488fa711 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -266,7 +266,7 @@ Status
 - -
 ``__cpp_lib_semaphore``   ``201907L``
 - -
-``__cpp_lib_shift``   *unimplemented*
+``__cpp_lib_shift``   ``201806L``
 - -
 ``__cpp_lib_smart_ptr_for_overwrite`` *unimplemented*
 - -

diff  --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index da55e5e9add0..77711d250188 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -301,6 +301,16 @@ template
 void shuffle(RandomAccessIterator first, RandomAccessIterator last,
  UniformRandomNumberGenerator&& g);
 
+template
+  constexpr ForwardIterator
+shift_left(ForwardIterator first, ForwardIterator last,
+   typename iterator_traits::
diff erence_type n); // C++20
+
+template
+  constexpr ForwardIterator
+shift_right(ForwardIterator first, ForwardIterator last,
+typename iterator_traits::
diff erence_type n); // C++20
+
 template 
 constexpr bool  // constexpr in C++20
 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
@@ -3259,6 +3269,111 @@ template
 }
 }
 
+#if _LIBCPP_STD_VER > 17
+
+// shift_left, shift_right
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY constexpr
+_ForwardIterator
+shift_left(_ForwardIterator __first, _ForwardIterator __last,
+   typename iterator_traits<_ForwardIterator>::
diff erence_type __n)
+{
+if (__n == 0) {
+return __last;
+}
+
+_ForwardIterator __m = __first;
+if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) {
+if (__n >= __last - __first) {
+return __first;
+}
+__m += __n;
+} else {
+for (; __n > 0; --__n) {
+if (__m == __last) {
+return __first;
+}
+++__m;
+}
+}
+return _VSTD::move(__m, __last, __first

[llvm-branch-commits] [libcxx] f851db3 - [libc++] [P0879] constexpr std::reverse, partition, *_permutation.

2021-01-25 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-01-25T13:09:30-05:00
New Revision: f851db3dae5cc24ce1897918bd69fa989aa31b59

URL: 
https://github.com/llvm/llvm-project/commit/f851db3dae5cc24ce1897918bd69fa989aa31b59
DIFF: 
https://github.com/llvm/llvm-project/commit/f851db3dae5cc24ce1897918bd69fa989aa31b59.diff

LOG: [libc++] [P0879] constexpr std::reverse, partition, *_permutation.

After this patch, the only parts of P0879 that remain missing will be
std::nth_element, std::sort, and the heap/partial_sort algorithms.

Differential Revision: https://reviews.llvm.org/D93443

Added: 


Modified: 
libcxx/include/algorithm

libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp

libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp

libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp

libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp

libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp

libcxx/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp

Removed: 




diff  --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 77711d250188b..f7fb2013a7573 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -267,7 +267,7 @@ template 
 unique_copy(InputIterator first, InputIterator last, OutputIterator 
result, BinaryPredicate pred);
 
 template 
-void
+constexpr void   // constexpr in C++20
 reverse(BidirectionalIterator first, BidirectionalIterator last);
 
 template 
@@ -316,7 +316,7 @@ template 
 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
 
 template 
-ForwardIterator
+constexpr ForwardIterator  // constexpr in C++20
 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
 
 template 
 InputIterator2 first2, InputIterator2 last2, 
Compare comp);
 
 template 
-bool
+constexpr bool // constexpr in C++20
 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
 
 template 
-bool
+constexpr bool // constexpr in C++20
 next_permutation(BidirectionalIterator first, BidirectionalIterator last, 
Compare comp);
 
 template 
-bool
+constexpr bool // constexpr in C++20
 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
 
 template 
-bool
+constexpr bool // constexpr in C++20
 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, 
Compare comp);
 
 }  // std
@@ -2321,7 +2321,7 @@ unique_copy(_InputIterator __first, _InputIterator 
__last, _OutputIterator __res
 // reverse
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, 
bidirectional_iterator_tag)
 {
@@ -2335,7 +2335,7 @@ __reverse(_BidirectionalIterator __first, 
_BidirectionalIterator __last, bidirec
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, 
random_access_iterator_tag)
 {
@@ -2345,7 +2345,7 @@ __reverse(_RandomAccessIterator __first, 
_RandomAccessIterator __last, random_ac
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
 {
@@ -3393,7 +3393,7 @@ is_partitioned(_InputIterator __first, _InputIterator 
__last, _Predicate __pred)
 // partition
 
 template 
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 __partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate 
__pred, forward_iterator_tag)
 {
 while (true)
@@ -3416,7 +3416,7 @@ __partition(_ForwardIterator __first, _ForwardIterator 
__last, _Predicate __pred
 }
 
 template 
-_BidirectionalIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator
 __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, 
_Predicate __pred,
 bidirectional_iterator_tag)
 {
@@ -3441,7 +3441,7 @@ __partition(_BidirectionalIterator __first, 
_BidirectionalIterator __last, _Pred
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
 {
@@ -5760,7 +5760,7 @@ lexicographical_compare(_InputIterator1 __first1, 
_InputIterator1 __last1,
 // next_permutation
 
 template 
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 __next_permutation(_BidirectionalIterator __first, _BidirectionalIterator 
__last, _Compare __com

[llvm-branch-commits] [libcxx] c85a094 - [libc++] Restore `basic_ios`'s implicit conversion to `bool` in C++03 mode.

2021-08-11 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-08-11T13:40:31-04:00
New Revision: c85a094bcaad233b1a7f029d29f37cfa70ef10c6

URL: 
https://github.com/llvm/llvm-project/commit/c85a094bcaad233b1a7f029d29f37cfa70ef10c6
DIFF: 
https://github.com/llvm/llvm-project/commit/c85a094bcaad233b1a7f029d29f37cfa70ef10c6.diff

LOG: [libc++] Restore `basic_ios`'s implicit conversion to `bool` in C++03 mode.

efriedma noted that D104682 broke this test case, reduced from SPEC2006.

#include 
bool a(std::istream a) {
return a.getline(0,0) == 0;
}

We can unbreak it by restoring the conversion to something-convertible-to-bool.
We chose `void*` in order to match libstdc++.

For more ancient history, see PR19460: 
https://bugs.llvm.org/show_bug.cgi?id=19460

Differential Revision: https://reviews.llvm.org/D107663

(cherry picked from commit c1a8f12873783e8f4827437f6b2dddadfc58109d)

Added: 


Modified: 
libcxx/include/ios
libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp

Removed: 




diff  --git a/libcxx/include/ios b/libcxx/include/ios
index 3128bca80..c9230d6a9484a 100644
--- a/libcxx/include/ios
+++ b/libcxx/include/ios
@@ -607,8 +607,15 @@ public:
 static_assert((is_same<_CharT, typename traits_type::char_type>::value),
   "traits_type::char_type must be the same type as CharT");
 
+#ifdef _LIBCPP_CXX03_LANG
+// Preserve the ability to compare with literal 0,
+// and implicitly convert to bool, but not implicitly convert to int.
+_LIBCPP_INLINE_VISIBILITY
+operator void*() const {return fail() ? nullptr : (void*)this;}
+#else
 _LIBCPP_INLINE_VISIBILITY
 explicit operator bool() const {return !fail();}
+#endif
 
 _LIBCPP_INLINE_VISIBILITY bool operator!() const{return  fail();}
 _LIBCPP_INLINE_VISIBILITY iostate rdstate() const   {return 
ios_base::rdstate();}

diff  --git 
a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp 
b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
index 59896c82f29b9..3fe50c6e045f6 100644
--- 
a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
+++ 
b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
@@ -24,10 +24,16 @@ int main(int, char**)
 assert(static_cast(ios) == !ios.fail());
 ios.setstate(std::ios::failbit);
 assert(static_cast(ios) == !ios.fail());
-static_assert((!std::is_convertible::value), "");
 static_assert((!std::is_convertible::value), "");
 static_assert((!std::is_convertible::value), "");
-static_assert((!std::is_convertible::value), "");
+#if TEST_STD_VER >= 11
+static_assert(!std::is_convertible::value, "");
+static_assert(!std::is_convertible::value, "");
+#else
+static_assert(std::is_convertible::value, "");
+static_assert(std::is_convertible::value, "");
+(void)(ios == 0);  // SPEC2006 apparently relies on this to compile
+#endif
 
   return 0;
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 216200a - [libc++] Fix hang in counting_semaphore::try_acquire

2021-11-05 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-11-05T15:59:12-04:00
New Revision: 216200aff2681407b5e799738b09a047771d86ec

URL: 
https://github.com/llvm/llvm-project/commit/216200aff2681407b5e799738b09a047771d86ec
DIFF: 
https://github.com/llvm/llvm-project/commit/216200aff2681407b5e799738b09a047771d86ec.diff

LOG: [libc++] Fix hang in counting_semaphore::try_acquire

Before this patch, `try_acquire` blocks instead of returning false.
This is because `__libcpp_thread_poll_with_backoff` interprets zero
as meaning infinite, causing `try_acquire` to wait indefinitely.

Thanks to Pablo Busse (pabusse) for the patch!

Differential Revision: https://reviews.llvm.org/D98334

(cherry picked from commit c92a253cf0ddcf905707b4e9265b42570ce409d9)

Added: 


Modified: 
libcxx/include/semaphore
libcxx/test/std/thread/thread.semaphore/try_acquire.pass.cpp

Removed: 




diff  --git a/libcxx/include/semaphore b/libcxx/include/semaphore
index 1128b36d9527..db03fb967ed1 100644
--- a/libcxx/include/semaphore
+++ b/libcxx/include/semaphore
@@ -105,17 +105,22 @@ public:
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
 bool try_acquire_for(chrono::duration const& __rel_time)
 {
-auto const __test_fn = [this]() -> bool {
-auto __old = __a.load(memory_order_acquire);
-while(1) {
-if (__old == 0)
-return false;
-if(__a.compare_exchange_strong(__old, __old - 1, 
memory_order_acquire, memory_order_relaxed))
-return true;
-}
-};
+if (__rel_time == chrono::duration::zero())
+return try_acquire();
+auto const __test_fn = [this]() { return try_acquire(); };
 return __libcpp_thread_poll_with_backoff(__test_fn, 
__libcpp_timed_backoff_policy(), __rel_time);
 }
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+bool try_acquire()
+{
+auto __old = __a.load(memory_order_acquire);
+while (true) {
+if (__old == 0)
+return false;
+if (__a.compare_exchange_strong(__old, __old - 1, 
memory_order_acquire, memory_order_relaxed))
+return true;
+}
+}
 };
 
 #define _LIBCPP_SEMAPHORE_MAX (numeric_limits::max())
@@ -156,14 +161,14 @@ public:
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
 bool try_acquire()
 {
-return try_acquire_for(chrono::nanoseconds::zero());
+return __semaphore.try_acquire();
 }
 template 
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
 bool try_acquire_until(chrono::time_point const& 
__abs_time)
 {
 auto const current = Clock::now();
-if(current >= __abs_time)
+if (current >= __abs_time)
 return try_acquire();
 else
 return try_acquire_for(__abs_time - current);

diff  --git a/libcxx/test/std/thread/thread.semaphore/try_acquire.pass.cpp 
b/libcxx/test/std/thread/thread.semaphore/try_acquire.pass.cpp
index 35cb6ce7dc82..5a5ab72d05df 100644
--- a/libcxx/test/std/thread/thread.semaphore/try_acquire.pass.cpp
+++ b/libcxx/test/std/thread/thread.semaphore/try_acquire.pass.cpp
@@ -27,14 +27,17 @@ int main(int, char**)
   std::counting_semaphore<> s(1);
 
   assert(s.try_acquire());
+  assert(!s.try_acquire());
   s.release();
   assert(s.try_acquire());
+  assert(!s.try_acquire());
   s.release(2);
   std::thread t = support::make_test_thread([&](){
 assert(s.try_acquire());
   });
   t.join();
   assert(s.try_acquire());
+  assert(!s.try_acquire());
 
   return 0;
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] c7463a9 - [libc++] [NFC] s/_LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)/!defined(_LIBCPP_HAS_NO_CONCEPTS)/

2022-02-02 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2022-02-02T12:16:28-05:00
New Revision: c7463a90789c9a0024a3142e059e2db90dae2075

URL: 
https://github.com/llvm/llvm-project/commit/c7463a90789c9a0024a3142e059e2db90dae2075
DIFF: 
https://github.com/llvm/llvm-project/commit/c7463a90789c9a0024a3142e059e2db90dae2075.diff

LOG: [libc++] [NFC] s/_LIBCPP_STD_VER > 17 && 
!defined(_LIBCPP_HAS_NO_CONCEPTS)/!defined(_LIBCPP_HAS_NO_CONCEPTS)/

Per Discord discussion, we're normalizing on a simple 
`!defined(_LIBCPP_HAS_NO_CONCEPTS)`
so that we can do a big search-and-replace for 
`!defined(_LIBCPP_HAS_NO_CONCEPTS)`
back into `_LIBCPP_STD_VER > 17` when we're ready to abandon support for 
concept-syntax-less
compilers.

Differential Revision: https://reviews.llvm.org/D118748

(cherry picked from commit 38db42d0043e501cbbb07ba6fa57597e6473fc3e)

Added: 


Modified: 
libcxx/include/__compare/compare_partial_order_fallback.h
libcxx/include/__compare/compare_strong_order_fallback.h
libcxx/include/__compare/compare_three_way.h
libcxx/include/__compare/compare_weak_order_fallback.h
libcxx/include/__compare/partial_order.h
libcxx/include/__compare/strong_order.h
libcxx/include/__compare/synth_three_way.h
libcxx/include/__compare/three_way_comparable.h
libcxx/include/__compare/weak_order.h
libcxx/include/__concepts/arithmetic.h
libcxx/include/__concepts/assignable.h
libcxx/include/__concepts/boolean_testable.h
libcxx/include/__concepts/class_or_enum.h
libcxx/include/__concepts/common_reference_with.h
libcxx/include/__concepts/common_with.h
libcxx/include/__concepts/constructible.h
libcxx/include/__concepts/convertible_to.h
libcxx/include/__concepts/copyable.h
libcxx/include/__concepts/derived_from.h
libcxx/include/__concepts/destructible.h
libcxx/include/__concepts/different_from.h
libcxx/include/__concepts/equality_comparable.h
libcxx/include/__concepts/invocable.h
libcxx/include/__concepts/movable.h
libcxx/include/__concepts/predicate.h
libcxx/include/__concepts/regular.h
libcxx/include/__concepts/relation.h
libcxx/include/__concepts/same_as.h
libcxx/include/__concepts/semiregular.h
libcxx/include/__concepts/swappable.h
libcxx/include/__concepts/totally_ordered.h
libcxx/include/__iterator/distance.h
libcxx/include/__iterator/insert_iterator.h
libcxx/include/__iterator/reverse_iterator.h
libcxx/include/__random/uniform_random_bit_generator.h
libcxx/include/__ranges/enable_borrowed_range.h
libcxx/include/__ranges/non_propagating_cache.h
libcxx/include/__utility/cmp.h
libcxx/include/__utility/pair.h
libcxx/include/numbers
libcxx/include/ranges
libcxx/include/string_view
libcxx/include/tuple
libcxx/include/type_traits

Removed: 




diff  --git a/libcxx/include/__compare/compare_partial_order_fallback.h 
b/libcxx/include/__compare/compare_partial_order_fallback.h
index 895523b38fb34..64937eaf37dd5 100644
--- a/libcxx/include/__compare/compare_partial_order_fallback.h
+++ b/libcxx/include/__compare/compare_partial_order_fallback.h
@@ -22,7 +22,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 // [cmp.alg]
 namespace __compare_partial_order_fallback {
@@ -66,7 +66,7 @@ inline namespace __cpo {
 inline constexpr auto compare_partial_order_fallback = 
__compare_partial_order_fallback::__fn{};
 } // namespace __cpo
 
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 _LIBCPP_END_NAMESPACE_STD
 

diff  --git a/libcxx/include/__compare/compare_strong_order_fallback.h 
b/libcxx/include/__compare/compare_strong_order_fallback.h
index 5fee7b4780684..b7abef26e9d2e 100644
--- a/libcxx/include/__compare/compare_strong_order_fallback.h
+++ b/libcxx/include/__compare/compare_strong_order_fallback.h
@@ -22,7 +22,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 // [cmp.alg]
 namespace __compare_strong_order_fallback {
@@ -63,7 +63,7 @@ inline namespace __cpo {
 inline constexpr auto compare_strong_order_fallback = 
__compare_strong_order_fallback::__fn{};
 } // namespace __cpo
 
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 _LIBCPP_END_NAMESPACE_STD
 

diff  --git a/libcxx/include/__compare/compare_three_way.h 
b/libcxx/include/__compare/compare_three_way.h
index d7f339eda992b..ddd37890a467c 100644
--- a/libcxx/include/__compare/compare_three_way.h
+++ b/libcxx/include/__compare/compare_three_way.h
@@ -20,7 +20,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 struct _LIBCPP_TEMPLATE_VIS

[llvm-branch-commits] [libcxx] 91632c8 - [libc++] [NFC] Normalize some `#ifndef _LIBCPP_HAS_NO_CONCEPTS`.

2022-02-02 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2022-02-02T12:16:36-05:00
New Revision: 91632c8ac97fa3daffe4ff8f1391735b5d6805e6

URL: 
https://github.com/llvm/llvm-project/commit/91632c8ac97fa3daffe4ff8f1391735b5d6805e6
DIFF: 
https://github.com/llvm/llvm-project/commit/91632c8ac97fa3daffe4ff8f1391735b5d6805e6.diff

LOG: [libc++] [NFC] Normalize some `#ifndef _LIBCPP_HAS_NO_CONCEPTS`.

(cherry picked from commit 93e7f35ac354a19a9db2f11fe17d1f955a5793b4)

Added: 


Modified: 
libcxx/include/__algorithm/in_in_out_result.h
libcxx/include/__algorithm/in_in_result.h
libcxx/include/__algorithm/in_out_result.h
libcxx/include/__iterator/indirectly_comparable.h

Removed: 




diff  --git a/libcxx/include/__algorithm/in_in_out_result.h 
b/libcxx/include/__algorithm/in_in_out_result.h
index e365eb58eb624..a492d27352291 100644
--- a/libcxx/include/__algorithm/in_in_out_result.h
+++ b/libcxx/include/__algorithm/in_in_out_result.h
@@ -14,11 +14,16 @@
 #include <__config>
 #include <__utility/move.h>
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#ifndef _LIBCPP_HAS_NO_CONCEPTS
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 namespace ranges {
+
 template 
 struct in_in_out_result {
   [[no_unique_address]] _I1 in1;
@@ -39,10 +44,11 @@ struct in_in_out_result {
 return {_VSTD::move(in1), _VSTD::move(in2), _VSTD::move(out)};
   }
 };
+
 } // namespace ranges
 
-#endif // _LIBCPP_HAS_NO_CONCEPTS
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 _LIBCPP_END_NAMESPACE_STD
 
-#endif // _LIBCPP___ALGORITHM_IN_IN_RESULT_H
+#endif // _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H

diff  --git a/libcxx/include/__algorithm/in_in_result.h 
b/libcxx/include/__algorithm/in_in_result.h
index ed14ecedbbdfe..c8fe43d039dcb 100644
--- a/libcxx/include/__algorithm/in_in_result.h
+++ b/libcxx/include/__algorithm/in_in_result.h
@@ -14,11 +14,16 @@
 #include <__config>
 #include <__utility/move.h>
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#ifndef _LIBCPP_HAS_NO_CONCEPTS
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 namespace ranges {
+
 template 
 struct in_in_result {
   [[no_unique_address]] _I1 in1;
@@ -36,9 +41,10 @@ struct in_in_result {
   _LIBCPP_HIDE_FROM_ABI constexpr
   operator in_in_result<_II1, _II2>() && { return {_VSTD::move(in1), 
_VSTD::move(in2)}; }
 };
+
 } // namespace ranges
 
-#endif // _LIBCPP_HAS_NO_CONCEPTS
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 _LIBCPP_END_NAMESPACE_STD
 

diff  --git a/libcxx/include/__algorithm/in_out_result.h 
b/libcxx/include/__algorithm/in_out_result.h
index 8a58d6ada10cf..d3c16e4acd459 100644
--- a/libcxx/include/__algorithm/in_out_result.h
+++ b/libcxx/include/__algorithm/in_out_result.h
@@ -21,6 +21,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
 namespace ranges {
 
 template
@@ -45,6 +46,7 @@ struct in_out_result {
 };
 
 } // namespace ranges
+
 #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 _LIBCPP_END_NAMESPACE_STD

diff  --git a/libcxx/include/__iterator/indirectly_comparable.h 
b/libcxx/include/__iterator/indirectly_comparable.h
index 3bafc56f926f9..ad5ff1a866d63 100644
--- a/libcxx/include/__iterator/indirectly_comparable.h
+++ b/libcxx/include/__iterator/indirectly_comparable.h
@@ -17,13 +17,13 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#ifndef _LIBCPP_HAS_NO_CONCEPTS
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 template 
 concept indirectly_comparable =
   indirect_binary_predicate<_Rp, projected<_I1, _P1>, projected<_I2, _P2>>;
 
-#endif // _LIBCPP_HAS_NO_CONCEPTS
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 _LIBCPP_END_NAMESPACE_STD
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 9f9ea70 - [libc++] No longer support ranges::begin(x) when x is an array of incomplete type.

2022-02-04 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2022-02-04T16:12:35-05:00
New Revision: 9f9ea707d0c6f2839a52a7045a35ea3356d851be

URL: 
https://github.com/llvm/llvm-project/commit/9f9ea707d0c6f2839a52a7045a35ea3356d851be
DIFF: 
https://github.com/llvm/llvm-project/commit/9f9ea707d0c6f2839a52a7045a35ea3356d851be.diff

LOG: [libc++] No longer support ranges::begin(x) when x is an array of 
incomplete type.

var-const points out that `ranges::begin` is (non-normatively
but explicitly) always supposed to return a `std::input_or_output_iterator`,
and `Incomplete*` is not a `std::input_or_output_iterator` because it
has no `operator++`. Therefore, we should never return `Incomplete*`
from `ranges::begin(x)`, even when `x` is `Incomplete(&)[]`. Instead,
just SFINAE away.

Differential Revision: https://reviews.llvm.org/D118963

(cherry picked from commit cc1d02ba2d177e0d31561934337f5412167f6954)

Added: 


Modified: 
libcxx/include/__ranges/access.h
libcxx/test/std/ranges/range.access/begin.pass.cpp

Removed: 
libcxx/test/libcxx/ranges/range.access/begin.incomplete_type.sh.cpp



diff  --git a/libcxx/include/__ranges/access.h 
b/libcxx/include/__ranges/access.h
index 67c6c57bd81e4..07a92d7834755 100644
--- a/libcxx/include/__ranges/access.h
+++ b/libcxx/include/__ranges/access.h
@@ -59,10 +59,17 @@ namespace __begin {
 
   struct __fn {
 template 
-  requires is_array_v>
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __t) 
const noexcept
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp 
(&__t)[]) const noexcept
+  requires (sizeof(_Tp) != 0)  // Disallow incomplete element types.
 {
-  return __t;
+  return __t + 0;
+}
+
+template 
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp 
(&__t)[_Np]) const noexcept
+  requires (sizeof(_Tp) != 0)  // Disallow incomplete element types.
+{
+  return __t + 0;
 }
 
 template 
@@ -127,7 +134,7 @@ namespace __end {
   public:
 template 
 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp 
(&__t)[_Np]) const noexcept
-  requires (sizeof(*__t) != 0)  // Disallow incomplete element types.
+  requires (sizeof(_Tp) != 0)  // Disallow incomplete element types.
 {
   return __t + _Np;
 }

diff  --git 
a/libcxx/test/libcxx/ranges/range.access/begin.incomplete_type.sh.cpp 
b/libcxx/test/libcxx/ranges/range.access/begin.incomplete_type.sh.cpp
deleted file mode 100644
index cc27789c04f3d..0
--- a/libcxx/test/libcxx/ranges/range.access/begin.incomplete_type.sh.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-//===--===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-// RUN: %{cxx} %{flags} %{compile_flags} -c %s -o %t.tu1.o -DTU1
-// RUN: %{cxx} %{flags} %{compile_flags} -c %s -o %t.tu2.o -DTU2
-// RUN: %{cxx} %t.tu1.o %t.tu2.o %{flags} %{link_flags} -o %t.exe
-// RUN: %{exec} %t.exe
-
-// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: libcpp-no-concepts
-// UNSUPPORTED: libcpp-has-no-incomplete-ranges
-
-// Test the libc++-specific behavior that we handle the IFNDR case for 
ranges::begin
-// by returning the beginning of the array-of-incomplete-type.
-// Use two translation units so that `Incomplete` really is never completed
-// at any point within TU2, but the array `bounded` is still given a definition
-// (in TU1) to avoid an "undefined reference" error from the linker.
-// All of the actually interesting stuff takes place within TU2.
-
-#include 
-#include 
-
-#include "test_macros.h"
-
-#if defined(TU1)
-
-struct Incomplete {};
-Incomplete bounded[10];
-Incomplete unbounded[10];
-
-#else // defined(TU1)
-
-struct Incomplete;
-
-constexpr bool test()
-{
-{
-extern Incomplete bounded[10];
-assert(std::ranges::begin(bounded) == bounded);
-assert(std::ranges::cbegin(bounded) == bounded);
-assert(std::ranges::begin(std::as_const(bounded)) == bounded);
-assert(std::ranges::cbegin(std::as_const(bounded)) == bounded);
-ASSERT_SAME_TYPE(decltype(std::ranges::begin(bounded)), Incomplete*);
-ASSERT_SAME_TYPE(decltype(std::ranges::cbegin(bounded)), const 
Incomplete*);
-ASSERT_SAME_TYPE(decltype(std::ranges::begin(std::as_const(bounded))), 
const Incomplete*);
-ASSERT_SAME_TYPE(decltype(std::ranges::cbegin(std::as_const(bounded))), 
const Incomplete*);
-}
-{
-extern Incomplete unbounded[];
-assert(std::ranges::begin(unbounded) == unbounded);
-assert(std::ranges::cbegin(unbounded) == unbounded);
-assert(std::ranges::begin(std::as_const(unbounded)) == unbounded);
-ass

[llvm-branch-commits] [libcxx] eef4bdb - [libc++] Add a missing `<_Compare>` template argument.

2021-01-12 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-01-12T14:18:24-05:00
New Revision: eef4bdbb34de2dda657668c2ab39397e61e36a0a

URL: 
https://github.com/llvm/llvm-project/commit/eef4bdbb34de2dda657668c2ab39397e61e36a0a
DIFF: 
https://github.com/llvm/llvm-project/commit/eef4bdbb34de2dda657668c2ab39397e61e36a0a.diff

LOG: [libc++] Add a missing `<_Compare>` template argument.

Sometimes `_Compare` is an lvalue reference type, so letting it be
deduced is pretty much always wrong. (Well, less efficient than
it could be, anyway.)

Differential Revision: https://reviews.llvm.org/D93562

Added: 


Modified: 
libcxx/include/algorithm

Removed: 




diff  --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 7a4cc39dbeab..fe9caf475f5a 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -4483,7 +4483,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, 
_BidirectionalIterator
 value_type* __p = __buff;
 for (_BidirectionalIterator __i = __first; __i != __middle; 
__d.template __incr(), (void) ++__i, (void) ++__p)
 ::new ((void*)__p) value_type(_VSTD::move(*__i));
-_VSTD::__half_inplace_merge(__buff, __p, __middle, __last, __first, 
__comp);
+_VSTD::__half_inplace_merge<_Compare>(__buff, __p, __middle, __last, 
__first, __comp);
 }
 else
 {
@@ -4492,9 +4492,10 @@ __buffered_inplace_merge(_BidirectionalIterator __first, 
_BidirectionalIterator
 ::new ((void*)__p) value_type(_VSTD::move(*__i));
 typedef reverse_iterator<_BidirectionalIterator> _RBi;
 typedef reverse_iterator _Rv;
-_VSTD::__half_inplace_merge(_Rv(__p), _Rv(__buff),
+typedef __invert<_Compare> _Inverted;
+_VSTD::__half_inplace_merge<_Inverted>(_Rv(__p), _Rv(__buff),
 _RBi(__middle), _RBi(__first),
-_RBi(__last), 
_VSTD::__invert<_Compare>(__comp));
+_RBi(__last), _Inverted(__comp));
 }
 }
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 14573d4 - Regenerate the feature test macro unit-tests. NFCI.

2021-01-18 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-01-18T19:06:28-05:00
New Revision: 14573d44ae097969a6168fbf14cc7f796442a296

URL: 
https://github.com/llvm/llvm-project/commit/14573d44ae097969a6168fbf14cc7f796442a296
DIFF: 
https://github.com/llvm/llvm-project/commit/14573d44ae097969a6168fbf14cc7f796442a296.diff

LOG: Regenerate the feature test macro unit-tests. NFCI.

Somehow commit 1f1250151f222ba391d05dcc173f4b6c65d05ca2 added the
right code but with the wrong whitespace.

Added: 


Modified: 

libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp
 
b/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp
index 41bc22f6a330..368c3811532c 100644
--- 
a/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp
+++ 
b/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp
@@ -638,11 +638,11 @@
 #   endif
 # endif
 
-#ifndef __cpp_lib_is_scoped_enum
-#error "__cpp_lib_is_scoped_enum should be defined in c++2b"
-#endif
-#if __cpp_lib_is_scoped_enum != 202011L
-#error "__cpp_lib_is_scoped_enum should have the value 202011L in c++2b"
+# ifndef __cpp_lib_is_scoped_enum
+#   error "__cpp_lib_is_scoped_enum should be defined in c++2b"
+# endif
+# if __cpp_lib_is_scoped_enum != 202011L
+#   error "__cpp_lib_is_scoped_enum should have the value 202011L in c++2b"
 # endif
 
 # ifndef __cpp_lib_is_swappable

diff  --git 
a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
 
b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
index 3ff920c3a489..887416c9dcbe 100644
--- 
a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
+++ 
b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
@@ -3983,11 +3983,11 @@
 #   endif
 # endif
 
-#ifndef __cpp_lib_is_scoped_enum
-#error "__cpp_lib_is_scoped_enum should be defined in c++2b"
-#endif
-#if __cpp_lib_is_scoped_enum != 202011L
-#error "__cpp_lib_is_scoped_enum should have the value 202011L in c++2b"
+# ifndef __cpp_lib_is_scoped_enum
+#   error "__cpp_lib_is_scoped_enum should be defined in c++2b"
+# endif
+# if __cpp_lib_is_scoped_enum != 202011L
+#   error "__cpp_lib_is_scoped_enum should have the value 202011L in c++2b"
 # endif
 
 # ifndef __cpp_lib_is_swappable



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 30f589c - [libc++] Constexpr-proof some machinery in not_fn.pass.cpp. NFCI.

2020-12-28 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-28T13:24:07-05:00
New Revision: 30f589c912115b4653f596eb3fd5bf62412f8aa7

URL: 
https://github.com/llvm/llvm-project/commit/30f589c912115b4653f596eb3fd5bf62412f8aa7
DIFF: 
https://github.com/llvm/llvm-project/commit/30f589c912115b4653f596eb3fd5bf62412f8aa7.diff

LOG: [libc++] Constexpr-proof some machinery in not_fn.pass.cpp. NFCI.

We don't need to use global variables here; we can store the "State"
of this machinery on the stack, so that it's constexpr-friendly.

Added: 


Modified: 
libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp 
b/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
index 56ed61500d3c..75f7f9fd4f02 100644
--- a/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
@@ -135,59 +135,60 @@ inline constexpr CallType operator|(CallType LHS, 
CallType RHS) {
 }
 
 struct ForwardingCallObject {
+  struct State {
+CallType  last_call_type = CT_None;
+TypeID const& (*last_call_args)() = nullptr;
+
+template 
+constexpr void set_call(CallType type) {
+  assert(last_call_type == CT_None);
+  assert(last_call_args == nullptr);
+  last_call_type = type;
+  last_call_args = &makeArgumentID;
+}
+
+template 
+constexpr bool check_call(CallType type) {
+  bool result =
+   last_call_type == type
+&& last_call_args
+&& *last_call_args == &makeArgumentID;
+  last_call_type = CT_None;
+  last_call_args = nullptr;
+  return result;
+}
+  };
+
+  State *st_;
+
+  explicit constexpr ForwardingCallObject(State& st) : st_(&st) {}
 
   template 
-  bool operator()(Args&&...) & {
-  set_call(CT_NonConst | CT_LValue);
+  constexpr bool operator()(Args&&...) & {
+  st_->set_call(CT_NonConst | CT_LValue);
   return true;
   }
 
   template 
-  bool operator()(Args&&...) const & {
-  set_call(CT_Const | CT_LValue);
+  constexpr bool operator()(Args&&...) const & {
+  st_->set_call(CT_Const | CT_LValue);
   return true;
   }
 
   // Don't allow the call operator to be invoked as an rvalue.
   template 
-  bool operator()(Args&&...) && {
-  set_call(CT_NonConst | CT_RValue);
+  constexpr bool operator()(Args&&...) && {
+  st_->set_call(CT_NonConst | CT_RValue);
   return true;
   }
 
   template 
-  bool operator()(Args&&...) const && {
-  set_call(CT_Const | CT_RValue);
+  constexpr bool operator()(Args&&...) const && {
+  st_->set_call(CT_Const | CT_RValue);
   return true;
   }
-
-  template 
-  static void set_call(CallType type) {
-  assert(last_call_type == CT_None);
-  assert(last_call_args == nullptr);
-  last_call_type = type;
-  last_call_args = &makeArgumentID();
-  }
-
-  template 
-  static bool check_call(CallType type) {
-  bool result =
-   last_call_type == type
-&& last_call_args
-&& *last_call_args == makeArgumentID();
-  last_call_type = CT_None;
-  last_call_args = nullptr;
-  return result;
-  }
-
-  static CallType  last_call_type;
-  static TypeID const* last_call_args;
 };
 
-CallType ForwardingCallObject::last_call_type = CT_None;
-TypeID const* ForwardingCallObject::last_call_args = nullptr;
-
-
 
 ///
 //BOOL TEST TYPES
@@ -467,85 +468,86 @@ void call_operator_sfinae_test() {
 void call_operator_forwarding_test()
 {
 using Fn = ForwardingCallObject;
-auto obj = std::not_fn(Fn{});
+Fn::State st;
+auto obj = std::not_fn(Fn{st});
 const auto& c_obj = obj;
 { // test zero args
 obj();
-assert(Fn::check_call<>(CT_NonConst | CT_LValue));
+assert(st.check_call<>(CT_NonConst | CT_LValue));
 std::move(obj)();
-assert(Fn::check_call<>(CT_NonConst | CT_RValue));
+assert(st.check_call<>(CT_NonConst | CT_RValue));
 c_obj();
-assert(Fn::check_call<>(CT_Const | CT_LValue));
+assert(st.check_call<>(CT_Const | CT_LValue));
 std::move(c_obj)();
-assert(Fn::check_call<>(CT_Const | CT_RValue));
+assert(st.check_call<>(CT_Const | CT_RValue));
 }
 { // test value categories
 int x = 42;
 const int cx = 42;
 obj(x);
-assert(Fn::check_call(CT_NonConst | CT_LValue));
+assert(st.check_call(CT_NonConst | CT_LValue));
 obj(cx);
-assert(Fn::check_call(CT_NonConst | CT_LValue));
+assert(st.check_call(CT_NonConst | CT_LValue));
 obj(std::move(x));
-assert(Fn::check_call(CT_NonConst | CT_LValue));
+assert(st.check_call(CT_NonConst | CT_LValue));
 ob

[llvm-branch-commits] [libcxx] 7b00e9f - [libc++] [P1065] Constexpr invoke, reference_wrapper, mem_fn, not_fn, default_searcher.

2020-12-28 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-28T13:24:07-05:00
New Revision: 7b00e9fae3853d4693e608cc52f6d6da5059f5ff

URL: 
https://github.com/llvm/llvm-project/commit/7b00e9fae3853d4693e608cc52f6d6da5059f5ff
DIFF: 
https://github.com/llvm/llvm-project/commit/7b00e9fae3853d4693e608cc52f6d6da5059f5ff.diff

LOG: [libc++] [P1065] Constexpr invoke, reference_wrapper, mem_fn, not_fn, 
default_searcher.

This completes the implementation of P1065 "constexpr INVOKE":
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1065r2.html

This doesn't yet complete the implementation of P1032 "Misc constexpr bits,"
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1032r1.html
but it does complete all of the  bits, which means
that we can now set `__cpp_lib_constexpr_functional` for C++20.

This could use more constexpr tests for `std::reference_wrapper`,
but the existing tests are extremely non-constexpr-friendly and
so I don't want to get into that rabbit-hole today.

Differential Revision: https://reviews.llvm.org/D93815

Added: 

libcxx/test/std/utilities/function.objects/func.invoke/invoke_constexpr.pass.cpp

Modified: 
libcxx/docs/Cxx2aStatusPaperStatus.csv
libcxx/docs/FeatureTestMacroTable.rst
libcxx/include/__functional_base
libcxx/include/functional
libcxx/include/type_traits
libcxx/include/version

libcxx/test/std/language.support/support.limits/support.limits.general/array.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/string_view.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/tuple.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp

libcxx/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp

libcxx/test/std/utilities/function.objects/func.memfn/member_function_const.pass.cpp
libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp

libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pass.cpp

libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp
libcxx/utils/generate_feature_test_macro_components.py

Removed: 




diff  --git a/libcxx/docs/Cxx2aStatusPaperStatus.csv 
b/libcxx/docs/Cxx2aStatusPaperStatus.csv
index c495e0210cf7..fe5b2f5d4771 100644
--- a/libcxx/docs/Cxx2aStatusPaperStatus.csv
+++ b/libcxx/docs/Cxx2aStatusPaperStatus.csv
@@ -109,7 +109,7 @@
 "`P0980 `__","LWG","Making std::string 
constexpr","Cologne","",""
 "`P1004 `__","LWG","Making std::vector 
constexpr","Cologne","",""
 "`P1035 `__","LWG","Input Range 
Adaptors","Cologne","",""
-"`P1065 `__","LWG","Constexpr INVOKE","Cologne","",""
+"`P1065 `__","LWG","Constexpr 
INVOKE","Cologne","|Complete|","12.0"
 "`P1135 `__","LWG","The C++20 Synchronization 
Library","Cologne","|Complete|","11.0"
 "`P1207 `__","LWG","Movability of Single-pass 
Iterators","Cologne","",""
 "`P1208 `__","LWG","Adopt source_location for 
C++20","Cologne","",""

diff  --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index 091d4b795233..5930cdaffaec 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -194,7 +194,7 @@ Status
 - -
 ``__cpp_lib_constexpr_dynamic_alloc`` ``201907L``
 - -
-``__cpp_lib_constexpr_misc``  *unimplemented*
+``__cpp_lib_constexpr_functional````201907L``
 - -
 ``__cpp_lib_constexpr_numeric``   ``201911L``
 - -

diff  --git a/libcxx/include/__functional_base 
b/libcxx/include/__functional_base
index c84e7eb11567..708c1a23e84b 100644
--- a/libcxx/include/__functional_base
+++ b/libcxx/include/__functional_base
@@ -382,20 +382,23 @@ private:
 
 public:
 // construct/copy/destroy
-_LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+reference_wrapper(type& __f) _NOEX

[llvm-branch-commits] [libcxx] dd756e3 - [libc++] Fix a test failure in 7b00e9fae3 (D93815).

2020-12-28 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-28T13:55:40-05:00
New Revision: dd756e3e84812bd962a5b5eaf4f10e9c9338c232

URL: 
https://github.com/llvm/llvm-project/commit/dd756e3e84812bd962a5b5eaf4f10e9c9338c232
DIFF: 
https://github.com/llvm/llvm-project/commit/dd756e3e84812bd962a5b5eaf4f10e9c9338c232.diff

LOG: [libc++] Fix a test failure in 7b00e9fae3 (D93815).

"LLVM Buildbot on libcxx-libcxxabi-x86_64-linux-debian" is not happy
with default-initializing the `double` member of `A` in a constexpr
function. At least I'm pretty sure that's what it's complaining about.

Added: 


Modified: 
libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp 
b/libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp
index 5cb4d2d28ab5..d6cd06cd8cd0 100644
--- a/libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp
@@ -25,7 +25,7 @@ TEST_CONSTEXPR_CXX20 bool
 test(F f)
 {
 {
-A a;
+A a = {0.0};
 f(a) = 5;
 assert(a.data_ == 5);
 A* ap = &a;



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] c0a2d3b - [libc++] Fix a test failure in 7b00e9fae3 (D93815).

2020-12-28 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-28T18:46:07-05:00
New Revision: c0a2d3b90b3b024247cb38f73219ed595e974431

URL: 
https://github.com/llvm/llvm-project/commit/c0a2d3b90b3b024247cb38f73219ed595e974431
DIFF: 
https://github.com/llvm/llvm-project/commit/c0a2d3b90b3b024247cb38f73219ed595e974431.diff

LOG: [libc++] Fix a test failure in 7b00e9fae3 (D93815).

"LLVM Buildbot on libcxx-libcxxabi-libunwind-armv7-linux" is not happy
with comparing `unsigned` and `int` [-Werror,-Wsign-compare].

Added: 


Modified: 

libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp
 
b/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp
index bc9ba2f860b4..59e5f7f52f01 100644
--- 
a/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp
+++ 
b/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp
@@ -40,7 +40,7 @@
 
 struct count_equal
 {
-unsigned *count;
+int *count;
 
 template 
 TEST_CONSTEXPR_CXX14 bool operator()(const T& x, const T& y) const
@@ -50,11 +50,11 @@ struct count_equal
 template 
 TEST_CONSTEXPR_CXX20
 void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result) {
-unsigned count = 0;
+int count = 0;
 std::default_searcher s{b2, e2, count_equal{&count}};
 assert(result == std::search(b1, e1, s));
-auto d1 = std::distance(b1, e1);
-auto d2 = std::distance(b2, e2);
+int d1 = std::distance(b1, e1);
+int d2 = std::distance(b2, e2);
 assert((count >= 1) || (d2 == 0) || (d1 < d2));
 assert((d1 < d2) || count <= d1 * (d1 - d2 + 1));
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 781c476 - [libc++] ADL-proof vector by adding _VSTD:: qualification on calls.

2021-01-06 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-01-06T18:23:50-05:00
New Revision: 781c476ce09ed983477885e33b8acbb2220ad3a1

URL: 
https://github.com/llvm/llvm-project/commit/781c476ce09ed983477885e33b8acbb2220ad3a1
DIFF: 
https://github.com/llvm/llvm-project/commit/781c476ce09ed983477885e33b8acbb2220ad3a1.diff

LOG: [libc++] ADL-proof vector by adding _VSTD:: qualification on calls.

This affects only vectors with weird/malicious allocators,
the same corner case covered in D91708, but for `vector` this time.

Also ADL-proof <__tree>, which affects only sets and maps with weird/malicious
allocators where the ADL trap is in the *fancy pointer type*.

Also drive-by _VSTD:: qualification in the guts of std::bind,
std::packaged_task, std::condition_variable.

Differential Revision: https://reviews.llvm.org/D93424

Added: 


Modified: 
libcxx/include/__bit_reference
libcxx/include/__mutex_base
libcxx/include/__tree
libcxx/include/array
libcxx/include/bitset
libcxx/include/functional
libcxx/include/future
libcxx/include/iomanip
libcxx/include/mutex
libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp

Removed: 




diff  --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference
index 4a2b82064b3c9..284ed0fb0d54b 100644
--- a/libcxx/include/__bit_reference
+++ b/libcxx/include/__bit_reference
@@ -239,8 +239,8 @@ __bit_iterator<_Cp, _IsConst>
 find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> 
__last, const _Tp& __value_)
 {
 if (static_cast(__value_))
-return __find_bool_true(__first, static_cast(__last - __first));
-return __find_bool_false(__first, static_cast(__last - __first));
+return _VSTD::__find_bool_true(__first, static_cast(__last - __first));
+return _VSTD::__find_bool_false(__first, static_cast(__last - __first));
 }
 
 // count
@@ -313,8 +313,8 @@ typename __bit_iterator<_Cp, _IsConst>::
diff erence_type
 count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> 
__last, const _Tp& __value_)
 {
 if (static_cast(__value_))
-return __count_bool_true(__first, static_cast(__last - __first));
-return __count_bool_false(__first, static_cast(__last - __first));
+return _VSTD::__count_bool_true(__first, static_cast(__last - __first));
+return _VSTD::__count_bool_false(__first, static_cast(__last - __first));
 }
 
 // fill_n
@@ -387,9 +387,9 @@ fill_n(__bit_iterator<_Cp, false> __first, typename 
_Cp::size_type __n, bool __v
 if (__n > 0)
 {
 if (__value_)
-__fill_n_true(__first, __n);
+_VSTD::__fill_n_true(__first, __n);
 else
-__fill_n_false(__first, __n);
+_VSTD::__fill_n_false(__first, __n);
 }
 }
 
@@ -538,8 +538,8 @@ __bit_iterator<_Cp, false>
 copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> 
__last, __bit_iterator<_Cp, false> __result)
 {
 if (__first.__ctz_ == __result.__ctz_)
-return __copy_aligned(__first, __last, __result);
-return __copy_unaligned(__first, __last, __result);
+return _VSTD::__copy_aligned(__first, __last, __result);
+return _VSTD::__copy_unaligned(__first, __last, __result);
 }
 
 // copy_backward
@@ -685,8 +685,8 @@ __bit_iterator<_Cp, false>
 copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, 
_IsConst> __last, __bit_iterator<_Cp, false> __result)
 {
 if (__last.__ctz_ == __result.__ctz_)
-return __copy_backward_aligned(__first, __last, __result);
-return __copy_backward_unaligned(__first, __last, __result);
+return _VSTD::__copy_backward_aligned(__first, __last, __result);
+return _VSTD::__copy_backward_unaligned(__first, __last, __result);
 }
 
 // move
@@ -868,8 +868,8 @@ swap_ranges(__bit_iterator<__C1, false> __first1, 
__bit_iterator<__C1, false> __
 __bit_iterator<__C2, false> __first2)
 {
 if (__first1.__ctz_ == __first2.__ctz_)
-return __swap_ranges_aligned(__first1, __last1, __first2);
-return __swap_ranges_unaligned(__first1, __last1, __first2);
+return _VSTD::__swap_ranges_aligned(__first1, __last1, __first2);
+return _VSTD::__swap_ranges_unaligned(__first1, __last1, __first2);
 }
 
 // rotate
@@ -1083,8 +1083,8 @@ bool
 equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, 
__bit_iterator<_Cp, _IC2> __first2)
 {
 if (__first1.__ctz_ == __first2.__ctz_)
-return __equal_aligned(__first1, __last1, __first2);
-return __equal_unaligned(__first1, __last1, __first2);
+return _VSTD::__equal_aligned(__first1, __last1, __first2);
+return _VSTD::__equal_unaligned(__first1, __last1, __first2);
 }
 
 template & __lk,
 if (__t <= __now)
 return cv_status::timeout;
 
-__clock_tp_ns __t_ns = 
__clock_tp_ns(__safe_nanosecond_cast(__t.time_since_epoch()));
+  

[llvm-branch-commits] [libcxx] ff1b6f9 - [libc++] Alphabetize generate_feature_test_macro_components.py. NFCI.

2021-01-07 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-01-07T18:11:46-05:00
New Revision: ff1b6f9ff27cc4d5607ea2b5daa980a1c553236b

URL: 
https://github.com/llvm/llvm-project/commit/ff1b6f9ff27cc4d5607ea2b5daa980a1c553236b
DIFF: 
https://github.com/llvm/llvm-project/commit/ff1b6f9ff27cc4d5607ea2b5daa980a1c553236b.diff

LOG: [libc++] Alphabetize generate_feature_test_macro_components.py. NFCI.

For ease of comparing our list with the official SD-6 list, which is 
alphabetized.
https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#library-feature-test-macros
This also alphabetizes the lists of headers in which the macros are
defined, which harmlessly alters many comments in .
Also drive-by-fix some trivial flake8 warnings.

Added: 


Modified: 
libcxx/include/version
libcxx/utils/generate_feature_test_macro_components.py

Removed: 




diff  --git a/libcxx/include/version b/libcxx/include/version
index dde6ca165b35..39e307e93bc2 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -15,13 +15,13 @@
 
 Macro name  Value   Headers
 __cpp_lib_addressof_constexpr   201603L 
-__cpp_lib_allocator_traits_is_always_equal  201411L  
 
- 
 
-  

-
 
+__cpp_lib_allocator_traits_is_always_equal  201411L  
 
+  

+  

+
 
 __cpp_lib_any   201606L 
 __cpp_lib_apply 201603L 
-__cpp_lib_array_constexpr   201811L  

+__cpp_lib_array_constexpr   201811L  

 201603L // C++17
 __cpp_lib_as_const  201510L 
 __cpp_lib_atomic_flag_test  201907L 
@@ -53,9 +53,9 @@ __cpp_lib_constexpr_utility 
201811L 
 __cpp_lib_destroying_delete 201806L 
 __cpp_lib_enable_shared_from_this   201603L 
 __cpp_lib_endian201907L 
-__cpp_lib_erase_if  202002L  
 
- 
 
- 
 
+__cpp_lib_erase_if  202002L  
 
+  

+
  
 __cpp_lib_exchange_function 201304L 
 __cpp_lib_execution 201603L 
 __cpp_lib_filesystem201703L 
@@ -89,8 +89,8 @@ __cpp_lib_math_special_functions
201603L 
 __cpp_lib_memory_resource   201603L 

 __cpp_lib_node_extract  201606L   

 
-__cpp_lib_nonmember_container_access201411L  
 
- 
 
+__cpp_lib_nonmember_container_access201411L  
 
+ 
 
   

 
  
 __cpp_lib_not_fn201603L 
@@ -119,7 +119,7 @@ __cpp_lib_transformation_trait_aliases  
201304L 
 __cpp_lib_transparent_operators 201510L 
 201210L // C++14
 __cpp_lib_tuple_element_t   201402L 
-__cpp_lib_tuples_by_type201304L  

+__cpp_lib_tuples_by_type201304L  

 __cpp_lib_type_trait_variable_templates 201510L 
 __cpp_lib_uncaught_exceptions   201411L 
 __cpp_lib_unordered_map_try_emplace 201411L 

diff  --git a/libcxx/utils/generate_feature_test_macro_components.py 
b/libcxx/utils/generate_feature_test_macro_components.py
index 2302dc4ec505..37d8a95dd9ae 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -1,8 +1,7 @@
 #!/usr/bin/env python
 
 import os
-import tempfile
-from builtins import int, range
+from builtins import range

[llvm-branch-commits] [libcxx] ca1694b - Re-enable __cpp_lib_constexpr_functional.

2021-01-08 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-01-08T17:30:04-05:00
New Revision: ca1694b9d07cf14dd15d804b37fa151f4e082c2f

URL: 
https://github.com/llvm/llvm-project/commit/ca1694b9d07cf14dd15d804b37fa151f4e082c2f
DIFF: 
https://github.com/llvm/llvm-project/commit/ca1694b9d07cf14dd15d804b37fa151f4e082c2f.diff

LOG: Re-enable __cpp_lib_constexpr_functional.

I accidentally disabled this feature-test macro in my D93830,
due to a rebasing conflict. It had been enabled by my D93815,
and should have remained enabled.

Added: 


Modified: 
libcxx/docs/FeatureTestMacroTable.rst
libcxx/include/version

libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
libcxx/utils/generate_feature_test_macro_components.py

Removed: 




diff  --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index 97edbb0a2e1f..99fb4e790c7d 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -206,7 +206,7 @@ Status
 - -
 ``__cpp_lib_constexpr_dynamic_alloc`` ``201907L``
 - -
-``__cpp_lib_constexpr_functional``*unimplemented*
+``__cpp_lib_constexpr_functional````201907L``
 - -
 ``__cpp_lib_constexpr_iterator``  *unimplemented*
 - -

diff  --git a/libcxx/include/version b/libcxx/include/version
index 9ef782a834de..3920b69a601c 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -296,7 +296,7 @@ __cpp_lib_void_t
201411L 
 // # define __cpp_lib_constexpr_algorithms 201806L
 // # define __cpp_lib_constexpr_complex201711L
 # define __cpp_lib_constexpr_dynamic_alloc  201907L
-// # define __cpp_lib_constexpr_functional 201907L
+# define __cpp_lib_constexpr_functional 201907L
 // # define __cpp_lib_constexpr_iterator   201811L
 // # define __cpp_lib_constexpr_memory 201811L
 # define __cpp_lib_constexpr_numeric201911L

diff  --git 
a/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp
 
b/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp
index db736a785af2..6fa1ac6ada5b 100644
--- 
a/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp
+++ 
b/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp
@@ -198,17 +198,11 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_constexpr_functional
-# error "__cpp_lib_constexpr_functional should be defined in c++20"
-#   endif
-#   if __cpp_lib_constexpr_functional != 201907L
-# error "__cpp_lib_constexpr_functional should have the value 201907L in 
c++20"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_constexpr_functional
-# error "__cpp_lib_constexpr_functional should not be defined because it 
is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_constexpr_functional
+#   error "__cpp_lib_constexpr_functional should be defined in c++20"
+# endif
+# if __cpp_lib_constexpr_functional != 201907L
+#   error "__cpp_lib_constexpr_functional should have the value 201907L in 
c++20"
 # endif
 
 # ifndef __cpp_lib_invoke
@@ -287,17 +281,11 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_constexpr_functional
-# error "__cpp_lib_constexpr_functional should be defined in c++2b"
-#   endif
-#   if __cpp_lib_constexpr_functional != 201907L
-# error "__cpp_lib_constexpr_functional should have the value 201907L in 
c++2b"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_constexpr_functional
-# error "__cpp_lib_constexpr_functional should not be defined because it 
is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_constexpr_functional
+#   error "__cpp_lib_constexpr_functional should be defined in c++2b"
+# endif
+# if __cpp_lib_constexpr_functional != 201907L
+#   error "__cpp_lib_constexpr_functional should have the value 201907L in 
c++2b"
 # endif
 
 # ifndef __cpp_lib_invoke

diff  --git 
a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
 
b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
index 18b367e868dd..a75d6db28b22 100644
--- 
a/libcxx/test/std/language.support/support.limits/s

[llvm-branch-commits] [libcxx] 963b771 - [libc++] Mark [P0475] "LWG2511: guaranteed copy elision for piecewise construction" as Complete.

2021-01-08 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-01-08T17:33:13-05:00
New Revision: 963b771e24caff502d6b5d9b2f72dd88dd56e97a

URL: 
https://github.com/llvm/llvm-project/commit/963b771e24caff502d6b5d9b2f72dd88dd56e97a
DIFF: 
https://github.com/llvm/llvm-project/commit/963b771e24caff502d6b5d9b2f72dd88dd56e97a.diff

LOG: [libc++] Mark [P0475] "LWG2511: guaranteed copy elision for piecewise 
construction" as Complete.

The point of LWG2511 is basically just to make sure that we use
`tuple` instead of `tuple` in a couple of places
inside `scoped_allocator_adaptor` and inside `pair`.
As far as I can tell, this has been true for libc++
since EricWF's D27612 (and maybe even earlier than that).

Added: 


Modified: 
libcxx/docs/Cxx2aStatusPaperStatus.csv

Removed: 




diff  --git a/libcxx/docs/Cxx2aStatusPaperStatus.csv 
b/libcxx/docs/Cxx2aStatusPaperStatus.csv
index c2a84a4b4353..57edb5992dbf 100644
--- a/libcxx/docs/Cxx2aStatusPaperStatus.csv
+++ b/libcxx/docs/Cxx2aStatusPaperStatus.csv
@@ -28,7 +28,7 @@
 "","","","","",""
 "`P0019R8 `__","LWG","Atomic Ref","Rapperswil","",""
 "`P0458R2 `__","LWG","Checking for Existence of an 
Element in Associative Containers","Rapperswil","|Complete|",""
-"`P0475R1 `__","LWG","LWG 2511: guaranteed copy 
elision for piecewise construction","Rapperswil","",""
+"`P0475R1 `__","LWG","LWG 2511: guaranteed copy 
elision for piecewise construction","Rapperswil","|Complete|",""
 "`P0476R2 `__","LWG","Bit-casting object 
representations","Rapperswil","",""
 "`P0528R3 `__","CWG","The Curious Case of Padding 
Bits, Featuring Atomic Compare-and-Exchange","Rapperswil","",""
 "`P0542R5 `__","CWG","Support for contract based 
programming in C++","Rapperswil","*Removed in Cologne*","n/a"



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] cdd7cbf - [libc++] Mark [P0809] "LWG2831: Comparing Unordered Containers" as Nothing To Do.

2021-01-08 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-01-08T17:33:22-05:00
New Revision: cdd7cbf7b56bf9e46914ee95c0658f543c7c14a9

URL: 
https://github.com/llvm/llvm-project/commit/cdd7cbf7b56bf9e46914ee95c0658f543c7c14a9
DIFF: 
https://github.com/llvm/llvm-project/commit/cdd7cbf7b56bf9e46914ee95c0658f543c7c14a9.diff

LOG: [libc++] Mark [P0809] "LWG2831: Comparing Unordered Containers" as Nothing 
To Do.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0809r0.pdf

This issue/paper simply removed some library UB because vendors were
already doing the right thing. libc++ has always done the right thing
(in this respect).

Differential Revision: https://reviews.llvm.org/D93816

Added: 


Modified: 
libcxx/docs/Cxx2aStatusPaperStatus.csv

Removed: 




diff  --git a/libcxx/docs/Cxx2aStatusPaperStatus.csv 
b/libcxx/docs/Cxx2aStatusPaperStatus.csv
index 57edb5992dbf..3747977b5d6c 100644
--- a/libcxx/docs/Cxx2aStatusPaperStatus.csv
+++ b/libcxx/docs/Cxx2aStatusPaperStatus.csv
@@ -21,7 +21,7 @@
 "`P0551R3 `__","LWG","Thou Shalt Not Specialize 
``std``\  Function Templates!","Jacksonville","|Complete|","11.0"
 "`P0753R2 `__","LWG","Manipulators for C++ 
Synchronized Buffered Ostream","Jacksonville","",""
 "`P0754R2 
`__","LWG","","Jacksonville","|Complete|","7.0"
-"`P0809R0 `__","LWG","Comparing Unordered 
Containers","Jacksonville","",""
+"`P0809R0 `__","LWG","Comparing Unordered 
Containers","Jacksonville","|Nothing To Do|",""
 "`P0858R0 `__","LWG","Constexpr iterator 
requirements","Jacksonville","",""
 "`P0905R1 `__","CWG","Symmetry for 
spaceship","Jacksonville","",""
 "`P0966R1 `__","LWG","``string::reserve``\  Should 
Not Shrink","Jacksonville","|Complete| [#note-P0966]_","12.0"



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 3c8e31e - [libc++] ADL-proof by adding _VSTD:: qualification on calls.

2020-12-14 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-14T12:08:34-05:00
New Revision: 3c8e31e17b85c3d24ade9053d56c1998b4dd28cd

URL: 
https://github.com/llvm/llvm-project/commit/3c8e31e17b85c3d24ade9053d56c1998b4dd28cd
DIFF: 
https://github.com/llvm/llvm-project/commit/3c8e31e17b85c3d24ade9053d56c1998b4dd28cd.diff

LOG: [libc++] ADL-proof  by adding _VSTD:: qualification on calls.

- std::reference_wrapper
- std::function
- std::mem_fn

While I'm here, remove _VSTD:: qualification from calls to `declval`
because it takes no arguments and thus isn't susceptible to ADL.

Differential Revision: https://reviews.llvm.org/D92884

Added: 

libcxx/test/std/utilities/function.objects/func.memfn/robust_against_adl.pass.cpp

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/robust_against_adl.pass.cpp

libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/robust_against_adl.pass.cpp

Modified: 
libcxx/include/__functional_base
libcxx/include/__functional_base_03
libcxx/include/functional

Removed: 




diff  --git a/libcxx/include/__functional_base 
b/libcxx/include/__functional_base
index f591bf5a9dce..c84e7eb11567 100644
--- a/libcxx/include/__functional_base
+++ b/libcxx/include/__functional_base
@@ -298,7 +298,7 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) 
const volatile>
 template 
 struct __invoke_return
 {
-typedef decltype(__invoke(_VSTD::declval<_Tp>(), 
_VSTD::declval<_Args>()...)) type;
+typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) 
type;
 };
 
 #else // defined(_LIBCPP_CXX03_LANG)
@@ -314,27 +314,27 @@ struct __invoke_void_return_wrapper
 #ifndef _LIBCPP_CXX03_LANG
 template 
 static _Ret __call(_Args&&... __args) {
-return __invoke(_VSTD::forward<_Args>(__args)...);
+return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
 }
 #else
 template 
 static _Ret __call(_Fn __f) {
-return __invoke(__f);
+return _VSTD::__invoke(__f);
 }
 
 template 
 static _Ret __call(_Fn __f, _A0& __a0) {
-return __invoke(__f, __a0);
+return _VSTD::__invoke(__f, __a0);
 }
 
 template 
 static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
-return __invoke(__f, __a0, __a1);
+return _VSTD::__invoke(__f, __a0, __a1);
 }
 
 template 
 static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
-return __invoke(__f, __a0, __a1, __a2);
+return _VSTD::__invoke(__f, __a0, __a1, __a2);
 }
 #endif
 };
@@ -345,27 +345,27 @@ struct __invoke_void_return_wrapper
 #ifndef _LIBCPP_CXX03_LANG
 template 
 static void __call(_Args&&... __args) {
-__invoke(_VSTD::forward<_Args>(__args)...);
+_VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
 }
 #else
 template 
 static void __call(_Fn __f) {
-__invoke(__f);
+_VSTD::__invoke(__f);
 }
 
 template 
 static void __call(_Fn __f, _A0& __a0) {
-__invoke(__f, __a0);
+_VSTD::__invoke(__f, __a0);
 }
 
 template 
 static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
-__invoke(__f, __a0, __a1);
+_VSTD::__invoke(__f, __a0, __a1);
 }
 
 template 
 static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
-__invoke(__f, __a0, __a1, __a2);
+_VSTD::__invoke(__f, __a0, __a1, __a2);
 }
 #endif
 };
@@ -398,112 +398,112 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 typename __invoke_of::type
 operator() (_ArgTypes&&... __args) const {
-return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
+return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
 }
 #else
 
 _LIBCPP_INLINE_VISIBILITY
 typename __invoke_return::type
 operator() () const {
-return __invoke(get());
+return _VSTD::__invoke(get());
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 typename __invoke_return0::type
 operator() (_A0& __a0) const {
-return __invoke(get(), __a0);
+return _VSTD::__invoke(get(), __a0);
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 typename __invoke_return0::type
 operator() (_A0 const& __a0) const {
-return __invoke(get(), __a0);
+return _VSTD::__invoke(get(), __a0);
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 typename __invoke_return1::type
 operator() (_A0& __a0, _A1& __a1) const {
-return __invoke(get(), __a0, __a1);
+return _VSTD::__invoke(get(), __a0, __a1);
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 typename __invoke_return1::type
 operator() (_A0 const& __a0, _A1& __a1) const {
-return __invoke(get(), __a0, __a1);
+return _VSTD::__invoke(get(), __a0, __a1);
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 typename __invoke_return1::type
 operator() (_A0

[llvm-branch-commits] [libcxx] be4c657 - [libc++] Consistently replace `::new(__p) T` with `::new ((void*)__p) T`. NFCI.

2020-12-14 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-14T12:08:34-05:00
New Revision: be4c657b010c3fd850ca5cfcee0f96b464740523

URL: 
https://github.com/llvm/llvm-project/commit/be4c657b010c3fd850ca5cfcee0f96b464740523
DIFF: 
https://github.com/llvm/llvm-project/commit/be4c657b010c3fd850ca5cfcee0f96b464740523.diff

LOG: [libc++] Consistently replace `::new(__p) T` with `::new ((void*)__p) T`. 
NFCI.

Everywhere, normalize the whitespace to `::new (EXPR) T`.
Everywhere, normalize the spelling of the cast to `(void*)EXPR`.

Without the cast to `(void*)`, the expression triggers ADL on GCC.
(I think this is a GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98249)
Even if it doesn't trigger ADL, it still seems incorrect to use any argument
that's not exactly `(void*)` because that opens the possibility of overload
resolution picking a user-defined overload of `operator new`, which would be
wrong.

Differential Revision: https://reviews.llvm.org/D93153

Added: 
libcxx/test/std/algorithms/robust_against_adl_on_new.pass.cpp

Modified: 
libcxx/include/__debug
libcxx/include/__functional_03
libcxx/include/algorithm
libcxx/include/functional
libcxx/include/future
libcxx/include/memory
libcxx/include/optional
libcxx/include/valarray

Removed: 




diff  --git a/libcxx/include/__debug b/libcxx/include/__debug
index be802755c34a..7b5bfb3f8378 100644
--- a/libcxx/include/__debug
+++ b/libcxx/include/__debug
@@ -221,7 +221,7 @@ public:
 
 template 
 _LIBCPP_INLINE_VISIBILITY static __c_node* __create_C_node(void *__mem, 
void *__c, __c_node *__next) {
-return ::new(__mem) _C_node<_Cont>(__c, __next);
+return ::new (__mem) _C_node<_Cont>(__c, __next);
 }
 
 template 

diff  --git a/libcxx/include/__functional_03 b/libcxx/include/__functional_03
index bf86428dea05..9616480611dc 100644
--- a/libcxx/include/__functional_03
+++ b/libcxx/include/__functional_03
@@ -126,7 +126,7 @@ __func<_Fp, _Alloc, _Rp()>::__clone() const
 _Ap __a(__f_.second());
 typedef __allocator_destructor<_Ap> _Dp;
 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
-::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
 return __hold.release();
 }
 
@@ -134,7 +134,7 @@ template
 void
 __func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const
 {
-::new (__p) __func(__f_.first(), __f_.second());
+::new ((void*)__p) __func(__f_.first(), __f_.second());
 }
 
 template
@@ -212,7 +212,7 @@ __func<_Fp, _Alloc, _Rp(_A0)>::__clone() const
 _Ap __a(__f_.second());
 typedef __allocator_destructor<_Ap> _Dp;
 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
-::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
 return __hold.release();
 }
 
@@ -220,7 +220,7 @@ template
 void
 __func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const
 {
-::new (__p) __func(__f_.first(), __f_.second());
+::new ((void*)__p) __func(__f_.first(), __f_.second());
 }
 
 template
@@ -298,7 +298,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const
 _Ap __a(__f_.second());
 typedef __allocator_destructor<_Ap> _Dp;
 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
-::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
 return __hold.release();
 }
 
@@ -306,7 +306,7 @@ template
 void
 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const
 {
-::new (__p) __func(__f_.first(), __f_.second());
+::new ((void*)__p) __func(__f_.first(), __f_.second());
 }
 
 template
@@ -384,7 +384,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const
 _Ap __a(__f_.second());
 typedef __allocator_destructor<_Ap> _Dp;
 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
-::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
 return __hold.release();
 }
 
@@ -392,7 +392,7 @@ template
 void
 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* 
__p) const
 {
-::new (__p) __func(__f_.first(), __f_.second());
+::new ((void*)__p) __func(__f_.first(), __f_.second());
 }
 
 template
@@ -554,7 +554,7 @@ function<_Rp()>::function(_Fp __f,
 if (sizeof(_FF) <= sizeof(__buf_))
 {
 __f_ = (__base*)&__buf_;
-::new (__f_) _FF(__f);
+::new ((void*)__f_) _FF(__f);
 }
 else
 {
@@ -562,7 +562,7 @@ function<_Rp()>::function(_Fp __f,
 _Ap __a;
 typedef __allocator_destructor<_Ap> _Dp;
 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
-::new (__hold.get()) _FF(

[llvm-branch-commits] [clang] 22cf54a - Replace `T(x)` with `reinterpret_cast(x)` everywhere it means reinterpret_cast. NFC.

2020-12-22 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-22T19:54:29-05:00
New Revision: 22cf54a7fba670642c121684ac3c7ff7e35dfa5c

URL: 
https://github.com/llvm/llvm-project/commit/22cf54a7fba670642c121684ac3c7ff7e35dfa5c
DIFF: 
https://github.com/llvm/llvm-project/commit/22cf54a7fba670642c121684ac3c7ff7e35dfa5c.diff

LOG: Replace `T(x)` with `reinterpret_cast(x)` everywhere it means 
reinterpret_cast. NFC.

Differential Revision: https://reviews.llvm.org/D76572

Added: 


Modified: 
clang/lib/CodeGen/CGCall.h
llvm/include/llvm/IR/SymbolTableListTraits.h
llvm/include/llvm/Object/Binary.h
llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
llvm/lib/Object/COFFObjectFile.cpp
llvm/lib/Object/ELFObjectFile.cpp
llvm/lib/Object/XCOFFObjectFile.cpp
llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h
index 509ca43a9784..e3d9fec6d363 100644
--- a/clang/lib/CodeGen/CGCall.h
+++ b/clang/lib/CodeGen/CGCall.h
@@ -110,7 +110,8 @@ class CGCallee {
   /// Construct a callee.  Call this constructor directly when this
   /// isn't a direct call.
   CGCallee(const CGCalleeInfo &abstractInfo, llvm::Value *functionPtr)
-  : KindOrFunctionPointer(SpecialKind(uintptr_t(functionPtr))) {
+  : KindOrFunctionPointer(
+SpecialKind(reinterpret_cast(functionPtr))) {
 AbstractInfo = abstractInfo;
 assert(functionPtr && "configuring callee without function pointer");
 assert(functionPtr->getType()->isPointerTy());
@@ -186,7 +187,8 @@ class CGCallee {
   }
   void setFunctionPointer(llvm::Value *functionPtr) {
 assert(isOrdinary());
-KindOrFunctionPointer = SpecialKind(uintptr_t(functionPtr));
+KindOrFunctionPointer =
+SpecialKind(reinterpret_cast(functionPtr));
   }
 
   bool isVirtual() const {

diff  --git a/llvm/include/llvm/IR/SymbolTableListTraits.h 
b/llvm/include/llvm/IR/SymbolTableListTraits.h
index 5b793e5dbf28..8af712374bfa 100644
--- a/llvm/include/llvm/IR/SymbolTableListTraits.h
+++ b/llvm/include/llvm/IR/SymbolTableListTraits.h
@@ -76,9 +76,11 @@ class SymbolTableListTraits : public 
ilist_alloc_traits {
   /// getListOwner - Return the object that owns this list.  If this is a list
   /// of instructions, it returns the BasicBlock that owns them.
   ItemParentClass *getListOwner() {
-size_t Offset(size_t(&((ItemParentClass*)nullptr->*ItemParentClass::
-   
getSublistAccess(static_cast(nullptr);
-ListTy *Anchor(static_cast(this));
+size_t Offset = reinterpret_cast(
+&((ItemParentClass *)nullptr->*ItemParentClass::getSublistAccess(
+   static_cast(
+   nullptr;
+ListTy *Anchor = static_cast(this);
 return reinterpret_cast(reinterpret_cast(Anchor)-
   Offset);
   }

diff  --git a/llvm/include/llvm/Object/Binary.h 
b/llvm/include/llvm/Object/Binary.h
index e12e512d68b8..dd98e1143e25 100644
--- a/llvm/include/llvm/Object/Binary.h
+++ b/llvm/include/llvm/Object/Binary.h
@@ -165,8 +165,8 @@ class Binary {
   static Error checkOffset(MemoryBufferRef M, uintptr_t Addr,
const uint64_t Size) {
 if (Addr + Size < Addr || Addr + Size < Size ||
-Addr + Size > uintptr_t(M.getBufferEnd()) ||
-Addr < uintptr_t(M.getBufferStart())) {
+Addr + Size > reinterpret_cast(M.getBufferEnd()) ||
+Addr < reinterpret_cast(M.getBufferStart())) {
   return errorCodeToError(object_error::unexpected_eof);
 }
 return Error::success();

diff  --git a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp 
b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
index 8fa83f515910..354b638b47a2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
@@ -145,9 +145,10 @@ void OcamlGCMetadataPrinter::finishAssembly(Module &M, 
GCModuleInfo &Info,
   report_fatal_error("Function '" + FI.getFunction().getName() +
  "' is too large for the ocaml GC! "
  "Frame size " +
- Twine(FrameSize) + ">= 65536.\n"
-"(" +
- Twine(uintptr_t(&FI)) + ")");
+ Twine(FrameSize) +
+ ">= 65536.\n"
+ "(" +
+ Twine(reinterpret_cast(&FI)) + ")");
 }
 
 AP.OutStreamer->AddComment("live roots for " +

diff  --git a/llvm/lib/Object/COFFObjectFile.cpp 
b/llvm/lib/Object/COFFObjectFile.cpp
index c0902597fadf..2e44a38ccdaa 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -57,7 +57,7 @@ static bool checkSize(MemoryBufferRef M, std::error_code &EC,

[llvm-branch-commits] [libcxx] bbf8a9c - [libc++] ADL-proof by adding _VSTD:: qualification on calls.

2020-11-25 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-11-25T09:19:37-05:00
New Revision: bbf8a9ca3ffedb7059194086bac490b6171cc474

URL: 
https://github.com/llvm/llvm-project/commit/bbf8a9ca3ffedb7059194086bac490b6171cc474
DIFF: 
https://github.com/llvm/llvm-project/commit/bbf8a9ca3ffedb7059194086bac490b6171cc474.diff

LOG: [libc++] ADL-proof  by adding _VSTD:: qualification on calls.

Differential Revision: https://reviews.llvm.org/D92036

Added: 
libcxx/test/std/utilities/variant/variant.visit/robust_against_adl.pass.cpp

Modified: 
libcxx/include/variant

Removed: 




diff  --git a/libcxx/include/variant b/libcxx/include/variant
index cb92a69d14d1..3621f2c68f52 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -491,7 +491,7 @@ private:
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
-return __invoke_constexpr(
+return _VSTD::__invoke_constexpr(
 static_cast<_Fp>(__f),
 __access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...);
 }
@@ -599,7 +599,7 @@ private:
   __std_visit_exhaustive_visitor_check<
   _Visitor,
   decltype((_VSTD::forward<_Alts>(__alts).__value))...>();
-  return __invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
+  return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
 _VSTD::forward<_Alts>(__alts).__value...);
 }
 _Visitor&& __visitor;

diff  --git 
a/libcxx/test/std/utilities/variant/variant.visit/robust_against_adl.pass.cpp 
b/libcxx/test/std/utilities/variant/variant.visit/robust_against_adl.pass.cpp
new file mode 100644
index ..af3cd759dbef
--- /dev/null
+++ 
b/libcxx/test/std/utilities/variant/variant.visit/robust_against_adl.pass.cpp
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+// Throwing bad_variant_access is supported starting in macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12 && !no-exceptions
+// XFAIL: with_system_cxx_lib=macosx10.11 && !no-exceptions
+// XFAIL: with_system_cxx_lib=macosx10.10 && !no-exceptions
+// XFAIL: with_system_cxx_lib=macosx10.9 && !no-exceptions
+
+// 
+// template 
+// constexpr see below visit(Visitor&& vis, Variants&&... vars);
+
+#include 
+
+#include "test_macros.h"
+
+struct Incomplete;
+template struct Holder { T t; };
+
+constexpr bool test(bool do_it)
+{
+if (do_it) {
+std::variant*, int> v = nullptr;
+std::visit([](auto){}, v);
+std::visit([](auto) -> Holder* { return nullptr; }, v);
+}
+return true;
+}
+
+int main(int, char**)
+{
+test(true);
+#if TEST_STD_VER > 17
+static_assert(test(true));
+#endif
+return 0;
+}



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 03ee461 - [libc++] Consistently unparenthesize `numeric_limits::max`. NFCI.

2020-11-27 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-11-27T17:27:36-05:00
New Revision: 03ee46127621934c030d37f50aaefdef6bf9d4b0

URL: 
https://github.com/llvm/llvm-project/commit/03ee46127621934c030d37f50aaefdef6bf9d4b0
DIFF: 
https://github.com/llvm/llvm-project/commit/03ee46127621934c030d37f50aaefdef6bf9d4b0.diff

LOG: [libc++] Consistently unparenthesize `numeric_limits::max`. NFCI.

I think people were sometimes parenthesizing `(foo::max)()` out of
misplaced concern that an unparenthesized `foo::max()` would trip up
Windows' `max(a,b)` macro. However, this is not the case: `max(a,b)`
should be tripped up only by an unparenthesized call to `foo::max(a,b)`,
and in fact we already do `_VSTD::max(a,b)` all over the place anyway
without any guards.

However, in order to do it without guards, we must also
wrap the header in _LIBCPP_PUSH_MACROS, which  was not.

Differential Revision: https://reviews.llvm.org/D92240

Added: 


Modified: 
libcxx/include/charconv
libcxx/include/span

Removed: 




diff  --git a/libcxx/include/charconv b/libcxx/include/charconv
index c830457154d7..4664f5b1d034 100644
--- a/libcxx/include/charconv
+++ b/libcxx/include/charconv
@@ -207,7 +207,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& 
__r)
 {
 auto __c = __a * __b;
 __r = __c;
-return __c > (numeric_limits::max)();
+return __c > numeric_limits::max();
 }
 
 template 
@@ -216,7 +216,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned 
short& __r)
 {
 auto __c = __a * __b;
 __r = __c;
-return __c > (numeric_limits::max)();
+return __c > numeric_limits::max();
 }
 
 template 
@@ -227,7 +227,7 @@ __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
 #if !defined(_LIBCPP_COMPILER_MSVC)
 return __builtin_mul_overflow(__a, __b, &__r);
 #else
-bool __did = __b && ((numeric_limits<_Tp>::max)() / __b) < __a;
+bool __did = __b && (numeric_limits<_Tp>::max() / __b) < __a;
 __r = __a * __b;
 return __did;
 #endif
@@ -435,7 +435,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, 
_Fn __f, _Ts... __args)
 }
 else
 {
-if (__x <= (__tl::max)())
+if (__x <= __tl::max())
 {
 __value = __x;
 return __r;
@@ -526,7 +526,7 @@ __from_chars_atoi(const char* __first, const char* __last, 
_Tp& __value)
 auto __p = __tx::__read(__first, __last, __a, __b);
 if (__p == __last || !__in_pattern(*__p))
 {
-__output_type __m = (numeric_limits<_Tp>::max)();
+__output_type __m = numeric_limits<_Tp>::max();
 if (__m >= __a && __m - __a >= __b)
 {
 __value = __a + __b;
@@ -581,7 +581,7 @@ __from_chars_integral(const char* __first, const char* 
__last, _Tp& __value,
 
 if (__p == __last || !__in_pattern(*__p, __base))
 {
-if ((__tl::max)() - __a >= __b)
+if (__tl::max() - __a >= __b)
 {
 __value = __a + __b;
 return {__p, {}};

diff  --git a/libcxx/include/span b/libcxx/include/span
index b307c98aee20..4f63d0ac4e1f 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -132,11 +132,14 @@ template
 #pragma GCC system_header
 #endif
 
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER > 17
 
-inline constexpr size_t dynamic_extent = (numeric_limits::max)();
+inline constexpr size_t dynamic_extent = numeric_limits::max();
 template  class span;
 
 
@@ -546,4 +549,6 @@ template
 
 _LIBCPP_END_NAMESPACE_STD
 
+_LIBCPP_POP_MACROS
+
 #endif // _LIBCPP_SPAN



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 530c69e - [libc++] s/constpexr/constexpr/ in some comments. NFC.

2020-11-27 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-11-27T18:53:08-05:00
New Revision: 530c69e9096bc916d38b337105ab44f0961b

URL: 
https://github.com/llvm/llvm-project/commit/530c69e9096bc916d38b337105ab44f0961b
DIFF: 
https://github.com/llvm/llvm-project/commit/530c69e9096bc916d38b337105ab44f0961b.diff

LOG: [libc++] s/constpexr/constexpr/ in some comments. NFC.

Added: 


Modified: 

libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp

libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
libcxx/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
libcxx/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp

libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp

libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
 
b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
index 5622f554078a..831fcf16c028 100644
--- 
a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
+++ 
b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
@@ -9,7 +9,7 @@
 // 
 
 // template 
-// constpexr bool   // constexpr after C++17
+// constexpr bool   // constexpr after C++17
 // is_partitioned(InputIterator first, InputIterator last, Predicate pred);
 
 #include 

diff  --git 
a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
 
b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
index 5da1b8150437..2dc17868f80e 100644
--- 
a/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
+++ 
b/libcxx/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
@@ -9,7 +9,7 @@
 // 
 
 // template
-// constpexr ForwardIterator   // constexpr after C++17
+// constexpr ForwardIterator   // constexpr after C++17
 // partition_point(ForwardIterator first, ForwardIterator last, Predicate 
pred);
 
 #include 

diff  --git 
a/libcxx/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp 
b/libcxx/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
index 5c49878f6a49..126845af046e 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
@@ -9,7 +9,7 @@
 // 
 
 // template 
-// constpexr bool   // constexpr after C++17
+// constexpr bool   // constexpr after C++17
 //   all_of(InputIterator first, InputIterator last, Predicate pred);
 
 #include 

diff  --git 
a/libcxx/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp 
b/libcxx/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp
index 22ae581d64b0..cdd7b8a53328 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp
@@ -9,7 +9,7 @@
 // 
 
 // template 
-// constpexr bool   // constexpr after C++17
+// constexpr bool   // constexpr after C++17
 //   any_of(InputIterator first, InputIterator last, Predicate pred);
 
 #include 

diff  --git 
a/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp
 
b/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp
index 08e08f672aed..b90aaf7f63fe 100644
--- 
a/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp
+++ 
b/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp
@@ -13,7 +13,7 @@
 // && OutputIterator
 // && HasLess
 // && HasLess
-//   constpexr OutIter   // constexpr after C++17
+//   constexpr OutIter   // constexpr after C++17
 //   set_intersection(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 
last2,
 //OutIter result);
 

diff  --git 
a/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp
 
b/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp
index acdd7b0191b7..b1796df78dd7 100644
--- 
a/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp
+++ 
b/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp
@@ -14,7 +14,7 @@
 // && OutputIterator
 // && Predicate
 // && Predi

[llvm-branch-commits] [libcxx] c3e15b3 - [libc++] Support simply `std::iterator_traits` in the iterator_traits test.

2020-12-01 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-01T22:13:39-05:00
New Revision: c3e15b3c1c1cb52c83686812a7640e1dd809d695

URL: 
https://github.com/llvm/llvm-project/commit/c3e15b3c1c1cb52c83686812a7640e1dd809d695
DIFF: 
https://github.com/llvm/llvm-project/commit/c3e15b3c1c1cb52c83686812a7640e1dd809d695.diff

LOG: [libc++] Support simply `std::iterator_traits` in the iterator_traits test.

This follows on from D56698. I copied this fix (simpler than D92142's)
from commit 66e6e37447b183b1c8bac9330a4658530d2d49e6.

Differential Revision: https://reviews.llvm.org/D92239

Added: 


Modified: 
libcxx/test/std/iterators/iterator.primitives/iterator.traits/empty.fail.cpp

Removed: 




diff  --git 
a/libcxx/test/std/iterators/iterator.primitives/iterator.traits/empty.fail.cpp 
b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/empty.fail.cpp
index 2c75fc8aebf9..5ab7f05c5392 100644
--- 
a/libcxx/test/std/iterators/iterator.primitives/iterator.traits/empty.fail.cpp
+++ 
b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/empty.fail.cpp
@@ -67,56 +67,56 @@ int main(int, char**)
 {
 {
 typedef std::iterator_traits T;
-typedef T::
diff erence_type   DT; // expected-error-re {{no type named '
diff erence_type' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::value_typeVT; // expected-error-re {{no type named 
'value_type' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::pointer   PT; // expected-error-re {{no type named 
'pointer' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::reference RT; // expected-error-re {{no type named 
'reference' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::iterator_category CT; // expected-error-re {{no type named 
'iterator_category' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
+typedef T::
diff erence_type   DT; // expected-error-re {{no type named '
diff erence_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
+typedef T::value_typeVT; // expected-error-re {{no type named 
'value_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
+typedef T::pointer   PT; // expected-error-re {{no type named 
'pointer' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
+typedef T::reference RT; // expected-error-re {{no type named 
'reference' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
+typedef T::iterator_category CT; // expected-error-re {{no type named 
'iterator_category' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
 }
 
 {
 typedef std::iterator_traits T;
-typedef T::
diff erence_type   DT; // expected-error-re {{no type named '
diff erence_type' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::value_typeVT; // expected-error-re {{no type named 
'value_type' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::pointer   PT; // expected-error-re {{no type named 
'pointer' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::reference RT; // expected-error-re {{no type named 
'reference' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::iterator_category CT; // expected-error-re {{no type named 
'iterator_category' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
+typedef T::
diff erence_type   DT; // expected-error-re {{no type named '
diff erence_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
+typedef T::value_typeVT; // expected-error-re {{no type named 
'value_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
+typedef T::pointer   PT; // expected-error-re {{no type named 
'pointer' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
+typedef T::reference RT; // expected-error-re {{no type named 
'reference' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
+typedef T::iterator_category CT; // expected-error-re {{no type named 
'iterator_category' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
 }
 
 {
 typedef std::iterator_traits T;
-typedef T::
diff erence_type   DT; // expected-error-re {{no type named '
diff erence_type' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::value_typeVT; // expected-error-re {{no type named 
'value_type' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::pointer   PT; // expected-error-re {{no type named 
'pointer' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::reference RT; // expected-error-re {{no type named 
'reference' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
-typedef T::iterator_category CT; // expected-error-re {{no type named 
'iterator_category' in 'std{{(::.+)?}}::iterator_traits<{{.+}}>}}
+typedef T::
diff erence_type   DT; // expected-error-re {{no type named '
diff erence_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
+typedef T::value_typeVT; // expected-error-re {{no type named 
'value_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
+t

[llvm-branch-commits] [libcxx] 40950a4 - [libc++] ADL-proof , and eliminate `using namespace chrono`.

2020-12-01 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-01T22:13:39-05:00
New Revision: 40950a44b9a6aefe17b130e291f8728b34844bce

URL: 
https://github.com/llvm/llvm-project/commit/40950a44b9a6aefe17b130e291f8728b34844bce
DIFF: 
https://github.com/llvm/llvm-project/commit/40950a44b9a6aefe17b130e291f8728b34844bce.diff

LOG: [libc++] ADL-proof , and eliminate `using namespace chrono`.

Since we know exactly which identifiers we expect to find in `chrono`,
a using-directive seems like massive overkill. Remove the directives
and qualify the names as needed.

One subtle trick here: In two places I replaced `*__p` with `*__p.get()`.
The former is an unqualified call to `operator*` on a class type, which
triggers ADL and breaks the new test. The latter is a call to the
built-in `operator*` on pointers, which specifically
does NOT trigger ADL thanks to [over.match.oper]/1.

Differential Revision: https://reviews.llvm.org/D92243

Added: 

libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/robust_against_adl.pass.cpp

Modified: 
libcxx/include/thread

Removed: 




diff  --git a/libcxx/include/thread b/libcxx/include/thread
index 6eff1800acdb..34e0c2a23916 100644
--- a/libcxx/include/thread
+++ b/libcxx/include/thread
@@ -277,18 +277,18 @@ inline _LIBCPP_INLINE_VISIBILITY
 void
 __thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>)
 {
-__invoke(_VSTD::move(_VSTD::get<1>(__t)), 
_VSTD::move(_VSTD::get<_Indices>(__t))...);
+_VSTD::__invoke(_VSTD::move(_VSTD::get<1>(__t)), 
_VSTD::move(_VSTD::get<_Indices>(__t))...);
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 void* __thread_proxy(void* __vp)
 {
-// _Fp = std::tuple< unique_ptr<__thread_struct>, Functor, Args...>
-std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
-__thread_local_data().set_pointer(_VSTD::get<0>(*__p).release());
+// _Fp = tuple< unique_ptr<__thread_struct>, Functor, Args...>
+unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
+__thread_local_data().set_pointer(_VSTD::get<0>(*__p.get()).release());
 typedef typename __make_tuple_indices::value, 2>::type 
_Index;
-__thread_execute(*__p, _Index());
+_VSTD::__thread_execute(*__p.get(), _Index());
 return nullptr;
 }
 
@@ -300,11 +300,11 @@ thread::thread(_Fp&& __f, _Args&&... __args)
 typedef unique_ptr<__thread_struct> _TSPtr;
 _TSPtr __tsp(new __thread_struct);
 typedef tuple<_TSPtr, typename decay<_Fp>::type, typename 
decay<_Args>::type...> _Gp;
-_VSTD::unique_ptr<_Gp> __p(
-new _Gp(std::move(__tsp),
-__decay_copy(_VSTD::forward<_Fp>(__f)),
-__decay_copy(_VSTD::forward<_Args>(__args))...));
-int __ec = __libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, __p.get());
+unique_ptr<_Gp> __p(
+new _Gp(_VSTD::move(__tsp),
+_VSTD::__decay_copy(_VSTD::forward<_Fp>(__f)),
+_VSTD::__decay_copy(_VSTD::forward<_Args>(__args))...));
+int __ec = _VSTD::__libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, 
__p.get());
 if (__ec == 0)
 __p.release();
 else
@@ -326,7 +326,7 @@ struct __thread_invoke_pair {
 template 
 void* __thread_proxy_cxx03(void* __vp)
 {
-std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
+unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
 __thread_local_data().set_pointer(__p->__tsp_.release());
 (__p->__fn_)();
 return nullptr;
@@ -337,9 +337,9 @@ thread::thread(_Fp __f)
 {
 
 typedef __thread_invoke_pair<_Fp> _InvokePair;
-typedef std::unique_ptr<_InvokePair> _PairPtr;
+typedef unique_ptr<_InvokePair> _PairPtr;
 _PairPtr __pp(new _InvokePair(__f));
-int __ec = __libcpp_thread_create(&__t_, 
&__thread_proxy_cxx03<_InvokePair>, __pp.get());
+int __ec = _VSTD::__libcpp_thread_create(&__t_, 
&__thread_proxy_cxx03<_InvokePair>, __pp.get());
 if (__ec == 0)
 __pp.release();
 else
@@ -360,25 +360,24 @@ template 
 void
 sleep_for(const chrono::duration<_Rep, _Period>& __d)
 {
-using namespace chrono;
-if (__d > duration<_Rep, _Period>::zero())
+if (__d > chrono::duration<_Rep, _Period>::zero())
 {
 #if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__)
 //  GCC's long double const folding is incomplete for IBM128 long doubles.
-_LIBCPP_CONSTEXPR duration _Max = duration(ULLONG_MAX/10ULL) ;
+_LIBCPP_CONSTEXPR chrono::duration _Max = 
chrono::duration(ULLONG_MAX/10ULL) ;
 #else
-_LIBCPP_CONSTEXPR duration _Max = nanoseconds::max();
+_LIBCPP_CONSTEXPR chrono::duration _Max = 
chrono::nanoseconds::max();
 #endif
-nanoseconds __ns;
+chrono::nanoseconds __ns;
 if (__d < _Max)
 {
-__ns = duration_cast(__d);
+__ns = chrono::duration_cast(__d);
 if (__ns < __d)
 ++__ns;
 }

[llvm-branch-commits] [libcxx] d586f92 - [libc++] Consistently replace `std::` qualification with `_VSTD::` or nothing. NFCI.

2020-12-01 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-01T22:13:39-05:00
New Revision: d586f92c9456a972ee475a021525c0522b89587b

URL: 
https://github.com/llvm/llvm-project/commit/d586f92c9456a972ee475a021525c0522b89587b
DIFF: 
https://github.com/llvm/llvm-project/commit/d586f92c9456a972ee475a021525c0522b89587b.diff

LOG: [libc++] Consistently replace `std::` qualification with `_VSTD::` or 
nothing. NFCI.

I used a lot of `git grep` to find places where `std::` was being used
outside of comments and assert-messages. There were three outcomes:

- Qualified function calls, e.g. `std::move` becomes `_VSTD::move`.
This is the most common case.

- Typenames that don't need qualification, e.g. `std::allocator` becomes 
`allocator`.
Leaving these as `_VSTD::allocator` would also be fine, but I decided
that removing the qualification is more consistent with existing practice.

- Names that specifically need un-versioned `std::` qualification,
or that I wasn't sure about. For example, I didn't touch any code in
, , , or any ext/ or experimental/ headers;
and I didn't touch any instances of `std::type_info`.

In some deduction guides, we were accidentally using `class Alloc = typename 
std::allocator`,
despite `std::allocator`'s type-ness not being template-dependent.
Because `std::allocator` is a qualified name, this did parse as we intended;
but what we meant was simply `class Alloc = allocator`.

Differential Revision: https://reviews.llvm.org/D92250

Added: 


Modified: 
libcxx/include/__debug
libcxx/include/__hash_table
libcxx/include/__mutex_base
libcxx/include/__split_buffer
libcxx/include/__string
libcxx/include/__tree
libcxx/include/algorithm
libcxx/include/array
libcxx/include/barrier
libcxx/include/bit
libcxx/include/bitset
libcxx/include/cmath
libcxx/include/compare
libcxx/include/complex
libcxx/include/deque
libcxx/include/filesystem
libcxx/include/forward_list
libcxx/include/functional
libcxx/include/future
libcxx/include/iomanip
libcxx/include/iterator
libcxx/include/list
libcxx/include/memory
libcxx/include/numbers
libcxx/include/numeric
libcxx/include/random
libcxx/include/regex
libcxx/include/string_view
libcxx/include/type_traits
libcxx/include/typeinfo
libcxx/include/unordered_map
libcxx/include/utility
libcxx/include/variant
libcxx/include/vector

Removed: 




diff  --git a/libcxx/include/__debug b/libcxx/include/__debug
index 1829b3279d5a..be802755c34a 100644
--- a/libcxx/include/__debug
+++ b/libcxx/include/__debug
@@ -54,7 +54,7 @@ struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
   __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* 
__m)
 : __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
 
-  _LIBCPP_FUNC_VIS std::string what() const;
+  _LIBCPP_FUNC_VIS string what() const;
 
   const char* __file_;
   int __line_;

diff  --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index a004d59a4a08..96845cbd466f 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -120,7 +120,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 size_t
 __next_hash_pow2(size_t __n)
 {
-return __n < 2 ? __n : (size_t(1) << (std::numeric_limits::digits 
- __libcpp_clz(__n-1)));
+return __n < 2 ? __n : (size_t(1) << (numeric_limits::digits - 
__libcpp_clz(__n-1)));
 }
 
 
@@ -1036,7 +1036,7 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 size_type max_size() const _NOEXCEPT
 {
-return std::min(
+return _VSTD::min(
 __node_traits::max_size(__node_alloc()),
 numeric_limits<
diff erence_type >::max()
 );

diff  --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base
index c54a01994c6c..9c3e933b126a 100644
--- a/libcxx/include/__mutex_base
+++ b/libcxx/include/__mutex_base
@@ -379,12 +379,12 @@ __safe_nanosecond_cast(chrono::duration<_Rep, _Period> 
__d)
 
 using __ratio = ratio_divide<_Period, nano>;
 using __ns_rep = nanoseconds::rep;
-__ns_rep __result_max = std::numeric_limits<__ns_rep>::max();
+__ns_rep __result_max = numeric_limits<__ns_rep>::max();
 if (__d.count() > 0 && __d.count() > __result_max / __ratio::num) {
 return nanoseconds::max();
 }
 
-__ns_rep __result_min = std::numeric_limits<__ns_rep>::min();
+__ns_rep __result_min = numeric_limits<__ns_rep>::min();
 if (__d.count() < 0 && __d.count() < __result_min / __ratio::num) {
 return nanoseconds::min();
 }

diff  --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index b1fbddcc6093..20480d19d31b 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -266,7 +266,7 @@ typename enable_if
 >::type
 __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, 
_ForwardIterator __last)
 {

[llvm-branch-commits] [clang-tools-extra] e181a6a - s/instantate/instantiate/ throughout. NFCI.

2020-12-01 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-01T22:13:40-05:00
New Revision: e181a6aeddc26ef0512b2dba94db6360ba32f2ff

URL: 
https://github.com/llvm/llvm-project/commit/e181a6aeddc26ef0512b2dba94db6360ba32f2ff
DIFF: 
https://github.com/llvm/llvm-project/commit/e181a6aeddc26ef0512b2dba94db6360ba32f2ff.diff

LOG: s/instantate/instantiate/ throughout. NFCI.

The static_assert in "libcxx/include/memory" was the main offender here,
but then I figured I might as well `git grep -i instantat` and fix all
the instances I found. One was in user-facing HTML documentation;
the rest were in comments or tests.

Added: 


Modified: 
clang-tools-extra/clangd/Diagnostics.cpp
clang/docs/LibASTMatchersReference.html
clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
clang/test/Modules/Inputs/cxx-irgen-top.h
clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
libcxx/include/memory
llvm/include/llvm/ADT/simple_ilist.h
llvm/lib/Support/SmallVector.cpp
llvm/test/tools/llvm-cov/cov-comdat.test

Removed: 




diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index a4429a7c9452..db4e2e61b86c 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -186,7 +186,7 @@ const char *getMainFileRange(const Diag &D, const 
SourceManager &SM,
 
 // Place the diagnostic the main file, rather than the header, if possible:
 //   - for errors in included files, use the #include location
-//   - for errors in template instantiation, use the instantation location
+//   - for errors in template instantiation, use the instantiation location
 // In both cases, add the original header location as a note.
 bool tryMoveToMainFile(Diag &D, FullSourceLoc DiagLoc) {
   const SourceManager &SM = DiagLoc.getManager();

diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index 9f14ab9f4c5b..203840c214a2 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -89,7 +89,7 @@ Traverse Mode
 from an AST matcher.
 
 
-In addition, because template instantations are matched in the default mode,
+In addition, because template instantiations are matched in the default 
mode,
 transformations can be accidentally made to template declarations. Finally,
 because implicit nodes are matched by default, transformations can be made on
 entirely incorrect places in the code.

diff  --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp 
b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
index 2bb75df7ac6a..7a570e07c212 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
@@ -115,7 +115,7 @@ namespace p5 {
   template void double_capture(NonConstCopy&);
 }
 
-namespace NonLocalLambdaInstantation {
+namespace NonLocalLambdaInstantiation {
   template
   struct X {
 static int value;
@@ -139,7 +139,7 @@ namespace NonLocalLambdaInstantation {
   }
 
   template
-  struct X2 { // expected-note{{in instantiation of default member initializer 
'NonLocalLambdaInstantation::X2::x'}}
+  struct X2 { // expected-note{{in instantiation of default member initializer 
'NonLocalLambdaInstantiation::X2::x'}}
 int x = []{ return T(); }(); // expected-error{{cannot initialize a member 
subobject of type 'int' with an rvalue of type 'int *'}}
   };
 

diff  --git a/clang/test/Modules/Inputs/cxx-irgen-top.h 
b/clang/test/Modules/Inputs/cxx-irgen-top.h
index f1a0bee21250..262a0fa556d9 100644
--- a/clang/test/Modules/Inputs/cxx-irgen-top.h
+++ b/clang/test/Modules/Inputs/cxx-irgen-top.h
@@ -36,7 +36,7 @@ namespace ImplicitSpecialMembers {
 namespace OperatorDeleteLookup {
   struct A { void operator delete(void*); virtual ~A() = default; };
   template struct B { void operator delete(void*); virtual ~B() {} 
typedef int t; };
-  typedef B::t b_int_instantated;
+  typedef B::t b_int_instantiated;
 }
 
 namespace EmitInlineMethods {

diff  --git a/clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp 
b/clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
index 8a0c960acd9e..2f00ad2d237b 100644
--- a/clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
+++ b/clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
@@ -675,7 +675,7 @@ int foo()
 f(x, c);
 f(y, c);
 int i = x;
-// This use will always be an error regardless of instantatiation
+// This use will always be an error regardless of instantiation
 // so diagnose this early.
 const int &r = x; //expected-error{{variable}}
   };

diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 6066aba4f716..17e1bbe102df 100644
--- a/clang/unitt

[llvm-branch-commits] [libcxx] d430330 - [libc++] Update and normalize the "all the headers" tests.

2020-12-03 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-03T15:01:38-05:00
New Revision: d430330788c646afcb2c32c8f24c63210b518a32

URL: 
https://github.com/llvm/llvm-project/commit/d430330788c646afcb2c32c8f24c63210b518a32
DIFF: 
https://github.com/llvm/llvm-project/commit/d430330788c646afcb2c32c8f24c63210b518a32.diff

LOG: [libc++] Update and normalize the "all the headers" tests.

Some C++20 headers weren't added properly to all three of these
test files. Add them, and take the time to normalize the formatting
so that

diff <(grep '#include' foo.cpp) <(grep '#include' bar.cpp)

shows no diffs (except that `no_assert_include` deliberately
excludes ``).

- Add macro guards to <{barrier,latch,semaphore}>.
- Add macro guards to .
- Remove an include of  from .
- Instead, include  in the semaphore tests.

Differential Revision: https://reviews.llvm.org/D92525

Added: 


Modified: 
libcxx/include/barrier
libcxx/include/experimental/simd
libcxx/include/latch
libcxx/include/semaphore
libcxx/test/libcxx/double_include.sh.cpp
libcxx/test/libcxx/min_max_macros.compile.pass.cpp
libcxx/test/libcxx/no_assert_include.compile.pass.cpp
libcxx/test/std/thread/thread.semaphore/timed.pass.cpp
libcxx/test/std/thread/thread.semaphore/try_acquire.pass.cpp

Removed: 




diff  --git a/libcxx/include/barrier b/libcxx/include/barrier
index 987ff0aa5c1d..ba9e8ea9bb84 100644
--- a/libcxx/include/barrier
+++ b/libcxx/include/barrier
@@ -58,6 +58,9 @@ namespace std
 # error  is not supported on this single threaded system
 #endif
 
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
 #if _LIBCPP_STD_VER >= 14
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -320,4 +323,6 @@ _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP_STD_VER >= 14
 
+_LIBCPP_POP_MACROS
+
 #endif //_LIBCPP_BARRIER

diff  --git a/libcxx/include/experimental/simd 
b/libcxx/include/experimental/simd
index 39ac35e4eb0a..41f8f799a0b0 100644
--- a/libcxx/include/experimental/simd
+++ b/libcxx/include/experimental/simd
@@ -659,6 +659,9 @@ public:
 #pragma GCC system_header
 #endif
 
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD
 
 #if _LIBCPP_STD_VER >= 17
@@ -1566,4 +1569,6 @@ public:
 
 _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
 
+_LIBCPP_POP_MACROS
+
 #endif /* _LIBCPP_EXPERIMENTAL_SIMD */

diff  --git a/libcxx/include/latch b/libcxx/include/latch
index 67fca97ac778..b338f091316c 100644
--- a/libcxx/include/latch
+++ b/libcxx/include/latch
@@ -50,6 +50,9 @@ namespace std
 # error  is not supported on this single threaded system
 #endif
 
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
 #if _LIBCPP_STD_VER >= 14
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -102,4 +105,6 @@ _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP_STD_VER >= 14
 
+_LIBCPP_POP_MACROS
+
 #endif //_LIBCPP_LATCH

diff  --git a/libcxx/include/semaphore b/libcxx/include/semaphore
index 8f6316273bff..0943606e93d2 100644
--- a/libcxx/include/semaphore
+++ b/libcxx/include/semaphore
@@ -49,7 +49,6 @@ using binary_semaphore = counting_semaphore<1>;
 #include <__availability>
 #include <__threading_support>
 #include 
-#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -59,6 +58,9 @@ using binary_semaphore = counting_semaphore<1>;
 # error  is not supported on this single threaded system
 #endif
 
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
 #if _LIBCPP_STD_VER >= 14
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -233,4 +235,6 @@ _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP_STD_VER >= 14
 
+_LIBCPP_POP_MACROS
+
 #endif //_LIBCPP_SEMAPHORE

diff  --git a/libcxx/test/libcxx/double_include.sh.cpp 
b/libcxx/test/libcxx/double_include.sh.cpp
index ba571e1d6283..39851cc379d4 100644
--- a/libcxx/test/libcxx/double_include.sh.cpp
+++ b/libcxx/test/libcxx/double_include.sh.cpp
@@ -30,9 +30,9 @@
 #include 
 #ifndef _LIBCPP_HAS_NO_THREADS
 #include 
-#include 
+#endif
+#ifndef _LIBCPP_HAS_NO_THREADS
 #include 
-#include 
 #endif
 #include 
 #include 
@@ -83,6 +83,9 @@
 #include 
 #include 
 #include 
+#ifndef _LIBCPP_HAS_NO_THREADS
+#include 
+#endif
 #include 
 #include 
 #include 
@@ -100,6 +103,9 @@
 #include 
 #include 
 #include 
+#ifndef _LIBCPP_HAS_NO_THREADS
+#include 
+#endif
 #include 
 #include 
 #ifndef _LIBCPP_HAS_NO_THREADS
@@ -170,8 +176,8 @@
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 

diff  --git a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp 
b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
index 7c1956b7476f..da7e857fc6ff 100644
--- a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
+++ b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
@@ -33,6 +33,12 @@ TEST_MACROS();
 #include 
 TEST_MACROS();
 #endif
+#ifndef _LIBCPP_HAS_NO_THREADS
+#include 
+TEST_MACROS();
+#endif
+#include 
+TEST_MACROS();
 #include 
 TEST_MACROS();
 #include 
@@ -59,10 +65,14 @@ TEST_MACROS();
 TES

[llvm-branch-commits] [libcxx] c75c654 - [libc++] Slightly improve constexpr test coverage for std::includes.

2020-12-04 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-04T17:53:53-05:00
New Revision: c75c6549ba7cadbbd51cae88d4ed286a6290a66b

URL: 
https://github.com/llvm/llvm-project/commit/c75c6549ba7cadbbd51cae88d4ed286a6290a66b
DIFF: 
https://github.com/llvm/llvm-project/commit/c75c6549ba7cadbbd51cae88d4ed286a6290a66b.diff

LOG: [libc++] Slightly improve constexpr test coverage for std::includes.

Differential Revision: https://reviews.llvm.org/D92255

Added: 


Modified: 

libcxx/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp

libcxx/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp
 
b/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp
index f8e8884085de..790b93c5ada5 100644
--- 
a/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp
+++ 
b/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp
@@ -20,21 +20,9 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
-#if TEST_STD_VER > 17
-TEST_CONSTEXPR bool test_constexpr() {
-int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
-int ib[] = {2, 4};
-int ic[] = {3, 3, 3, 3};
-
-return  std::includes(std::begin(ia), std::end(ia), std::begin(ib), 
std::end(ib))
-&& !std::includes(std::begin(ia), std::end(ia), std::begin(ic), 
std::end(ic))
-   ;
-}
-#endif
-
 template 
-void
-test()
+TEST_CONSTEXPR_CXX20
+void test()
 {
 int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
@@ -62,7 +50,8 @@ test()
 assert(!std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+4)));
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20
+bool do_tests()
 {
 test, input_iterator >();
 test, forward_iterator >();
@@ -94,9 +83,14 @@ int main(int, char**)
 test >();
 test();
 
+return true;
+}
+
+int main(int, char**)
+{
+do_tests();
 #if TEST_STD_VER > 17
-   static_assert(test_constexpr());
+static_assert(do_tests());
 #endif
-
-  return 0;
+return 0;
 }

diff  --git 
a/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp
 
b/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp
index 48bafcb3a84c..8c54f0df0f1c 100644
--- 
a/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp
+++ 
b/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp
@@ -21,51 +21,38 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
-#if TEST_STD_VER > 17
-TEST_CONSTEXPR bool test_constexpr() {
-int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
-int ib[] = {2, 4};
-int ic[] = {3, 3, 3, 3};
-
-auto comp = [](int a, int b) {return a < b; };
-return  std::includes(std::begin(ia), std::end(ia), std::begin(ib), 
std::end(ib), comp)
-&& !std::includes(std::begin(ia), std::end(ia), std::begin(ic), 
std::end(ic), comp)
-   ;
-}
-#endif
-
-
 template 
-void
-test()
+TEST_CONSTEXPR_CXX20
+void test()
 {
-int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+int ia[] = {4, 4, 4, 4, 3, 3, 3, 2, 2, 1};
 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
-int ib[] = {2, 4};
+int ib[] = {4, 2};
 const unsigned sb = sizeof(ib)/sizeof(ib[0]);
-int ic[] = {1, 2};
+int ic[] = {2, 1};
 const unsigned sc = sizeof(ic)/sizeof(ic[0]); ((void)sc);
 int id[] = {3, 3, 3, 3};
 const unsigned sd = sizeof(id)/sizeof(id[0]); ((void)sd);
 
-assert(std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib), 
std::less()));
-assert(!std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib+1), 
std::less()));
-assert(std::includes(Iter1(ia), Iter1(ia+1), Iter2(ib), Iter2(ib), 
std::less()));
-assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), 
std::less()));
+assert(std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib), 
std::greater()));
+assert(!std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib+1), 
std::greater()));
+assert(std::includes(Iter1(ia), Iter1(ia+1), Iter2(ib), Iter2(ib), 
std::greater()));
+assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), 
std::greater()));
 
-assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+sb), 
std::less()));
-assert(!std::includes(Iter1(ib), Iter1(ib+sb), Iter2(ia), Iter2(ia+sa), 
std::less()));
+assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+sb), 
std::greater()));
+assert(!std::includes(Iter1(ib), Iter1(ib+sb), Iter2(ia), Iter2(ia+sa), 
std::greater()));
 
-assert(std::includes(Iter1(ia), Iter1(ia+2), Iter2(ic), Iter2(ic+2), 
std::less()));
-assert(!std::includes(Iter1(ia), Iter1(ia+2), Iter2(ib), Iter2(

[llvm-branch-commits] [libcxx] b8bc4e1 - [libc++] Update the commented "synopsis" in to match current reality.

2020-12-04 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-04T17:53:54-05:00
New Revision: b8bc4e153f01002a52ce628ef53486c4396863b3

URL: 
https://github.com/llvm/llvm-project/commit/b8bc4e153f01002a52ce628ef53486c4396863b3
DIFF: 
https://github.com/llvm/llvm-project/commit/b8bc4e153f01002a52ce628ef53486c4396863b3.diff

LOG: [libc++] Update the commented "synopsis" in  to match current 
reality.

The synopsis now reflects what's implemented. It does NOT reflect
all of what's specified in C++20. The "constexpr in C++20" markings
are still missing from these 12 algorithms, because they are still
unimplemented by libc++:

reverse partition sort nth_element next_permutation prev_permutation
push_heap pop_heap make_heap sort_heap partial_sort partial_sort_copy

All of the above algorithms were excluded from [P0202].

All of the above algorithms were made constexpr in [P0879] (along with
swap_ranges, iter_swap, and rotate — we've already implemented those three).

Differential Revision: https://reviews.llvm.org/D92255

Added: 


Modified: 
libcxx/include/algorithm

Removed: 




diff  --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 7ad8ff9a52a4..3bb6c7829bcf 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -47,16 +47,16 @@ template 
 find_if(InputIterator first, InputIterator last, Predicate pred);
 
 template
-InputIterator   // constexpr in C++20
+constexpr InputIterator // constexpr in C++20
 find_if_not(InputIterator first, InputIterator last, Predicate pred);
 
 template 
-ForwardIterator1// constexpr in C++20
+constexpr ForwardIterator1  // constexpr in C++20
 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
  ForwardIterator2 first2, ForwardIterator2 last2);
 
 template 
-ForwardIterator1// constexpr in C++20
+constexpr ForwardIterator1  // constexpr in C++20
 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
  ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate 
pred);
 
@@ -185,11 +185,11 @@ template 
   BidirectionalIterator2 result);
 
 template 
-ForwardIterator2
+constexpr ForwardIterator2// constexpr in C++20
 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, 
ForwardIterator2 first2);
 
 template 
-void
+constexpr void// constexpr in C++20
 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
 
 template 
@@ -251,19 +251,19 @@ template 
 remove_copy_if(InputIterator first, InputIterator last, OutputIterator 
result, Predicate pred);
 
 template 
-ForwardIterator
+constexpr ForwardIterator// constexpr in C++20
 unique(ForwardIterator first, ForwardIterator last);
 
 template 
-ForwardIterator
+constexpr ForwardIterator// constexpr in C++20
 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
 
 template 
-OutputIterator
+constexpr OutputIterator // constexpr in C++20
 unique_copy(InputIterator first, InputIterator last, OutputIterator 
result);
 
 template 
-OutputIterator
+constexpr OutputIterator // constexpr in C++20
 unique_copy(InputIterator first, InputIterator last, OutputIterator 
result, BinaryPredicate pred);
 
 template 
@@ -275,11 +275,11 @@ template 
 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, 
OutputIterator result);
 
 template 
-ForwardIterator
+constexpr ForwardIterator  // constexpr in C++20
 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator 
last);
 
 template 
-OutputIterator
+constexpr OutputIterator   // constexpr in C++20
 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator 
last, OutputIterator result);
 
 template 
@@ -329,7 +329,7 @@ template 
 is_sorted(ForwardIterator first, ForwardIterator last);
 
 template 
-bool
+constexpr bool  // constexpr in C++20
 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
 
 template
@@ -529,82 +529,82 @@ template 
 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, 
Compare comp);
 
 template 
-ForwardIterator
-min_element(ForwardIterator first, ForwardIterator last);  // constexpr in 
C++14
+constexpr ForwardIterator// constexpr in C++14
+min_element(ForwardIterator first, ForwardIterator last);
 
 template 
-ForwardIterator
-min_element(ForwardIterator first, ForwardIterator last, Compare comp);  
// constexpr in C++14
+constexpr ForwardIterator// constexpr in C++14
+min_element(ForwardIterator first, ForwardIterator last, Compare comp);
 
 template 
-const T&
-min(const T& a, const T& b);  // constexpr in C++14
+constexpr const T&   // constexpr in C++14
+min(const T& a, const T& b);
 
 templa

[llvm-branch-commits] [libcxx] c0428b3 - [libc++] ADL-proof . `__convert_to_integral` is not a customization point.

2020-12-08 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-08T11:19:16-05:00
New Revision: c0428b3c0c1f3b78d39ceaf909908800fb7aabe3

URL: 
https://github.com/llvm/llvm-project/commit/c0428b3c0c1f3b78d39ceaf909908800fb7aabe3
DIFF: 
https://github.com/llvm/llvm-project/commit/c0428b3c0c1f3b78d39ceaf909908800fb7aabe3.diff

LOG: [libc++] ADL-proof . `__convert_to_integral` is not a 
customization point.

The interesting change here is that we no longer consider 
`__convert_to_integral`
an ADL customization point for the user's types. I think the new behavior
is defensible. The old behavior had come from D7449, where Marshall explicitly
said "people can't define their own [`__convert_to_integral` overloads]."

Differential Revision: https://reviews.llvm.org/D92814

Added: 

libcxx/test/std/iterators/iterator.primitives/iterator.operations/robust_against_adl.pass.cpp

Modified: 
libcxx/include/algorithm
libcxx/include/iterator

Removed: 




diff  --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 3bb6c7829bcf..7944f9b6e1aa 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -895,7 +895,7 @@ inline _LIBCPP_INLINE_VISIBILITY 
_LIBCPP_CONSTEXPR_AFTER_CXX17
 _InputIterator
 for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
 {
-typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
 _IntegralSize __n = __orig_n;
 while (__n > 0)
 {
@@ -1614,7 +1614,7 @@ search_n(_ForwardIterator __first, _ForwardIterator 
__last,
  _Size __count, const _Tp& __value_, _BinaryPredicate __pred)
 {
 return _VSTD::__search_n::type>
-   (__first, __last, __convert_to_integral(__count), __value_, __pred,
+   (__first, __last, _VSTD::__convert_to_integral(__count), __value_, 
__pred,
typename iterator_traits<_ForwardIterator>::iterator_category());
 }
 
@@ -1625,7 +1625,7 @@ _ForwardIterator
 search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, 
const _Tp& __value_)
 {
 typedef typename iterator_traits<_ForwardIterator>::value_type __v;
-return _VSTD::search_n(__first, __last, __convert_to_integral(__count),
+return _VSTD::search_n(__first, __last, 
_VSTD::__convert_to_integral(__count),
__value_, __equal_to<__v, _Tp>());
 }
 
@@ -1827,7 +1827,7 @@ typename enable_if
 >::type
 copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
 {
-typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
 _IntegralSize __n = __orig_n;
 if (__n > 0)
 {
@@ -1852,7 +1852,7 @@ typename enable_if
 >::type
 copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
 {
-typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
 _IntegralSize __n = __orig_n;
 return _VSTD::copy(__first, __first + __n, __result);
 }
@@ -2057,7 +2057,7 @@ inline _LIBCPP_INLINE_VISIBILITY 
_LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
 {
-   return _VSTD::__fill_n(__first, __convert_to_integral(__n), __value_);
+   return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), 
__value_);
 }
 
 // fill
@@ -2105,7 +2105,7 @@ inline _LIBCPP_INLINE_VISIBILITY 
_LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
 {
-typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
 _IntegralSize __n = __orig_n;
 for (; __n > 0; ++__first, (void) --__n)
 *__first = __gen();

diff  --git a/libcxx/include/iterator b/libcxx/include/iterator
index 90b5f41132d9..3e1fb610821a 100644
--- a/libcxx/include/iterator
+++ b/libcxx/include/iterator
@@ -663,9 +663,9 @@ void advance(_InputIter& __i, _Distance __orig_n)
 {
 _LIBCPP_ASSERT(__orig_n >= 0 || 
__is_cpp17_bidirectional_iterator<_InputIter>::value,
"Attempt to advance(it, n) with negative n on a 
non-bidirectional iterator");
-typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
 _IntegralSize __n = __orig_n;
-__advance(__i, __n, typename 
iterator_traits<_InputIter>::iterator_category());
+_VSTD::__advance(__i, __n, typename 
iterator_traits<_InputIter>::iterator_category());
 }
 
 template 
@@ -692,7 +692,7 @@ inline _LIBCPP_INLINE_VISIBILITY 
_LIBCPP_CONSTEXPR_AFTER_CXX14
 typename iterator_traits<_InputIter>::
diff erence_type
 distance(_InputIter __first, _InputIter __last)
 {
-return __distance(__first, __last, typename 
iterato

[llvm-branch-commits] [libcxx] 1968804 - [libc++] Add _VSTD:: qualifications to ADL-proof .

2020-12-08 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-08T17:05:38-05:00
New Revision: 1968804ac726e7674d5de22bc2204b45857da344

URL: 
https://github.com/llvm/llvm-project/commit/1968804ac726e7674d5de22bc2204b45857da344
DIFF: 
https://github.com/llvm/llvm-project/commit/1968804ac726e7674d5de22bc2204b45857da344.diff

LOG: [libc++] Add _VSTD:: qualifications to ADL-proof .

Relevant blog post: 
https://quuxplusone.github.io/blog/2019/09/26/uglification-doesnt-stop-adl/

Differential Revision: https://reviews.llvm.org/D92776

Added: 
libcxx/test/std/algorithms/robust_against_adl.pass.cpp

Modified: 
libcxx/include/__string
libcxx/include/algorithm
libcxx/include/locale

Removed: 




diff  --git a/libcxx/include/__string b/libcxx/include/__string
index 882be96b4fed..2473e1f1718e 100644
--- a/libcxx/include/__string
+++ b/libcxx/include/__string
@@ -374,7 +374,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) 
_NOEXCEPT
 {
 return __libcpp_is_constant_evaluated()
-   ? __move_constexpr(__s1, __s2, __n)
+   ? _VSTD::__move_constexpr(__s1, __s2, __n)
: __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, 
__n);
 }
 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
@@ -382,14 +382,14 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
 {
 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy 
overlapped range");
 return __libcpp_is_constant_evaluated()
-   ? __copy_constexpr(__s1, __s2, __n)
+   ? _VSTD::__copy_constexpr(__s1, __s2, __n)
: __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
 }
 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
 {
 return __libcpp_is_constant_evaluated()
-   ? __assign_constexpr(__s, __n, __a)
+   ? _VSTD::__assign_constexpr(__s, __n, __a)
: __n == 0 ? __s : (char_type*)memset(__s, 
to_int_type(__a), __n);
 }
 
@@ -477,7 +477,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) 
_NOEXCEPT
 {
 return __libcpp_is_constant_evaluated()
-   ? __move_constexpr(__s1, __s2, __n)
+   ? _VSTD::__move_constexpr(__s1, __s2, __n)
: __n == 0 ? __s1 : wmemmove(__s1, __s2, __n);
 }
 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
@@ -485,14 +485,14 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
 {
 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy 
overlapped range");
 return __libcpp_is_constant_evaluated()
-   ? __copy_constexpr(__s1, __s2, __n)
+   ? _VSTD::__copy_constexpr(__s1, __s2, __n)
: __n == 0 ? __s1 : wmemcpy(__s1, __s2, __n);
 }
 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
 {
 return __libcpp_is_constant_evaluated()
-   ? __assign_constexpr(__s, __n, __a)
+   ? _VSTD::__assign_constexpr(__s, __n, __a)
: __n == 0 ? __s : wmemset(__s, __a, __n);
 }
 static inline _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
@@ -610,7 +610,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
 char_type*   move(char_type* __s1, const char_type* __s2, size_t __n) 
_NOEXCEPT
 {
 return __libcpp_is_constant_evaluated()
-   ? __move_constexpr(__s1, __s2, __n)
+   ? _VSTD::__move_constexpr(__s1, __s2, __n)
: __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, 
__n);
 }
 
@@ -619,7 +619,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
{
 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy 
overlapped range");
 return __libcpp_is_constant_evaluated()
-   ? __copy_constexpr(__s1, __s2, __n)
+   ? _VSTD::__copy_constexpr(__s1, __s2, __n)
: __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
 }
 
@@ -627,7 +627,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
 char_type*   assign(char_type* __s, size_t __n, char_type __a) 
_NOEXCEPT
 {
 return __libcpp_is_constant_evaluated()
-   ? __assign_constexpr(__s, __n, __a)
+   ? _VSTD::__assign_constexpr(__s, __n, __a)
: __n == 0 ? __s : (char_type*)memset(__s, 
to_int_type(__a), __n);
 }
 

diff  --git a/libcxx/

[llvm-branch-commits] [libcxx] 35c3b53 - [libc++] ADL-proof __libcpp_is_nothrow_constructible.

2020-12-08 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-08T17:05:38-05:00
New Revision: 35c3b539438be2d587cbe8f2b9604a68bbe7792b

URL: 
https://github.com/llvm/llvm-project/commit/35c3b539438be2d587cbe8f2b9604a68bbe7792b
DIFF: 
https://github.com/llvm/llvm-project/commit/35c3b539438be2d587cbe8f2b9604a68bbe7792b.diff

LOG: [libc++] ADL-proof __libcpp_is_nothrow_constructible.

The GCC C++20 buildbot hit this ADL call; Clang doesn't,
presumably because it uses a compiler builtin instead of
this codepath in .
https://buildkite.com/llvm-project/libcxx-ci/builds/674

Added: 


Modified: 
libcxx/include/type_traits

Removed: 




diff  --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index cd6a1633df80..2842c905e302 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -1821,7 +1821,7 @@ template 
 static void __test_noexcept(_Tp) noexcept;
 
 template
-static bool_constant(declval<_Fm>()))>
+static bool_constant(declval<_Fm>()))>
 __is_nothrow_convertible_test();
 
 template 
@@ -3293,7 +3293,7 @@ void __implicit_conversion_to(_Tp) noexcept { }
 
 template 
 struct __libcpp_is_nothrow_constructible
-: public integral_constant(declval<_Arg>()))>
+: public integral_constant(declval<_Arg>()))>
 {
 };
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 2130699 - [libc++] Mark my new test unsupported on clang-8.

2020-12-08 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-08T17:25:23-05:00
New Revision: 2130699ba486dd2dd65dd0b61c0dedc6ef9481ac

URL: 
https://github.com/llvm/llvm-project/commit/2130699ba486dd2dd65dd0b61c0dedc6ef9481ac
DIFF: 
https://github.com/llvm/llvm-project/commit/2130699ba486dd2dd65dd0b61c0dedc6ef9481ac.diff

LOG: [libc++] Mark my new  test unsupported on clang-8.

Because in C++20 mode, it tests that `copy_n` is constexpr;
so it depends on the compiler supporting `is_constant_evaluated`.

Added: 


Modified: 
libcxx/test/std/algorithms/robust_against_adl.pass.cpp

Removed: 




diff  --git a/libcxx/test/std/algorithms/robust_against_adl.pass.cpp 
b/libcxx/test/std/algorithms/robust_against_adl.pass.cpp
index fca6f98f8b0a..a9ea46a50c90 100644
--- a/libcxx/test/std/algorithms/robust_against_adl.pass.cpp
+++ b/libcxx/test/std/algorithms/robust_against_adl.pass.cpp
@@ -6,6 +6,7 @@
 //
 
//===--===//
 
+// UNSUPPORTED: clang-8
 // UNSUPPORTED: c++03
 
 // 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] b12ea06 - [libc++] Include C++ headers, not C headers, in .

2020-12-10 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-10T22:03:12-05:00
New Revision: b12ea0652129da3b42642a0b76adbfab8833db53

URL: 
https://github.com/llvm/llvm-project/commit/b12ea0652129da3b42642a0b76adbfab8833db53
DIFF: 
https://github.com/llvm/llvm-project/commit/b12ea0652129da3b42642a0b76adbfab8833db53.diff

LOG: [libc++] Include C++ headers, not C headers, in .

This matches how libc++ does it in all other C++ headers
(that is, headers not ending in ".h").
We need to include  if we want to use `_VSTD::memmove`
instead of unqualified ADL `memmove`. Even though ADL doesn't
physically matter in 's specific case, I'm trying
to migrate libc++ to using `_VSTD::memmove` for all cases
(because some of them do matter, and this way it's easier to
grep for outliers).

Differential Revision: https://reviews.llvm.org/D92875

Added: 


Modified: 
libcxx/include/charconv

Removed: 




diff  --git a/libcxx/include/charconv b/libcxx/include/charconv
index 4664f5b1d034..4666c5c51db6 100644
--- a/libcxx/include/charconv
+++ b/libcxx/include/charconv
@@ -76,11 +76,11 @@ namespace std {
 #include <__config>
 #include <__availability>
 #include <__errc>
-#include 
+#include  // for log2f
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
+#include 
 
 #include <__debug>
 
@@ -333,7 +333,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, 
false_type)
 auto __len = __p - __buf;
 if (__len <= __
diff )
 {
-memcpy(__first, __buf, __len);
+_VSTD::memcpy(__first, __buf, __len);
 return {__first + __len, {}};
 }
 else
@@ -382,7 +382,7 @@ __to_chars_integral(char* __first, char* __last, _Tp 
__value, int __base,
 return {__last, errc::value_too_large};
 else
 {
-memmove(__first, __p, __len);
+_VSTD::memmove(__first, __p, __len);
 return {__first + __len, {}};
 }
 }
@@ -429,7 +429,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, 
_Fn __f, _Ts... __args)
 if (__x <= __complement(__to_unsigned(__tl::min(
 {
 __x = __complement(__x);
-memcpy(&__value, &__x, sizeof(__x));
+_VSTD::memcpy(&__value, &__x, sizeof(__x));
 return __r;
 }
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 3696227 - [libc++] ADL-proof by adding _VSTD:: qualifications to memmove etc.

2020-12-10 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-10T22:03:12-05:00
New Revision: 3696227c10f5e5841223c2a2fb63fdd1d50a7930

URL: 
https://github.com/llvm/llvm-project/commit/3696227c10f5e5841223c2a2fb63fdd1d50a7930
DIFF: 
https://github.com/llvm/llvm-project/commit/3696227c10f5e5841223c2a2fb63fdd1d50a7930.diff

LOG: [libc++] ADL-proof by adding _VSTD:: qualifications to memmove etc.

Generally these calls aren't vulnerable to ADL because they involve only
primitive types. The ones in  and  drag in namespace std
but that's OK; the ones in  and  are vulnerable
iff `CharT` is an enum type, which seems far-fetched.
But absolutely zero of them *need* ADL to happen; so in my opinion
they should all be consistently qualified, just like calls to any
other (non-user-customizable) functions in namespace std.

Also: Include  and  in <__string>.
We seemed to be getting lucky that  included 
included  included . That gave us the
global-namespace `wmemmove`, but not `_VSTD::wmemmove`.
This is now fixed.

I didn't touch these headers:
 uses strlen, safely
 uses memcpy, safely
 uses memchr and strchr, safely
 uses wcschr, safely
<__bsd_locale_fallbacks.h> uses wcsnrtombs, safely

Differential Revision: https://reviews.llvm.org/D93061

Added: 


Modified: 
libcxx/include/__hash_table
libcxx/include/__locale
libcxx/include/__string
libcxx/include/atomic
libcxx/include/fstream
libcxx/include/list
libcxx/include/locale
libcxx/include/string
libcxx/include/strstream
libcxx/include/vector

Removed: 




diff  --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 96845cbd466f..ab45277e20c8 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -1571,7 +1571,7 @@ __hash_table<_Tp, _Hash, _Equal, 
_Alloc>::__deallocate_node(__next_pointer __np)
 {
 (*__p)->__c_ = nullptr;
 if (--__c->end_ != __p)
-memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+_VSTD::memmove(__p, __p+1, (__c->end_ - 
__p)*sizeof(__i_node*));
 }
 }
 __get_db()->unlock();
@@ -2599,7 +2599,7 @@ __hash_table<_Tp, _Hash, _Equal, 
_Alloc>::remove(const_iterator __p) _NOEXCEPT
 {
 (*__dp)->__c_ = nullptr;
 if (--__c->end_ != __dp)
-memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*));
+_VSTD::memmove(__dp, __dp+1, (__c->end_ - 
__dp)*sizeof(__i_node*));
 }
 }
 __get_db()->unlock();

diff  --git a/libcxx/include/__locale b/libcxx/include/__locale
index dda8a75d9046..f32bd59ae585 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -79,7 +79,7 @@ struct __libcpp_locale_guard {
   // locale name, otherwise it will be a semicolon-separated string listing
   // each category.  In the second case, we know at least one category 
won't
   // be what we want, so we only have to check the first case.
-  if (strcmp(__l.__get_locale(), __lc) != 0) {
+  if (_VSTD::strcmp(__l.__get_locale(), __lc) != 0) {
 __locale_all = _strdup(__lc);
 if (__locale_all == nullptr)
   __throw_bad_alloc();

diff  --git a/libcxx/include/__string b/libcxx/include/__string
index 2473e1f1718e..d8b672e4c1be 100644
--- a/libcxx/include/__string
+++ b/libcxx/include/__string
@@ -55,7 +55,9 @@ template <> struct char_traits;  // c++20
 
 #include <__config>
 #include   // for search and min
-#include  // For EOF.
+#include  // for EOF
+#include // for memcpy
+#include  // for wmemcpy
 #include  // for __murmur2_or_cityhash
 
 #include <__debug>
@@ -375,7 +377,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
 {
 return __libcpp_is_constant_evaluated()
? _VSTD::__move_constexpr(__s1, __s2, __n)
-   : __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, 
__n);
+   : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, 
__s2, __n);
 }
 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) 
_NOEXCEPT
@@ -383,14 +385,14 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy 
overlapped range");
 return __libcpp_is_constant_evaluated()
? _VSTD::__copy_constexpr(__s1, __s2, __n)
-   : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
+   : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, 
__s2, __n);
 }
 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
 {
 return __libcpp_is_constant_evaluated()
? _VSTD::__assign_constexpr(__s, __n, __a)
-

[llvm-branch-commits] [libcxx] 1d7c39e - [libc++] s/Birdirectional/Bidirectional/g. NFCI.

2020-12-14 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-14T09:54:57-05:00
New Revision: 1d7c39e14e25ecabeff1007df7c220d871de4719

URL: 
https://github.com/llvm/llvm-project/commit/1d7c39e14e25ecabeff1007df7c220d871de4719
DIFF: 
https://github.com/llvm/llvm-project/commit/1d7c39e14e25ecabeff1007df7c220d871de4719.diff

LOG: [libc++] s/Birdirectional/Bidirectional/g. NFCI.

Added: 


Modified: 
libcxx/include/algorithm

Removed: 




diff  --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 573dc07e0f16..bba8f3ac5199 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -3803,14 +3803,14 @@ __sort5(_ForwardIterator __x1, _ForwardIterator __x2, 
_ForwardIterator __x3,
 }
 
 // Assumes size > 0
-template 
+template 
 void
-__selection_sort(_BirdirectionalIterator __first, _BirdirectionalIterator 
__last, _Compare __comp)
+__selection_sort(_BidirectionalIterator __first, _BidirectionalIterator 
__last, _Compare __comp)
 {
-_BirdirectionalIterator __lm1 = __last;
+_BidirectionalIterator __lm1 = __last;
 for (--__lm1; __first != __lm1; ++__first)
 {
-_BirdirectionalIterator __i = 
_VSTD::min_element<_BirdirectionalIterator,
+_BidirectionalIterator __i = _VSTD::min_element<_BidirectionalIterator,
 typename 
add_lvalue_reference<_Compare>::type>
(__first, __last, 
__comp);
 if (__i != __first)
@@ -3818,19 +3818,19 @@ __selection_sort(_BirdirectionalIterator __first, 
_BirdirectionalIterator __last
 }
 }
 
-template 
+template 
 void
-__insertion_sort(_BirdirectionalIterator __first, _BirdirectionalIterator 
__last, _Compare __comp)
+__insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator 
__last, _Compare __comp)
 {
-typedef typename iterator_traits<_BirdirectionalIterator>::value_type 
value_type;
+typedef typename iterator_traits<_BidirectionalIterator>::value_type 
value_type;
 if (__first != __last)
 {
-_BirdirectionalIterator __i = __first;
+_BidirectionalIterator __i = __first;
 for (++__i; __i != __last; ++__i)
 {
-_BirdirectionalIterator __j = __i;
+_BidirectionalIterator __j = __i;
 value_type __t(_VSTD::move(*__j));
-for (_BirdirectionalIterator __k = __i; __k != __first && 
__comp(__t,  *--__k); --__j)
+for (_BidirectionalIterator __k = __i; __k != __first && 
__comp(__t,  *--__k); --__j)
 *__j = _VSTD::move(*__k);
 *__j = _VSTD::move(__t);
 }
@@ -3911,12 +3911,12 @@ __insertion_sort_incomplete(_RandomAccessIterator 
__first, _RandomAccessIterator
 return true;
 }
 
-template 
+template 
 void
-__insertion_sort_move(_BirdirectionalIterator __first1, 
_BirdirectionalIterator __last1,
-  typename 
iterator_traits<_BirdirectionalIterator>::value_type* __first2, _Compare __comp)
+__insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator 
__last1,
+  typename 
iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp)
 {
-typedef typename iterator_traits<_BirdirectionalIterator>::value_type 
value_type;
+typedef typename iterator_traits<_BidirectionalIterator>::value_type 
value_type;
 if (__first1 != __last1)
 {
 __destruct_n __d(0);



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] e9eb999 - [libc++] s/insertible/insertable/g. NFCI.

2020-12-14 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-14T09:54:58-05:00
New Revision: e9eb9f8f75e5f9244da8600dde1f7d85cac9

URL: 
https://github.com/llvm/llvm-project/commit/e9eb9f8f75e5f9244da8600dde1f7d85cac9
DIFF: 
https://github.com/llvm/llvm-project/commit/e9eb9f8f75e5f9244da8600dde1f7d85cac9.diff

LOG: [libc++] s/insertible/insertable/g. NFCI.

Added: 


Modified: 
libcxx/include/memory

libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
libcxx/test/support/container_test_types.h

Removed: 




diff  --git a/libcxx/include/memory b/libcxx/include/memory
index f8c3ace20619..b5193396673f 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -1716,7 +1716,7 @@ template 
 _LIBCPP_INLINE_VISIBILITY
 void __construct_forward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, 
_Ptr __end1, _Ptr& __begin2) {
 static_assert(__is_cpp17_move_insertable<_Alloc>::value,
-"The specified type does not meet the requirements of 
Cpp17MoveInsertible");
+"The specified type does not meet the requirements of 
Cpp17MoveInsertable");
 typedef allocator_traits<_Alloc> _Traits;
 for (; __begin1 != __end1; ++__begin1, (void)++__begin2) {
 _Traits::construct(__a, _VSTD::__to_address(__begin2),

diff  --git 
a/libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
 
b/libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
index fb10a3c9b5d5..984af29d31bf 100644
--- 
a/libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
+++ 
b/libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
@@ -14,7 +14,7 @@
 // 
 
 // Test that vector produces a decent diagnostic for user types that explicitly
-// delete their move constructor. Such types don't meet the Cpp17CopyInsertible
+// delete their move constructor. Such types don't meet the Cpp17CopyInsertable
 // requirements.
 
 #include 

diff  --git a/libcxx/test/support/container_test_types.h 
b/libcxx/test/support/container_test_types.h
index 2668aa889fe3..38fcd5107d3a 100644
--- a/libcxx/test/support/container_test_types.h
+++ b/libcxx/test/support/container_test_types.h
@@ -49,12 +49,12 @@
 //
 /*
  * Usage: The following example checks that 'unordered_map::emplace(Args&&...)'
- *with 'Args = [CopyInsertable<1> const&, CopyInsertible<2>&&]'
+ *with 'Args = [CopyInsertable<1> const&, CopyInsertable<2>&&]'
  *calls 'alloc.construct(value_type*, Args&&...)' with the same types.
  *
  * // Typedefs for container
- * using Key = CopyInsertible<1>;
- * using Value = CopyInsertible<2>;
+ * using Key = CopyInsertable<1>;
+ * using Value = CopyInsertable<2>;
  * using ValueTp = std::pair;
  * using Alloc = ContainerTestAllocator;
  * using Map = std::unordered_map, 
std::equal_to, Alloc>;



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] ce9ac54 - [libc++] Remove __is_construct::__nat. NFCI.

2020-12-14 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-14T09:54:58-05:00
New Revision: ce9ac549c9396a1308630f838c87a44b5284ea01

URL: 
https://github.com/llvm/llvm-project/commit/ce9ac549c9396a1308630f838c87a44b5284ea01
DIFF: 
https://github.com/llvm/llvm-project/commit/ce9ac549c9396a1308630f838c87a44b5284ea01.diff

LOG: [libc++] Remove __is_construct::__nat. NFCI.

This type has been unused since commit 5b4cc84b87232e67afb63e2bad429b3211b26964.

Added: 


Modified: 
libcxx/include/type_traits

Removed: 




diff  --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 2842c905e302..3bcb1d74fcad 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -2878,11 +2878,6 @@ struct __member_pointer_class_type<_Ret _ClassType::*> {
 
 // template  struct is_constructible;
 
-namespace __is_construct
-{
-struct __nat {};
-}
-
 #if defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER_NEW >= 1
 # define _LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE
 #endif



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 2664f5d - generate_header_tests.py: Sort the header files ASCIIbetically.

2020-12-14 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-14T09:56:07-05:00
New Revision: 2664f5d436522d52b0cc8c05ee76e4de8d93dad1

URL: 
https://github.com/llvm/llvm-project/commit/2664f5d436522d52b0cc8c05ee76e4de8d93dad1
DIFF: 
https://github.com/llvm/llvm-project/commit/2664f5d436522d52b0cc8c05ee76e4de8d93dad1.diff

LOG: generate_header_tests.py: Sort the header files ASCIIbetically.

Otherwise they come out in random (inode?) order.

Also `chmod +x` the generator, and re-run it. Somehow on Marek's
machine it produced \r\n line endings?! Open all files with
`newline='\n'` so that (if the Python3 docs are correct)
that won't happen again.

Differential Revision: https://reviews.llvm.org/D93137

Added: 


Modified: 
libcxx/test/libcxx/double_include.sh.cpp
libcxx/test/libcxx/min_max_macros.compile.pass.cpp
libcxx/test/libcxx/no_assert_include.compile.pass.cpp
libcxx/utils/generate_abi_list.py
libcxx/utils/generate_feature_test_macro_components.py
libcxx/utils/generate_header_tests.py

Removed: 




diff  --git a/libcxx/test/libcxx/double_include.sh.cpp 
b/libcxx/test/libcxx/double_include.sh.cpp
index 072b78899b36..f382ee7ab9f6 100644
--- a/libcxx/test/libcxx/double_include.sh.cpp
+++ b/libcxx/test/libcxx/double_include.sh.cpp
@@ -1,235 +1,235 @@
-// -*- C++ -*-
-//===--===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-// Test that we can include each header in two TU's and link them together.
-
-// RUN: %{cxx} -c %s -o %t.first.o %{flags} %{compile_flags}
-// RUN: %{cxx} -c %s -o %t.second.o -DWITH_MAIN %{flags} %{compile_flags}
-// RUN: %{cxx} -o %t.exe %t.first.o %t.second.o %{flags} %{link_flags}
-// RUN: %{run}
-
-// GCC 5 pretends it supports C++17 features, but some features like 
static_assert
-// without a message are not actually supported. This causes some headers to 
fail
-// when included.
-// UNSUPPORTED: gcc-5 && c++17
-
-// Prevent  from generating deprecated warnings for this test.
-#if defined(__DEPRECATED)
-#undef __DEPRECATED
-#endif
-
-
-// BEGIN-GENERATED-HEADERS
-
-
-// clang-format off
-
-// WARNING: This test was generated by generate_header_tests.py
-// and should not be edited manually.
-
-// Top level headers
-#include 
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#include 
-#endif
-#ifndef _LIBCPP_HAS_NO_THREADS
-#include 
-#endif
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#include 
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#include 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#include 
-#endif
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#include 
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#include 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#include 
-#endif
-#include 
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#include 
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#include 
-#endif
-#include 
-#include 
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#include 
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#include 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#include 
-#endif
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#include 
-#endif
-#include 
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#include 
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include 
-#endif
-#include 
-#include 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#include 
-#endif
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#includ

[llvm-branch-commits] [libcxx] b6f1917 - [libc++] Fix some one-off typos in comments. NFCI.

2020-12-14 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-14T09:54:58-05:00
New Revision: b6f191741562ab32a3e210c8661df09b546275cc

URL: 
https://github.com/llvm/llvm-project/commit/b6f191741562ab32a3e210c8661df09b546275cc
DIFF: 
https://github.com/llvm/llvm-project/commit/b6f191741562ab32a3e210c8661df09b546275cc.diff

LOG: [libc++] Fix some one-off typos in comments. NFCI.

Added: 


Modified: 
libcxx/include/__hash_table
libcxx/include/__tree
libcxx/include/algorithm
libcxx/include/list
libcxx/include/optional
libcxx/include/semaphore

Removed: 




diff  --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index ab45277e20c8..521ebbf2c45f 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -1929,7 +1929,7 @@ __hash_table<_Tp, _Hash, _Equal, 
_Alloc>::__node_insert_unique(__node_pointer __
 // Prepare the container for an insertion of the value __cp_val with the hash
 // __cp_hash. This does a lookup into the container to see if __cp_value is
 // already present, and performs a rehash if necessary. Returns a pointer to 
the
-// last occurance of __cp_val in the map.
+// last occurrence of __cp_val in the map.
 //
 // Note that this function does forward exceptions if key_eq() throws, and 
never
 // mutates __value or actually inserts into the map.

diff  --git a/libcxx/include/__tree b/libcxx/include/__tree
index 26c4c4121c5f..d1bfccfb5909 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -1428,7 +1428,7 @@ private:
 __node_base_pointer&
 __find_leaf(const_iterator __hint,
 __parent_pointer& __parent, const key_type& __v);
-// FIXME: Make this function const qualified. Unfortunetly doing so
+// FIXME: Make this function const qualified. Unfortunately doing so
 // breaks existing code which uses non-const callable comparators.
 template 
 __node_base_pointer&

diff  --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index bba8f3ac5199..b1771a1c629b 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -4056,7 +4056,7 @@ __sort(_RandomAccessIterator __first, 
_RandomAccessIterator __last, _Compare __c
 ++__i;
 }
 // [__first, __i) == *__first and *__first < [__i, __last)
-// The first part is sorted, sort the secod part
+// The first part is sorted, sort the second part
 // _VSTD::__sort<_Compare>(__i, __last, __comp);
 __first = __i;
 goto __restart;
@@ -4564,7 +4564,7 @@ __inplace_merge(_BidirectionalIterator __first, 
_BidirectionalIterator __middle,
 // swap middle two partitions
 __middle = _VSTD::rotate(__m1, __middle, __m2);
 // __len12 and __len21 now have swapped meanings
-// merge smaller range with recurisve call and larger with tail 
recursion elimination
+// merge smaller range with recursive call and larger with tail 
recursion elimination
 if (__len11 + __len21 < __len12 + __len22)
 {
 _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, 
__len11, __len21, __buff, __buff_size);

diff  --git a/libcxx/include/list b/libcxx/include/list
index a71f46fa2527..a18514d74eaf 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -2056,7 +2056,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, 
const_iterator __i)
 " referring to list argument");
 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(&__i),
 "list::splice(iterator, list, iterator) called with second iterator 
not"
-" derefereceable");
+" dereferenceable");
 #endif
 if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_)
 {

diff  --git a/libcxx/include/optional b/libcxx/include/optional
index 6cd51482e926..570fa11e78c4 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -657,7 +657,7 @@ private:
   }
   template 
   static constexpr bool __enable_assign() {
-  // Construction and assignability of _Qup to _Tp has already been
+  // Construction and assignability of _QUp to _Tp has already been
   // checked.
   return !__check_constructible_from_opt<_Up>::value &&
   !__check_assignable_from_opt<_Up>::value;

diff  --git a/libcxx/include/semaphore b/libcxx/include/semaphore
index 0943606e93d2..0e0434f7fbd5 100644
--- a/libcxx/include/semaphore
+++ b/libcxx/include/semaphore
@@ -71,7 +71,7 @@ __atomic_semaphore_base is the general-case implementation, 
to be used for
 user-requested least-max values that exceed the OS implementation support
 (incl. when the OS has no support of its own) and for binary semaphores.
 
-It is a typical Dijsktra semaphore algorithm over atomics, wait and notify
+It is a typical Dijkstra semaphore algorith