Skip to content

[libc++] Enable modernize-use-equals-delete #93293

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

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Checks: >
modernize-redundant-void-arg,
modernize-use-nullptr,
modernize-use-override,
modernize-use-equals-delete,

readability-duplicate-include,
readability-identifier-naming,
Expand Down Expand Up @@ -72,7 +73,6 @@ CheckOptions:
# modernize-use-bool-literals,
# modernize-use-default-member-init,
# modernize-use-equals-default,
# modernize-use-equals-delete,
# portability-restrict-system-includes,
# readability-function-cognitive-complexity,
# readability-implicit-bool-conversion,
Expand Down
3 changes: 1 addition & 2 deletions libcxx/include/__bit_reference
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public:
using __container = typename _Cp::__self;

_LIBCPP_HIDE_FROM_ABI __bit_const_reference(const __bit_const_reference&) = default;
__bit_const_reference& operator=(const __bit_const_reference&) = delete;

_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
: __seg_(__x.__seg_),
Expand All @@ -167,8 +168,6 @@ private:
__storage_pointer __s, __storage_type __m) _NOEXCEPT
: __seg_(__s),
__mask_(__m) {}

__bit_const_reference& operator=(const __bit_const_reference&) = delete;
};

// copy
Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/__functional/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ class _LIBCPP_TEMPLATE_VIS __base;

template <class _Rp, class... _ArgTypes>
class __base<_Rp(_ArgTypes...)> {
__base(const __base&);
__base& operator=(const __base&);

public:
__base(const __base&) = delete;
__base& operator=(const __base&) = delete;

_LIBCPP_HIDE_FROM_ABI __base() {}
_LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__base() {}
virtual __base* __clone() const = 0;
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__functional/reference_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp> {
type* __f_;

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

public:
template <class _Up,
Expand Down
5 changes: 2 additions & 3 deletions libcxx/include/__locale_dir/locale_base_api/locale_guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ struct __libcpp_locale_guard {

locale_t __old_loc_;

private:
__libcpp_locale_guard(__libcpp_locale_guard const&);
__libcpp_locale_guard& operator=(__libcpp_locale_guard const&);
__libcpp_locale_guard(__libcpp_locale_guard const&) = delete;
__libcpp_locale_guard& operator=(__libcpp_locale_guard const&) = delete;
};
#elif defined(_LIBCPP_MSVCRT_LIKE)
struct __libcpp_locale_guard {
Expand Down
1 change: 0 additions & 1 deletion libcxx/include/__mutex/lock_guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) loc
: __m_(__m) {}
_LIBCPP_HIDE_FROM_ABI ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); }

private:
lock_guard(lock_guard const&) = delete;
lock_guard& operator=(lock_guard const&) = delete;
};
Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/__ostream/basic_ostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Tra
}
~basic_ostream() override;

basic_ostream(const basic_ostream& __rhs) = delete;
basic_ostream& operator=(const basic_ostream& __rhs) = delete;

protected:
inline _LIBCPP_HIDE_FROM_ABI basic_ostream(basic_ostream&& __rhs);

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

basic_ostream(const basic_ostream& __rhs) = delete;
basic_ostream& operator=(const basic_ostream& __rhs) = delete;

public:
// 27.7.2.4 Prefix/suffix:
class _LIBCPP_TEMPLATE_VIS sentry;
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__ranges/ref_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ref_view : public view_interface<ref_view<_Range>> {
_Range* __range_;

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

public:
template <class _Tp>
Expand Down
5 changes: 2 additions & 3 deletions libcxx/include/__thread/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ class __thread_specific_ptr {
__thread_specific_ptr();
friend _LIBCPP_EXPORTED_FROM_ABI __thread_specific_ptr<__thread_struct>& __thread_local_data();

__thread_specific_ptr(const __thread_specific_ptr&);
__thread_specific_ptr& operator=(const __thread_specific_ptr&);

_LIBCPP_HIDDEN static void _LIBCPP_TLS_DESTRUCTOR_CC __at_thread_exit(void*);

public:
typedef _Tp* pointer;

__thread_specific_ptr(const __thread_specific_ptr&) = delete;
__thread_specific_ptr& operator=(const __thread_specific_ptr&) = delete;
~__thread_specific_ptr();

_LIBCPP_HIDE_FROM_ABI pointer get() const { return static_cast<_Tp*>(__libcpp_tls_get(__key_)); }
Expand Down
2 changes: 0 additions & 2 deletions libcxx/include/__tree
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ public:

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

private:
~__tree_node_base() = delete;
__tree_node_base(__tree_node_base const&) = delete;
__tree_node_base& operator=(__tree_node_base const&) = delete;
Expand All @@ -666,7 +665,6 @@ public:

_LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }

private:
~__tree_node() = delete;
__tree_node(__tree_node const&) = delete;
__tree_node& operator=(__tree_node const&) = delete;
Expand Down
8 changes: 3 additions & 5 deletions libcxx/include/forward_list
Original file line number Diff line number Diff line change
Expand Up @@ -510,19 +510,17 @@ protected:
: __before_begin_(__begin_node(), __node_allocator(__a)) {}
_LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a)
: __before_begin_(__begin_node(), __a) {}
#ifndef _LIBCPP_CXX03_LANG

