[libcxx-commits] [libcxx] 177cb10 - [libc++][NFC] Rename helper function for testing spaceship

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 28 06:59:00 PDT 2023


Author: Louis Dionne
Date: 2023-03-28T09:58:37-04:00
New Revision: 177cb1030f5de716143d3883b89acde5240042fb

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

LOG: [libc++][NFC] Rename helper function for testing spaceship

The helper is mis-named, since it won't work as-is on ordered containers
like set and map, because they rely on being able to store keys that are
partial_ordering::unordered, and that's UB for an ordered container.

This was most likely a typo or an unintended naming mistake, since
the function is only used with sequence containers anyway.

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

Added: 
    

Modified: 
    libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp
    libcxx/test/libcxx/containers/sequences/forwardlist/compare.three_way.pass.cpp
    libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp
    libcxx/test/support/test_container_comparisons.h

Removed: 
    


################################################################################
diff  --git a/libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp
index 92355755dadfc..3d5646a844951 100644
--- a/libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp
@@ -19,7 +19,7 @@
 #include "test_container_comparisons.h"
 
 int main(int, char**) {
-  assert(test_ordered_container_spaceship<std::deque>());
+  assert(test_sequence_container_spaceship<std::deque>());
   // `std::deque` is not constexpr, so no `static_assert` test here.
   return 0;
 }

diff  --git a/libcxx/test/libcxx/containers/sequences/forwardlist/compare.three_way.pass.cpp b/libcxx/test/libcxx/containers/sequences/forwardlist/compare.three_way.pass.cpp
index ec570c6a12e63..52adfc4d85985 100644
--- a/libcxx/test/libcxx/containers/sequences/forwardlist/compare.three_way.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/forwardlist/compare.three_way.pass.cpp
@@ -19,7 +19,7 @@
 #include "test_container_comparisons.h"
 
 int main(int, char**) {
-  assert(test_ordered_container_spaceship<std::forward_list>());
+  assert(test_sequence_container_spaceship<std::forward_list>());
   // `std::forward_list` is not constexpr, so no `static_assert` test here.
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp b/libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp
index 592067b602cc0..059fba3c26268 100644
--- a/libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp
@@ -19,7 +19,7 @@
 #include "test_container_comparisons.h"
 
 int main(int, char**) {
-  assert(test_ordered_container_spaceship<std::list>());
+  assert(test_sequence_container_spaceship<std::list>());
   // `std::list` is not constexpr, so no `static_assert` test here.
   return 0;
 }

diff  --git a/libcxx/test/support/test_container_comparisons.h b/libcxx/test/support/test_container_comparisons.h
index 8687d9ae80d53..561275c8bb790 100644
--- a/libcxx/test/support/test_container_comparisons.h
+++ b/libcxx/test/support/test_container_comparisons.h
@@ -12,9 +12,9 @@
 
 #include "test_comparisons.h"
 
-// Implementation detail of `test_ordered_container_spaceship`
+// Implementation detail of `test_sequence_container_spaceship`
 template <template <typename...> typename Container, typename Elem, typename Order>
-constexpr void test_ordered_container_spaceship_with_type() {
+constexpr void test_sequence_container_spaceship_with_type() {
   // Empty containers
   {
     Container<Elem> l1;
@@ -59,20 +59,20 @@ constexpr void test_ordered_container_spaceship_with_type() {
   }
 }
 
-// Tests the `operator<=>` on ordered containers
+// Tests the `operator<=>` on sequence containers
 template <template <typename...> typename Container>
-constexpr bool test_ordered_container_spaceship() {
+constexpr bool test_sequence_container_spaceship() {
   // The container should fulfil `std::three_way_comparable`
   static_assert(std::three_way_comparable<Container<int>>);
 
   // Test 
diff erent comparison categories
-  test_ordered_container_spaceship_with_type<Container, int, std::strong_ordering>();
-  test_ordered_container_spaceship_with_type<Container, StrongOrder, std::strong_ordering>();
-  test_ordered_container_spaceship_with_type<Container, WeakOrder, std::weak_ordering>();
-  test_ordered_container_spaceship_with_type<Container, PartialOrder, std::partial_ordering>();
+  test_sequence_container_spaceship_with_type<Container, int, std::strong_ordering>();
+  test_sequence_container_spaceship_with_type<Container, StrongOrder, std::strong_ordering>();
+  test_sequence_container_spaceship_with_type<Container, WeakOrder, std::weak_ordering>();
+  test_sequence_container_spaceship_with_type<Container, PartialOrder, std::partial_ordering>();
 
   // `LessAndEqComp` does not have `operator<=>`. ordering is sythesized based on `operator<`
-  test_ordered_container_spaceship_with_type<Container, LessAndEqComp, std::weak_ordering>();
+  test_sequence_container_spaceship_with_type<Container, LessAndEqComp, std::weak_ordering>();
 
   // Thanks to SFINAE, the following is not a compiler error but returns `false`
   struct NonComparable {};


        


More information about the libcxx-commits mailing list