diff --git a/libcxx/.clang-tidy b/libcxx/.clang-tidy --- a/libcxx/.clang-tidy +++ b/libcxx/.clang-tidy @@ -16,6 +16,7 @@ modernize-loop-convert, modernize-redundant-void-arg, modernize-use-override, + modernize-use-equals-delete, readability-duplicate-include, readability-identifier-naming, @@ -59,7 +60,6 @@ # modernize-use-bool-literals, # modernize-use-default-member-init, # modernize-use-equals-default, -# modernize-use-equals-delete, # modernize-use-nullptr, # portability-restrict-system-includes, # readability-function-cognitive-complexity, diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference --- a/libcxx/include/__bit_reference +++ b/libcxx/include/__bit_reference @@ -165,18 +165,17 @@ __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT : __seg_(__x.__seg_), __mask_(__x.__mask_) {} + __bit_const_reference& operator=(const __bit_const_reference&) = delete; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT {return static_cast(*__seg_ & __mask_);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT {return __bit_iterator<_Cp, true>(__seg_, static_cast(std::__libcpp_ctz(__mask_)));} private: - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT : __seg_(__s), __mask_(__m) {} - - __bit_const_reference& operator=(const __bit_const_reference&) = delete; }; // find diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h --- a/libcxx/include/__functional/function.h +++ b/libcxx/include/__functional/function.h @@ -261,9 +261,10 @@ template class __base<_Rp(_ArgTypes...)> { - __base(const __base&); - __base& operator=(const __base&); public: + __base(const __base&) = delete; + __base& operator=(const __base&) = delete; + _LIBCPP_INLINE_VISIBILITY __base() {} _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__base() {} virtual __base* __clone() const = 0; diff --git a/libcxx/include/__functional/reference_wrapper.h b/libcxx/include/__functional/reference_wrapper.h --- a/libcxx/include/__functional/reference_wrapper.h +++ b/libcxx/include/__functional/reference_wrapper.h @@ -35,7 +35,7 @@ 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 ::value, decltype(__fun(std::declval<_Up>())) > > diff --git a/libcxx/include/__locale b/libcxx/include/__locale --- a/libcxx/include/__locale +++ b/libcxx/include/__locale @@ -57,6 +57,9 @@ _LIBCPP_INLINE_VISIBILITY __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {} + __libcpp_locale_guard(__libcpp_locale_guard const&) = delete; + __libcpp_locale_guard& operator=(__libcpp_locale_guard const&) = delete; + _LIBCPP_INLINE_VISIBILITY ~__libcpp_locale_guard() { if (__old_loc_) @@ -64,9 +67,6 @@ } locale_t __old_loc_; -private: - __libcpp_locale_guard(__libcpp_locale_guard const&); - __libcpp_locale_guard& operator=(__libcpp_locale_guard const&); }; #elif defined(_LIBCPP_MSVCRT_LIKE) struct __libcpp_locale_guard { diff --git a/libcxx/include/__mutex/lock_guard.h b/libcxx/include/__mutex/lock_guard.h --- a/libcxx/include/__mutex/lock_guard.h +++ b/libcxx/include/__mutex/lock_guard.h @@ -40,7 +40,6 @@ : __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; }; diff --git a/libcxx/include/__ranges/ref_view.h b/libcxx/include/__ranges/ref_view.h --- a/libcxx/include/__ranges/ref_view.h +++ b/libcxx/include/__ranges/ref_view.h @@ -43,7 +43,7 @@ _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 diff --git a/libcxx/include/__tree b/libcxx/include/__tree --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -759,7 +759,6 @@ __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; @@ -774,7 +773,6 @@ __node_value_type __value_; -private: ~__tree_node() = delete; __tree_node(__tree_node const&) = delete; __tree_node& operator=(__tree_node const&) = delete; diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list --- a/libcxx/include/forward_list +++ b/libcxx/include/forward_list @@ -523,8 +523,9 @@ _LIBCPP_INLINE_VISIBILITY explicit __forward_list_base(const __node_allocator& __a) : __before_begin_(__begin_node(), __a) {} -#ifndef _LIBCPP_CXX03_LANG + public: +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY __forward_list_base(__forward_list_base&& __x) _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value); @@ -532,11 +533,9 @@ __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: ~__forward_list_base(); protected: diff --git a/libcxx/include/future b/libcxx/include/future --- a/libcxx/include/future +++ b/libcxx/include/future @@ -1627,8 +1627,6 @@ template class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_base<_Rp(_ArgTypes...)> { - __packaged_task_base(const __packaged_task_base&); - __packaged_task_base& operator=(const __packaged_task_base&); public: _LIBCPP_INLINE_VISIBILITY __packaged_task_base() {} diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd --- a/libcxx/include/iosfwd +++ b/libcxx/include/iosfwd @@ -244,8 +244,6 @@ fmtflags __fmtflags_; _CharT __fill_; - __save_flags(const __save_flags&); - __save_flags& operator=(const __save_flags&); public: _LIBCPP_INLINE_VISIBILITY explicit __save_flags(__stream_type& __stream) @@ -259,6 +257,9 @@ __stream_.flags(__fmtflags_); __stream_.fill(__fill_); } + + __save_flags(const __save_flags&) = delete; + __save_flags& operator=(const __save_flags&) = delete; }; _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/istream b/libcxx/include/istream --- a/libcxx/include/istream +++ b/libcxx/include/istream @@ -211,9 +211,9 @@ basic_ios::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; diff --git a/libcxx/include/list b/libcxx/include/list --- a/libcxx/include/list +++ b/libcxx/include/list @@ -548,9 +548,10 @@ template 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 __alloc_traits; typedef typename __alloc_traits::size_type size_type; diff --git a/libcxx/include/locale b/libcxx/include/locale --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -3616,8 +3616,6 @@ 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_INLINE_VISIBILITY @@ -3640,6 +3638,9 @@ #endif ~wstring_convert(); + wstring_convert(const wstring_convert& __wc) = delete; + wstring_convert& operator=(const wstring_convert& __wc) = delete; + _LIBCPP_INLINE_VISIBILITY wide_string from_bytes(char __byte) {return from_bytes(&__byte, &__byte+1);} @@ -3898,9 +3899,6 @@ bool __owns_ib_; bool __always_noconv_; - wbuffer_convert(const wbuffer_convert&); - wbuffer_convert& operator=(const wbuffer_convert&); - public: #ifndef _LIBCPP_CXX03_LANG wbuffer_convert() : wbuffer_convert(nullptr) {} @@ -3916,6 +3914,9 @@ ~wbuffer_convert(); + wbuffer_convert(const wbuffer_convert&) = delete; + wbuffer_convert& operator=(const wbuffer_convert&) = delete; + _LIBCPP_INLINE_VISIBILITY streambuf* rdbuf() const {return __bufptr_;} _LIBCPP_INLINE_VISIBILITY diff --git a/libcxx/include/map b/libcxx/include/map --- a/libcxx/include/map +++ b/libcxx/include/map @@ -693,8 +693,6 @@ private: allocator_type& __na_; - __map_node_destructor& operator=(const __map_node_destructor&); - public: bool __first_constructed; bool __second_constructed; @@ -717,6 +715,8 @@ } #endif // _LIBCPP_CXX03_LANG + __map_node_destructor& operator=(const __map_node_destructor&) = delete; + _LIBCPP_INLINE_VISIBILITY void operator()(pointer __p) _NOEXCEPT { @@ -810,7 +810,6 @@ return *this; } -private: __value_type() = delete; ~__value_type() = delete; __value_type(const __value_type&) = delete; @@ -835,11 +834,10 @@ _LIBCPP_INLINE_VISIBILITY 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 diff --git a/libcxx/include/ostream b/libcxx/include/ostream --- a/libcxx/include/ostream +++ b/libcxx/include/ostream @@ -203,6 +203,10 @@ explicit basic_ostream(basic_streambuf* __sb) { this->init(__sb); } ~basic_ostream() override; + + basic_ostream (const basic_ostream& __rhs) = delete; + basic_ostream& operator=(const basic_ostream& __rhs) = delete; + protected: inline _LIBCPP_INLINE_VISIBILITY basic_ostream(basic_ostream&& __rhs); @@ -215,9 +219,6 @@ void swap(basic_ostream& __rhs) { basic_ios::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; diff --git a/libcxx/include/regex b/libcxx/include/regex --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -1442,10 +1442,8 @@ template class __node { - __node(const __node&); - __node& operator=(const __node&); public: - typedef _VSTD::__state<_CharT> __state; + typedef __state<_CharT> __state; _LIBCPP_INLINE_VISIBILITY __node() {} @@ -2219,15 +2217,16 @@ _CharT __c_; - __match_char(const __match_char&); - __match_char& operator=(const __match_char&); public: - typedef _VSTD::__state<_CharT> __state; + typedef __state<_CharT> __state; _LIBCPP_INLINE_VISIBILITY __match_char(_CharT __c, __node<_CharT>* __s) : base(__s), __c_(__c) {} + __match_char(const __match_char&) = delete; + __match_char& operator=(const __match_char&) = delete; + virtual void __exec(__state&) const; }; @@ -2259,15 +2258,16 @@ _Traits __traits_; _CharT __c_; - __match_char_icase(const __match_char_icase&); - __match_char_icase& operator=(const __match_char_icase&); public: - typedef _VSTD::__state<_CharT> __state; + typedef __state<_CharT> __state; _LIBCPP_INLINE_VISIBILITY __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s) : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {} + __match_char_icase(const __match_char_icase&) = delete; + __match_char_icase& operator=(const __match_char_icase&) = delete; + virtual void __exec(__state&) const; }; @@ -2300,15 +2300,16 @@ _Traits __traits_; _CharT __c_; - __match_char_collate(const __match_char_collate&); - __match_char_collate& operator=(const __match_char_collate&); public: - typedef _VSTD::__state<_CharT> __state; + typedef __state<_CharT> __state; _LIBCPP_INLINE_VISIBILITY __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s) : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {} + __match_char_collate(const __match_char_collate&) = delete; + __match_char_collate& operator=(const __match_char_collate&) = delete; + virtual void __exec(__state&) const; }; @@ -2352,10 +2353,8 @@ bool __collate_; bool __might_have_digraph_; - __bracket_expression(const __bracket_expression&); - __bracket_expression& operator=(const __bracket_expression&); public: - typedef _VSTD::__state<_CharT> __state; + typedef __state<_CharT> __state; _LIBCPP_INLINE_VISIBILITY __bracket_expression(const _Traits& __traits, __node<_CharT>* __s, @@ -2364,6 +2363,9 @@ __negate_(__negate), __icase_(__icase), __collate_(__collate), __might_have_digraph_(__traits_.getloc().name() != "C") {} + __bracket_expression(const __bracket_expression&) = delete; + __bracket_expression& operator=(const __bracket_expression&) = delete; + virtual void __exec(__state&) const; _LIBCPP_INLINE_VISIBILITY @@ -3147,15 +3149,16 @@ unsigned __mexp_; bool __invert_; - __lookahead(const __lookahead&); - __lookahead& operator=(const __lookahead&); public: - typedef _VSTD::__state<_CharT> __state; + typedef __state<_CharT> __state; _LIBCPP_INLINE_VISIBILITY __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp) : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {} + __lookahead(const __lookahead&) = delete; + __lookahead& operator=(const __lookahead&) = delete; + virtual void __exec(__state&) const; }; diff --git a/libcxx/include/thread b/libcxx/include/thread --- a/libcxx/include/thread +++ b/libcxx/include/thread @@ -154,9 +154,6 @@ __thread_specific_ptr(); friend _LIBCPP_FUNC_VIS __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: @@ -164,6 +161,9 @@ ~__thread_specific_ptr(); + __thread_specific_ptr(const __thread_specific_ptr&) = delete; + __thread_specific_ptr& operator=(const __thread_specific_ptr&) = delete; + _LIBCPP_INLINE_VISIBILITY pointer get() const {return static_cast<_Tp*>(__libcpp_tls_get(__key_));} _LIBCPP_INLINE_VISIBILITY diff --git a/libcxx/include/tuple b/libcxx/include/tuple --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -303,8 +303,6 @@ #endif } - _LIBCPP_CONSTEXPR_SINCE_CXX14 - __tuple_leaf& operator=(const __tuple_leaf&); public: _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf() _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_() @@ -369,11 +367,12 @@ __tuple_leaf(const __tuple_leaf& __t) = default; __tuple_leaf(__tuple_leaf&& __t) = default; + __tuple_leaf& operator=(const __tuple_leaf&) = delete; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) { - _VSTD::swap(*this, __t); + std::swap(*this, __t); return 0; } @@ -391,8 +390,6 @@ class __tuple_leaf<_Ip, _Hp, true> : private _Hp { - _LIBCPP_CONSTEXPR_SINCE_CXX14 - __tuple_leaf& operator=(const __tuple_leaf&); public: _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf() _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {} @@ -440,12 +437,13 @@ __tuple_leaf(__tuple_leaf const &) = default; __tuple_leaf(__tuple_leaf &&) = default; + __tuple_leaf& operator=(const __tuple_leaf&) = delete; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) { - _VSTD::swap(*this, __t); + std::swap(*this, __t); return 0; } diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map --- a/libcxx/include/unordered_map +++ b/libcxx/include/unordered_map @@ -756,14 +756,11 @@ typedef allocator_traits __alloc_traits; public: - typedef typename __alloc_traits::pointer pointer; -private: +private: allocator_type& __na_; - __hash_map_node_destructor& operator=(const __hash_map_node_destructor&); - public: bool __first_constructed; bool __second_constructed; @@ -796,6 +793,8 @@ } #endif // _LIBCPP_CXX03_LANG + __hash_map_node_destructor& operator=(const __hash_map_node_destructor&) = delete; + _LIBCPP_INLINE_VISIBILITY void operator()(pointer __p) _NOEXCEPT { @@ -882,7 +881,6 @@ return *this; } -private: __hash_value_type(const __hash_value_type& __v) = delete; __hash_value_type(__hash_value_type&& __v) = delete; template @@ -909,8 +907,7 @@ _LIBCPP_INLINE_VISIBILITY const value_type& __get_value() const { return __cc_; } -private: - ~__hash_value_type(); + ~__hash_value_type() = delete; }; #endif diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -789,6 +789,7 @@ __v_.__annotate_increase(__n); #endif } + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { __v_.__end_ = __pos_; #ifndef _LIBCPP_HAS_NO_ASAN @@ -798,13 +799,12 @@ #endif } + _ConstructTransaction(_ConstructTransaction const&) = delete; + _ConstructTransaction& operator=(_ConstructTransaction const&) = delete; + vector &__v_; pointer __pos_; const_pointer const __new_end_; - - private: - _ConstructTransaction(_ConstructTransaction const&) = delete; - _ConstructTransaction& operator=(_ConstructTransaction const&) = delete; }; template