public:
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x)
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
_LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x, const allocator_type& __a);
#endif // _LIBCPP_CXX03_LANG

private:
__forward_list_base(const __forward_list_base&);
__forward_list_base& operator=(const __forward_list_base&);
__forward_list_base(const __forward_list_base&) = delete;
__forward_list_base& operator=(const __forward_list_base&) = delete;

public:
_LIBCPP_HIDE_FROM_ABI ~__forward_list_base();

protected:
Expand Down
5 changes: 2 additions & 3 deletions libcxx/include/future
Original file line number Diff line number Diff line change
Expand Up @@ -1384,11 +1384,10 @@ class __packaged_task_base;

template <class _Rp, class... _ArgTypes>
class __packaged_task_base<_Rp(_ArgTypes...)> {
__packaged_task_base(const __packaged_task_base&);
__packaged_task_base& operator=(const __packaged_task_base&);

public:
_LIBCPP_HIDE_FROM_ABI __packaged_task_base() {}
__packaged_task_base(const __packaged_task_base&) = delete;
__packaged_task_base& operator=(const __packaged_task_base&) = delete;
_LIBCPP_HIDE_FROM_ABI_VIRTUAL
virtual ~__packaged_task_base() {}
virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0;
Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/iosfwd
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ class __save_flags {
fmtflags __fmtflags_;
_CharT __fill_;

__save_flags(const __save_flags&);
__save_flags& operator=(const __save_flags&);

public:
__save_flags(const __save_flags&) = delete;
__save_flags& operator=(const __save_flags&) = delete;

_LIBCPP_HIDE_FROM_ABI explicit __save_flags(__stream_type& __stream)
: __stream_(__stream), __fmtflags_(__stream.flags()), __fill_(__stream.fill()) {}
_LIBCPP_HIDE_FROM_ABI ~__save_flags() {
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/istream
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ protected:
basic_ios<char_type, traits_type>::swap(__rhs);
}

public:
basic_istream(const basic_istream& __rhs) = delete;
basic_istream& operator=(const basic_istream& __rhs) = delete;

public:
// 27.7.1.1.3 Prefix/suffix:
class _LIBCPP_TEMPLATE_VIS sentry;

Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/list
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,10 @@ public:

template <class _Tp, class _Alloc>
class __list_imp {
__list_imp(const __list_imp&);
__list_imp& operator=(const __list_imp&);

public:
__list_imp(const __list_imp&) = delete;
__list_imp& operator=(const __list_imp&) = delete;

typedef _Alloc allocator_type;
typedef allocator_traits<allocator_type> __alloc_traits;
typedef typename __alloc_traits::size_type size_type;
Expand Down
12 changes: 6 additions & 6 deletions libcxx/include/locale
Original file line number Diff line number Diff line change
Expand Up @@ -3148,9 +3148,6 @@ private:
state_type __cvtstate_;
size_t __cvtcount_;

wstring_convert(const wstring_convert& __wc);
wstring_convert& operator=(const wstring_convert& __wc);

public:
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {}
Expand All @@ -3167,6 +3164,9 @@ public:
#endif
_LIBCPP_HIDE_FROM_ABI ~wstring_convert();

wstring_convert(const wstring_convert& __wc) = delete;
wstring_convert& operator=(const wstring_convert& __wc) = delete;

_LIBCPP_HIDE_FROM_ABI wide_string from_bytes(char __byte) { return from_bytes(&__byte, &__byte + 1); }
_LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __ptr) {
return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr));
Expand Down Expand Up @@ -3371,9 +3371,6 @@ private:
bool __owns_ib_;
bool __always_noconv_;

wbuffer_convert(const wbuffer_convert&);
wbuffer_convert& operator=(const wbuffer_convert&);

public:
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {}
Expand All @@ -3393,6 +3390,9 @@ public:
return __r;
}

wbuffer_convert(const wbuffer_convert&) = delete;
wbuffer_convert& operator=(const wbuffer_convert&) = delete;

_LIBCPP_HIDE_FROM_ABI state_type state() const { return __st_; }

protected:
Expand Down
14 changes: 6 additions & 8 deletions libcxx/include/map
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,6 @@ public:
private:
allocator_type& __na_;

__map_node_destructor& operator=(const __map_node_destructor&);

public:
bool __first_constructed;
bool __second_constructed;
Expand All @@ -735,6 +733,8 @@ public:
}
#endif // _LIBCPP_CXX03_LANG

__map_node_destructor& operator=(const __map_node_destructor&) = delete;

_LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {
if (__second_constructed)
__alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().second));
Expand Down Expand Up @@ -808,7 +808,6 @@ public:
return *this;
}

private:
__value_type() = delete;
~__value_type() = delete;
__value_type(const __value_type&) = delete;
Expand All @@ -830,11 +829,10 @@ public:
_LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; }
_LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; }

private:
__value_type();
__value_type(__value_type const&);
__value_type& operator=(__value_type const&);
~__value_type();
__value_type() = delete;
__value_type(__value_type const&) = delete;
__value_type& operator=(__value_type const&) = delete;
~__value_type() = delete;
};

#endif // _LIBCPP_CXX03_LANG
Expand Down
Loading
Loading