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++] Deprecates rel_ops. #91642

Merged
merged 1 commit into from
Jul 17, 2024
Merged

Conversation

mordante
Copy link
Member

@mordante mordante commented May 9, 2024

These operators were deprecated in
P0768R1 Library Support for the Spaceship (Comparison) Operator

This was discovered while investigating the paper's implementation status.

@mordante mordante requested a review from a team as a code owner May 9, 2024 18:34
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label May 9, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 9, 2024

@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)

Changes

These operators were deprecated in
P0768R1 Library Support for the Spaceship (Comparison) Operator

This was discovered while investigating the paper's implementation status.


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

4 Files Affected:

  • (modified) libcxx/include/__utility/rel_ops.h (+4-4)
  • (added) libcxx/test/libcxx/depr/depr.rel_ops/rel_ops.depr_in_cxx20.verify.cpp (+35)
  • (modified) libcxx/test/std/containers/iterator.rel_ops.compile.pass.cpp (+2)
  • (modified) libcxx/test/std/utilities/utility/operators/rel_ops.pass.cpp (+2)
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>
 

Copy link
Member

@ldionne ldionne left a 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.

@mordante mordante force-pushed the review/deprecates_rel_ops branch 2 times, most recently from 02dc129 to 4e51263 Compare July 7, 2024 16:36
These operators were deprecated in
  P0768R1 Library Support for the Spaceship (Comparison) Operator

This was discovered while investigating the paper's implementation
status.
@mordante mordante merged commit 136737d into llvm:main Jul 17, 2024
14 of 16 checks passed
@mordante mordante deleted the review/deprecates_rel_ops branch July 17, 2024 16:21
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 17, 2024

LLVM Buildbot has detected a new failure on builder clang-ve-ninja running on hpce-ve-main while building libcxx at step 4 "annotate".

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:

Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/ve-linux.py ...' (failure)
...
[639/640] Linking CXX executable unittests/ExecutionEngine/MCJIT/MCJITTests
[639/640] Running the LLVM regression tests
Unknown option: -C
usage: git [--version] [--help] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
An error occurred retrieving the git revision: Command '['git', '-C', '/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm', 'rev-parse', 'HEAD']' returned non-zero exit status 129.
-- Testing: 54529 tests, 48 workers --
command timed out: 1200 seconds without output running [b'python', b'../llvm-zorg/zorg/buildbot/builders/annotated/ve-linux.py', b'--jobs=8'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1604.295294
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
Step 8 (check-llvm) failure: check-llvm (failure)
...
[605/640] Linking CXX executable unittests/Support/SupportTests
[606/640] Linking CXX executable unittests/DebugInfo/PDB/DebugInfoPDBTests
[607/640] Linking CXX executable unittests/MC/MCTests
[608/640] Linking CXX executable unittests/DebugInfo/BTF/DebugInfoBTFTests
[609/640] Linking CXX executable unittests/Bitcode/BitcodeTests
[610/640] Linking CXX executable unittests/ObjectYAML/ObjectYAMLTests
[611/640] Linking CXX executable unittests/tools/llvm-cfi-verify/CFIVerifyTests
[612/640] Linking CXX executable unittests/Object/ObjectTests
[613/640] Linking CXX executable unittests/ObjCopy/ObjCopyTests
[614/640] Linking CXX executable unittests/ProfileData/ProfileDataTests
[615/640] Linking CXX executable unittests/Transforms/Vectorize/VectorizeTests
[616/640] Linking CXX executable unittests/FuzzMutate/FuzzMutateTests
[617/640] Linking CXX executable unittests/DebugInfo/LogicalView/DebugInfoLogicalViewTests
[618/640] Linking CXX executable unittests/Transforms/IPO/IPOTests
[619/640] Linking CXX executable unittests/Target/VE/VETests
[620/640] Linking CXX executable unittests/MIR/MIRTests
[621/640] Linking CXX executable unittests/CodeGen/GlobalISel/GlobalISelTests
[622/640] Linking CXX executable unittests/Target/TargetMachineCTests
[623/640] Linking CXX executable unittests/MI/MITests
[624/640] Linking CXX executable unittests/DebugInfo/DWARF/DebugInfoDWARFTests
[625/640] Linking CXX executable unittests/tools/llvm-exegesis/LLVMExegesisTests
[626/640] Linking CXX executable unittests/tools/llvm-mca/LLVMMCATests
[627/640] Linking CXX executable unittests/Passes/Plugins/PluginsTests
[628/640] Linking CXX executable unittests/Transforms/Coroutines/CoroTests
[629/640] Linking CXX executable unittests/Passes/PassBuilderBindings/PassesBindingsTests
[630/640] Linking CXX executable unittests/Transforms/Instrumentation/InstrumentationTests
[631/640] Linking CXX executable unittests/Frontend/LLVMFrontendTests
[632/640] Linking CXX executable unittests/Transforms/Utils/UtilsTests
[633/640] Linking CXX executable unittests/ExecutionEngine/Orc/OrcJITTests
[634/640] Linking CXX executable unittests/Transforms/Scalar/ScalarTests
[635/640] Linking CXX executable unittests/Analysis/AnalysisTests
[636/640] Linking CXX executable unittests/IR/IRTests
[637/640] Linking CXX executable unittests/Target/X86/X86Tests
[638/640] Linking CXX executable unittests/CodeGen/CodeGenTests
[639/640] Linking CXX executable unittests/ExecutionEngine/MCJIT/MCJITTests
[639/640] Running the LLVM regression tests
Unknown option: -C
usage: git [--version] [--help] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
An error occurred retrieving the git revision: Command '['git', '-C', '/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm', 'rev-parse', 'HEAD']' returned non-zero exit status 129.
-- Testing: 54529 tests, 48 workers --

command timed out: 1200 seconds without output running [b'python', b'../llvm-zorg/zorg/buildbot/builders/annotated/ve-linux.py', b'--jobs=8'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1604.295294
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..

sgundapa pushed a commit to sgundapa/upstream_effort that referenced this pull request Jul 23, 2024
These operators were deprecated in
  P0768R1 Library Support for the Spaceship (Comparison) Operator

This was discovered while investigating the paper's implementation
status.
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
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
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.

5 participants