Skip to content

Commit bbe4a80

Browse files
authored
[libc++] Enable modernize-use-equals-delete (#93293)
Differential Revision: https://reviews.llvm.org/D121213
1 parent 6b4b29f commit bbe4a80

File tree

21 files changed

+61
-75
lines changed

21 files changed

+61
-75
lines changed

libcxx/.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Checks: >
1717
modernize-redundant-void-arg,
1818
modernize-use-nullptr,
1919
modernize-use-override,
20+
modernize-use-equals-delete,
2021
2122
readability-duplicate-include,
2223
readability-identifier-naming,
@@ -72,7 +73,6 @@ CheckOptions:
7273
# modernize-use-bool-literals,
7374
# modernize-use-default-member-init,
7475
# modernize-use-equals-default,
75-
# modernize-use-equals-delete,
7676
# portability-restrict-system-includes,
7777
# readability-function-cognitive-complexity,
7878
# readability-implicit-bool-conversion,

libcxx/include/__bit_reference

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public:
149149
using __container = typename _Cp::__self;
150150

151151
_LIBCPP_HIDE_FROM_ABI __bit_const_reference(const __bit_const_reference&) = default;
152+
__bit_const_reference& operator=(const __bit_const_reference&) = delete;
152153

153154
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
154155
: __seg_(__x.__seg_),
@@ -167,8 +168,6 @@ private:
167168
__storage_pointer __s, __storage_type __m) _NOEXCEPT
168169
: __seg_(__s),
169170
__mask_(__m) {}
170-
171-
__bit_const_reference& operator=(const __bit_const_reference&) = delete;
172171
};
173172

174173
// copy

libcxx/include/__functional/function.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,10 @@ class _LIBCPP_TEMPLATE_VIS __base;
232232

233233
template <class _Rp, class... _ArgTypes>
234234
class __base<_Rp(_ArgTypes...)> {
235-
__base(const __base&);
236-
__base& operator=(const __base&);
237-
238235
public:
236+
__base(const __base&) = delete;
237+
__base& operator=(const __base&) = delete;
238+
239239
_LIBCPP_HIDE_FROM_ABI __base() {}
240240
_LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__base() {}
241241
virtual __base* __clone() const = 0;

libcxx/include/__functional/reference_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp> {
3939
type* __f_;
4040

4141
static void __fun(_Tp&) _NOEXCEPT;
42-
static void __fun(_Tp&&) = delete;
42+
static void __fun(_Tp&&) = delete; // NOLINT(modernize-use-equals-delete) ; This is llvm.org/PR54276
4343

4444
public:
4545
template <class _Up,

libcxx/include/__locale_dir/locale_base_api/locale_guard.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ struct __libcpp_locale_guard {
3030

3131
locale_t __old_loc_;
3232

33-
private:
34-
__libcpp_locale_guard(__libcpp_locale_guard const&);
35-
__libcpp_locale_guard& operator=(__libcpp_locale_guard const&);
33+
__libcpp_locale_guard(__libcpp_locale_guard const&) = delete;
34+
__libcpp_locale_guard& operator=(__libcpp_locale_guard const&) = delete;
3635
};
3736
#elif defined(_LIBCPP_MSVCRT_LIKE)
3837
struct __libcpp_locale_guard {

libcxx/include/__mutex/lock_guard.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) loc
4040
: __m_(__m) {}
4141
_LIBCPP_HIDE_FROM_ABI ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); }
4242

43-
private:
4443
lock_guard(lock_guard const&) = delete;
4544
lock_guard& operator=(lock_guard const&) = delete;
4645
};

libcxx/include/__ostream/basic_ostream.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Tra
5252
}
5353
~basic_ostream() override;
5454

55+
basic_ostream(const basic_ostream& __rhs) = delete;
56+
basic_ostream& operator=(const basic_ostream& __rhs) = delete;
57+
5558
protected:
5659
inline _LIBCPP_HIDE_FROM_ABI basic_ostream(basic_ostream&& __rhs);
5760

@@ -62,9 +65,6 @@ class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Tra
6265
basic_ios<char_type, traits_type>::swap(__rhs);
6366
}
6467

65-
basic_ostream(const basic_ostream& __rhs) = delete;
66-
basic_ostream& operator=(const basic_ostream& __rhs) = delete;
67-
6868
public:
6969
// 27.7.2.4 Prefix/suffix:
7070
class _LIBCPP_TEMPLATE_VIS sentry;

libcxx/include/__ranges/ref_view.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ref_view : public view_interface<ref_view<_Range>> {
4343
_Range* __range_;
4444

4545
static void __fun(_Range&);
46-
static void __fun(_Range&&) = delete;
46+
static void __fun(_Range&&) = delete; // NOLINT(modernize-use-equals-delete) ; This is llvm.org/PR54276
4747

4848
public:
4949
template <class _Tp>

libcxx/include/__thread/thread.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,13 @@ class __thread_specific_ptr {
6969
__thread_specific_ptr();
7070
friend _LIBCPP_EXPORTED_FROM_ABI __thread_specific_ptr<__thread_struct>& __thread_local_data();
7171

72-
__thread_specific_ptr(const __thread_specific_ptr&);
73-
__thread_specific_ptr& operator=(const __thread_specific_ptr&);
74-
7572
_LIBCPP_HIDDEN static void _LIBCPP_TLS_DESTRUCTOR_CC __at_thread_exit(void*);
7673

7774
public:
7875
typedef _Tp* pointer;
7976

77+
__thread_specific_ptr(const __thread_specific_ptr&) = delete;
78+
__thread_specific_ptr& operator=(const __thread_specific_ptr&) = delete;
8079
~__thread_specific_ptr();
8180

8281
_LIBCPP_HIDE_FROM_ABI pointer get() const { return static_cast<_Tp*>(__libcpp_tls_get(__key_)); }

libcxx/include/__tree

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,6 @@ public:
651651

652652
_LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__parent_pointer>(__p); }
653653

654-
private:
655654
~__tree_node_base() = delete;
656655
__tree_node_base(__tree_node_base const&) = delete;
657656
__tree_node_base& operator=(__tree_node_base const&) = delete;
@@ -666,7 +665,6 @@ public:
666665

667666
_LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
668667

669-
private:
670668
~__tree_node() = delete;
671669
__tree_node(__tree_node const&) = delete;
672670
__tree_node& operator=(__tree_node const&) = delete;

0 commit comments

Comments
 (0)