-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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++] Deprecates rel_ops. #91642
[libc++] Deprecates rel_ops. #91642
Conversation
@llvm/pr-subscribers-libcxx Author: Mark de Wever (mordante) ChangesThese operators were deprecated in This was discovered while investigating the paper's implementation status. Full diff: https://github.com/llvm/llvm-project/pull/91642.diff 4 Files Affected:
diff --git a/libcxx/include/__utility/rel_ops.h b/libcxx/include/__utility/rel_ops.h
index ee8657196d98c..a8caf5bdeaf27 100644
--- a/libcxx/include/__utility/rel_ops.h
+++ b/libcxx/include/__utility/rel_ops.h
@@ -20,22 +20,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace rel_ops {
template <class _Tp>
-inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const _Tp& __x, const _Tp& __y) {
+inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator!=(const _Tp& __x, const _Tp& __y) {
return !(__x == __y);
}
template <class _Tp>
-inline _LIBCPP_HIDE_FROM_ABI bool operator>(const _Tp& __x, const _Tp& __y) {
+inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator>(const _Tp& __x, const _Tp& __y) {
return __y < __x;
}
template <class _Tp>
-inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const _Tp& __x, const _Tp& __y) {
+inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator<=(const _Tp& __x, const _Tp& __y) {
return !(__y < __x);
}
template <class _Tp>
-inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const _Tp& __x, const _Tp& __y) {
+inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator>=(const _Tp& __x, const _Tp& __y) {
return !(__x < __y);
}
diff --git a/libcxx/test/libcxx/depr/depr.rel_ops/rel_ops.depr_in_cxx20.verify.cpp b/libcxx/test/libcxx/depr/depr.rel_ops/rel_ops.depr_in_cxx20.verify.cpp
new file mode 100644
index 0000000000000..11c1b8c335dea
--- /dev/null
+++ b/libcxx/test/libcxx/depr/depr.rel_ops/rel_ops.depr_in_cxx20.verify.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// UNSUPPORTED: c++03, c++11, c++
+
+#include <utility>
+#include <cassert>
+
+struct A {
+ int data_ = 0;
+};
+
+inline bool operator==(const A& x, const A& y) { return x.data_ == y.data_; }
+
+inline bool operator<(const A& x, const A& y) { return x.data_ < y.data_; }
+
+void test() {
+ using namespace std::rel_ops;
+ A a1(1);
+ A a2(2);
+ (void)(a1 == a1);
+ (void)(a1 != a2); // note not deprecated message, due to compiler generated operator.
+ std::rel_ops::operator!=(a1, a2); // expected-warning {{is deprecated}}
+ (void)(a1 < a2);
+ (void)(a1 > a2); // expected-warning 2 {{is deprecated}}
+ (void)(a1 <= a2); // expected-warning 2 {{is deprecated}}
+ (void)(a1 >= a2); // expected-warning 2 {{is deprecated}}
+}
diff --git a/libcxx/test/std/containers/iterator.rel_ops.compile.pass.cpp b/libcxx/test/std/containers/iterator.rel_ops.compile.pass.cpp
index aaaa887f72074..9db2449f2f166 100644
--- a/libcxx/test/std/containers/iterator.rel_ops.compile.pass.cpp
+++ b/libcxx/test/std/containers/iterator.rel_ops.compile.pass.cpp
@@ -8,6 +8,8 @@
// XFAIL: availability-filesystem-missing
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
// Make sure the various containers' iterators are not broken by the use of `std::rel_ops`.
#include <utility> // for std::rel_ops
diff --git a/libcxx/test/std/utilities/utility/operators/rel_ops.pass.cpp b/libcxx/test/std/utilities/utility/operators/rel_ops.pass.cpp
index 52ed642274114..db0c7a61bddd6 100644
--- a/libcxx/test/std/utilities/utility/operators/rel_ops.pass.cpp
+++ b/libcxx/test/std/utilities/utility/operators/rel_ops.pass.cpp
@@ -8,6 +8,8 @@
// test rel_ops
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
#include <utility>
#include <cassert>
|
libcxx/test/libcxx/depr/depr.rel_ops/rel_ops.depr_in_cxx20.verify.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be relevant to mention this deprecation in a release note.
02dc129
to
4e51263
Compare
4e51263
to
a709962
Compare
These operators were deprecated in P0768R1 Library Support for the Spaceship (Comparison) Operator This was discovered while investigating the paper's implementation status.
a709962
to
00f6e65
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/12/builds/2068 Here is the relevant piece of the build log for the reference:
|
These operators were deprecated in P0768R1 Library Support for the Spaceship (Comparison) Operator This was discovered while investigating the paper's implementation status.
Summary: These operators were deprecated in P0768R1 Library Support for the Spaceship (Comparison) Operator This was discovered while investigating the paper's implementation status. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250952
These operators were deprecated in
P0768R1 Library Support for the Spaceship (Comparison) Operator
This was discovered while investigating the paper's implementation status.