Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] Restore __synth_three_way lambda #90398

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

H-G-Hristov
Copy link
Contributor

@H-G-Hristov H-G-Hristov commented Apr 28, 2024

Restore __synth_three_way lambda to match the Standard.
GH-57222 is done, restoring the Standard wording implementation should be possible.

https://github.com/llvm/llvm-project/blob/df28d4412c1d21b0e18896c92ac77d2fac7729f1/libcxx/include/__compare/synth_three_way.h#L28

According to comment #59513 (comment), GH-59513 is not a blocker.

Copy link

github-actions bot commented Apr 28, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@H-G-Hristov H-G-Hristov force-pushed the hgh/libcxx/__synth_three_way-restore-the-lambda-to-match-the-Standard branch from df28d44 to af02e09 Compare April 28, 2024 15:23
@H-G-Hristov
Copy link
Contributor Author

Not possible yet. We'll need an Xcode based on LLVM 17.

@H-G-Hristov H-G-Hristov force-pushed the hgh/libcxx/__synth_three_way-restore-the-lambda-to-match-the-Standard branch from af02e09 to a7522dd Compare April 28, 2024 17:12
@Zingam Zingam marked this pull request as ready for review May 19, 2024 04:24
@Zingam Zingam requested a review from a team as a code owner May 19, 2024 04:25
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label May 19, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 19, 2024

@llvm/pr-subscribers-libcxx

Author: Hristo Hristov (H-G-Hristov)

Changes

Restore __synth_three_way lambda to match the Standard.
GH-57222 is done, restoring the Standard wording implementation should be possible.

https://github.com/llvm/llvm-project/blob/df28d4412c1d21b0e18896c92ac77d2fac7729f1/libcxx/include/__compare/synth_three_way.h#L28

According to comment #59513 (comment), GH-59513 is not a blocker.


Full diff: https://github.com/llvm/llvm-project/pull/90398.diff

8 Files Affected:

  • (modified) libcxx/include/__compare/synth_three_way.h (+2-7)
  • (modified) libcxx/include/array (+1-1)
  • (modified) libcxx/include/deque (+1-1)
  • (modified) libcxx/include/forward_list (+1-1)
  • (modified) libcxx/include/list (+1-1)
  • (modified) libcxx/include/map (+2-12)
  • (modified) libcxx/include/set (+2-3)
  • (modified) libcxx/include/vector (+1-1)
diff --git a/libcxx/include/__compare/synth_three_way.h b/libcxx/include/__compare/synth_three_way.h
index 6420d1362db0c..e48ce49799836 100644
--- a/libcxx/include/__compare/synth_three_way.h
+++ b/libcxx/include/__compare/synth_three_way.h
@@ -25,12 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 // [expos.only.func]
 
-// TODO MODULES restore the lamba to match the Standard.
-// See https://github.com/llvm/llvm-project/issues/57222
-//_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
-//  []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
-template <class _Tp, class _Up>
-_LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up& __u)
+_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
   requires requires {
     { __t < __u } -> __boolean_testable;
     { __u < __t } -> __boolean_testable;
@@ -45,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up
       return weak_ordering::greater;
     return weak_ordering::equivalent;
   }
-}
+};
 
 template <class _Tp, class _Up = _Tp>
 using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));
diff --git a/libcxx/include/array b/libcxx/include/array
index 6ea094deec32d..c34881224d063 100644
--- a/libcxx/include/array
+++ b/libcxx/include/array
@@ -423,7 +423,7 @@ template <class _Tp, size_t _Size>
 _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
 operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/deque b/libcxx/include/deque
index 3c33e04e9f05f..46a9eb357d4e7 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -2523,7 +2523,7 @@ template <class _Tp, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
 operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 5a7521eed4104..69409404a6265 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -1524,7 +1524,7 @@ template <class _Tp, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
 operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // #if _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/list b/libcxx/include/list
index 90bddcc29db09..d37f9e4258042 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -1687,7 +1687,7 @@ template <class _Tp, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
 operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/map b/libcxx/include/map
index 1d1c062a0267c..d098fd006227f 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -1623,12 +1623,7 @@ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp,
 template <class _Key, class _Tp, class _Compare, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
 operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {
-  return std::lexicographical_compare_three_way(
-      __x.begin(),
-      __x.end(),
-      __y.begin(),
-      __y.end(),
-      std::__synth_three_way<pair<const _Key, _Tp>, pair<const _Key, _Tp>>);
+  return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // #if _LIBCPP_STD_VER <= 17
@@ -2144,12 +2139,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
 operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
             const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {
-  return std::lexicographical_compare_three_way(
-      __x.begin(),
-      __x.end(),
-      __y.begin(),
-      __y.end(),
-      std::__synth_three_way<pair<const _Key, _Tp>, pair<const _Key, _Tp>>);
+  return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
 }
 
 #endif // #if _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/set b/libcxx/include/set
index d9377ee6c3322..cff37170ee71f 100644
--- a/libcxx/include/set
+++ b/libcxx/include/set
@@ -996,8 +996,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,
 template <class _Key, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
 operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) {
-  return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>);
+  return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17
@@ -1457,7 +1456,7 @@ template <class _Key, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
 operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/vector b/libcxx/include/vector
index 976bde9b9048c..effc8d14fea1d 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -2906,7 +2906,7 @@ template <class _Tp, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
 operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17

@mordante mordante self-assigned this May 20, 2024
@mordante
Copy link
Member

Not possible yet. We'll need an Xcode based on LLVM 17.

Thanks for working on this. I think we indeed should wait for proper support on XCode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants