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;

libcxx/include/forward_list

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,19 +510,17 @@ protected:
510510
: __before_begin_(__begin_node(), __node_allocator(__a)) {}
511511
_LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a)
512512
: __before_begin_(__begin_node(), __a) {}
513-
#ifndef _LIBCPP_CXX03_LANG
514513

515514
public:
515+
#ifndef _LIBCPP_CXX03_LANG
516516
_LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x)
517517
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
518518
_LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x, const allocator_type& __a);
519519
#endif // _LIBCPP_CXX03_LANG
520520

521-
private:
522-
__forward_list_base(const __forward_list_base&);
523-
__forward_list_base& operator=(const __forward_list_base&);
521+
__forward_list_base(const __forward_list_base&) = delete;
522+
__forward_list_base& operator=(const __forward_list_base&) = delete;
524523

525-
public:
526524
_LIBCPP_HIDE_FROM_ABI ~__forward_list_base();
527525

528526
protected:

libcxx/include/future

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,11 +1384,10 @@ class __packaged_task_base;
13841384

13851385
template <class _Rp, class... _ArgTypes>
13861386
class __packaged_task_base<_Rp(_ArgTypes...)> {
1387-
__packaged_task_base(const __packaged_task_base&);
1388-
__packaged_task_base& operator=(const __packaged_task_base&);
1389-
13901387
public:
13911388
_LIBCPP_HIDE_FROM_ABI __packaged_task_base() {}
1389+
__packaged_task_base(const __packaged_task_base&) = delete;
1390+
__packaged_task_base& operator=(const __packaged_task_base&) = delete;
13921391
_LIBCPP_HIDE_FROM_ABI_VIRTUAL
13931392
virtual ~__packaged_task_base() {}
13941393
virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0;

libcxx/include/iosfwd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ class __save_flags {
169169
fmtflags __fmtflags_;
170170
_CharT __fill_;
171171

172-
__save_flags(const __save_flags&);
173-
__save_flags& operator=(const __save_flags&);
174-
175172
public:
173+
__save_flags(const __save_flags&) = delete;
174+
__save_flags& operator=(const __save_flags&) = delete;
175+
176176
_LIBCPP_HIDE_FROM_ABI explicit __save_flags(__stream_type& __stream)
177177
: __stream_(__stream), __fmtflags_(__stream.flags()), __fill_(__stream.fill()) {}
178178
_LIBCPP_HIDE_FROM_ABI ~__save_flags() {

libcxx/include/istream

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ protected:
216216
basic_ios<char_type, traits_type>::swap(__rhs);
217217
}
218218

219+
public:
219220
basic_istream(const basic_istream& __rhs) = delete;
220221
basic_istream& operator=(const basic_istream& __rhs) = delete;
221222

222-
public:
223223
// 27.7.1.1.3 Prefix/suffix:
224224
class _LIBCPP_TEMPLATE_VIS sentry;
225225

libcxx/include/list

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,10 @@ public:
465465

466466
template <class _Tp, class _Alloc>
467467
class __list_imp {
468-
__list_imp(const __list_imp&);
469-
__list_imp& operator=(const __list_imp&);
470-
471468
public:
469+
__list_imp(const __list_imp&) = delete;
470+
__list_imp& operator=(const __list_imp&) = delete;
471+
472472
typedef _Alloc allocator_type;
473473
typedef allocator_traits<allocator_type> __alloc_traits;
474474
typedef typename __alloc_traits::size_type size_type;

libcxx/include/locale

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,9 +3148,6 @@ private:
31483148
state_type __cvtstate_;
31493149
size_t __cvtcount_;
31503150

3151-
wstring_convert(const wstring_convert& __wc);
3152-
wstring_convert& operator=(const wstring_convert& __wc);
3153-
31543151
public:
31553152
#ifndef _LIBCPP_CXX03_LANG
31563153
_LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {}
@@ -3167,6 +3164,9 @@ public:
31673164
#endif
31683165
_LIBCPP_HIDE_FROM_ABI ~wstring_convert();
31693166

3167+
wstring_convert(const wstring_convert& __wc) = delete;
3168+
wstring_convert& operator=(const wstring_convert& __wc) = delete;
3169+
31703170
_LIBCPP_HIDE_FROM_ABI wide_string from_bytes(char __byte) { return from_bytes(&__byte, &__byte + 1); }
31713171
_LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __ptr) {
31723172
return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr));
@@ -3371,9 +3371,6 @@ private:
33713371
bool __owns_ib_;
33723372
bool __always_noconv_;
33733373

3374-
wbuffer_convert(const wbuffer_convert&);
3375-
wbuffer_convert& operator=(const wbuffer_convert&);
3376-
33773374
public:
33783375
#ifndef _LIBCPP_CXX03_LANG
33793376
_LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {}
@@ -3393,6 +3390,9 @@ public:
33933390
return __r;
33943391
}
33953392

3393+
wbuffer_convert(const wbuffer_convert&) = delete;
3394+
wbuffer_convert& operator=(const wbuffer_convert&) = delete;
3395+
33963396
_LIBCPP_HIDE_FROM_ABI state_type state() const { return __st_; }
33973397

33983398
protected:

libcxx/include/map

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -715,8 +715,6 @@ public:
715715
private:
716716
allocator_type& __na_;
717717

718-
__map_node_destructor& operator=(const __map_node_destructor&);
719-
720718
public:
721719
bool __first_constructed;
722720
bool __second_constructed;
@@ -735,6 +733,8 @@ public:
735733
}
736734
#endif // _LIBCPP_CXX03_LANG
737735

736+
__map_node_destructor& operator=(const __map_node_destructor&) = delete;
737+
738738
_LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {
739739
if (__second_constructed)
740740
__alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().second));
@@ -808,7 +808,6 @@ public:
808808
return *this;
809809
}
810810

811-
private:
812811
__value_type() = delete;
813812
~__value_type() = delete;
814813
__value_type(const __value_type&) = delete;
@@ -830,11 +829,10 @@ public:
830829
_LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; }
831830
_LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; }
832831

833-
private:
834-
__value_type();
835-
__value_type(__value_type const&);
836-
__value_type& operator=(__value_type const&);
837-
~__value_type();
832+
__value_type() = delete;
833+
__value_type(__value_type const&) = delete;
834+
__value_type& operator=(__value_type const&) = delete;
835+
~__value_type() = delete;
838836
};
839837

840838
#endif // _LIBCPP_CXX03_LANG

0 commit comments

Comments
 (0)