[libcxx-commits] [libcxx] [libc++] [ranges] remove `__workaround_52970` (PR #85683)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 18 12:39:30 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Xiaoyang Liu (xiaoyang-sde)
<details>
<summary>Changes</summary>
## Abstract
This pull request removes the `__workaround_52970` concept. This concept is a workaround for a bug described in #<!-- -->52970, which causes the compiler to trigger ADL on a pointer to an incomplete type in an SFINAE context. This bug is fixed in Clang 14.
## Reference
- [[clang] Don't typo-fix an expression in a SFINAE context](https://reviews.llvm.org/D117603)
- [[libc++] [ranges] ADL-proof the [range.access] CPOs.](https://reviews.llvm.org/D116239)
---
Full diff: https://github.com/llvm/llvm-project/pull/85683.diff
7 Files Affected:
- (modified) libcxx/include/__concepts/class_or_enum.h (-5)
- (modified) libcxx/include/__ranges/access.h (+2-2)
- (modified) libcxx/include/__ranges/data.h (+1-1)
- (modified) libcxx/include/__ranges/empty.h (+1-1)
- (modified) libcxx/include/__ranges/rbegin.h (+1-1)
- (modified) libcxx/include/__ranges/rend.h (+1-1)
- (modified) libcxx/include/__ranges/size.h (+1-1)
``````````diff
diff --git a/libcxx/include/__concepts/class_or_enum.h b/libcxx/include/__concepts/class_or_enum.h
index c1b4a8c258f3a5..2739e31e14ba65 100644
--- a/libcxx/include/__concepts/class_or_enum.h
+++ b/libcxx/include/__concepts/class_or_enum.h
@@ -28,11 +28,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;
-// Work around Clang bug https://llvm.org/PR52970
-// TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14).
-template <class _Tp>
-concept __workaround_52970 = is_class_v<__remove_cvref_t<_Tp>> || is_union_v<__remove_cvref_t<_Tp>>;
-
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__ranges/access.h b/libcxx/include/__ranges/access.h
index 218b3928ecdc5f..3db4f11b40f2d0 100644
--- a/libcxx/include/__ranges/access.h
+++ b/libcxx/include/__ranges/access.h
@@ -41,7 +41,7 @@ concept __can_borrow = is_lvalue_reference_v<_Tp> || enable_borrowed_range<remov
namespace ranges {
namespace __begin {
template <class _Tp>
-concept __member_begin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
+concept __member_begin = __can_borrow<_Tp> && requires(_Tp&& __t) {
{ _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator;
};
@@ -103,7 +103,7 @@ using iterator_t = decltype(ranges::begin(std::declval<_Tp&>()));
namespace ranges {
namespace __end {
template <class _Tp>
-concept __member_end = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
+concept __member_end = __can_borrow<_Tp> && requires(_Tp&& __t) {
typename iterator_t<_Tp>;
{ _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>;
};
diff --git a/libcxx/include/__ranges/data.h b/libcxx/include/__ranges/data.h
index 18002bb52cc8ce..131f6cdad8f21c 100644
--- a/libcxx/include/__ranges/data.h
+++ b/libcxx/include/__ranges/data.h
@@ -40,7 +40,7 @@ template <class _Tp>
concept __ptr_to_object = is_pointer_v<_Tp> && is_object_v<remove_pointer_t<_Tp>>;
template <class _Tp>
-concept __member_data = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
+concept __member_data = __can_borrow<_Tp> && requires(_Tp&& __t) {
{ _LIBCPP_AUTO_CAST(__t.data()) } -> __ptr_to_object;
};
diff --git a/libcxx/include/__ranges/empty.h b/libcxx/include/__ranges/empty.h
index acd55dae224ce7..5c1004042aba51 100644
--- a/libcxx/include/__ranges/empty.h
+++ b/libcxx/include/__ranges/empty.h
@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
namespace __empty {
template <class _Tp>
-concept __member_empty = __workaround_52970<_Tp> && requires(_Tp&& __t) { bool(__t.empty()); };
+concept __member_empty = requires(_Tp&& __t) { bool(__t.empty()); };
template <class _Tp>
concept __can_invoke_size = !__member_empty<_Tp> && requires(_Tp&& __t) { ranges::size(__t); };
diff --git a/libcxx/include/__ranges/rbegin.h b/libcxx/include/__ranges/rbegin.h
index 947e428f00cd52..12e739e1a2b852 100644
--- a/libcxx/include/__ranges/rbegin.h
+++ b/libcxx/include/__ranges/rbegin.h
@@ -36,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
namespace __rbegin {
template <class _Tp>
-concept __member_rbegin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
+concept __member_rbegin = __can_borrow<_Tp> && requires(_Tp&& __t) {
{ _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator;
};
diff --git a/libcxx/include/__ranges/rend.h b/libcxx/include/__ranges/rend.h
index 1b6be58fea24b4..5edbc4e3160c5f 100644
--- a/libcxx/include/__ranges/rend.h
+++ b/libcxx/include/__ranges/rend.h
@@ -37,7 +37,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
namespace __rend {
template <class _Tp>
-concept __member_rend = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
+concept __member_rend = __can_borrow<_Tp> && requires(_Tp&& __t) {
ranges::rbegin(__t);
{ _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
};
diff --git a/libcxx/include/__ranges/size.h b/libcxx/include/__ranges/size.h
index 59ca2b11ee3890..40b0c6b6aad7a3 100644
--- a/libcxx/include/__ranges/size.h
+++ b/libcxx/include/__ranges/size.h
@@ -47,7 +47,7 @@ template <class _Tp>
concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>;
template <class _Tp>
-concept __member_size = __size_enabled<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
+concept __member_size = __size_enabled<_Tp> && requires(_Tp&& __t) {
{ _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like;
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/85683
More information about the libcxx-commits
mailing list