diff --git a/libcxx/.clang-tidy b/libcxx/.clang-tidy --- a/libcxx/.clang-tidy +++ b/libcxx/.clang-tidy @@ -11,6 +11,7 @@ -misc-unconventional-assign-operator, modernize-redundant-void-arg, + modernize-use-equals-delete, readability-duplicate-include, readability-function-cognitive-complexity, @@ -37,7 +38,6 @@ # modernize-use-bool-literals, # modernize-use-default-member-init, # modernize-use-equals-default, -# modernize-use-equals-delete, # modernize-use-nullptr, # modernize-use-override, # portability-restrict-system-includes, diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference --- a/libcxx/include/__bit_reference +++ b/libcxx/include/__bit_reference @@ -156,18 +156,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 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT {return __bit_iterator<_Cp, true>(__seg_, static_cast(__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 @@ -258,9 +258,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_INLINE_VISIBILITY 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(declval<_Up>())) > > diff --git a/libcxx/include/__locale b/libcxx/include/__locale --- a/libcxx/include/__locale +++ b/libcxx/include/__locale @@ -58,6 +58,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_) @@ -65,9 +68,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_base b/libcxx/include/__mutex_base --- a/libcxx/include/__mutex_base +++ b/libcxx/include/__mutex_base @@ -87,8 +87,8 @@ private: mutex_type& __m_; -public: +public: _LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) : __m_(__m) {__m_.lock();} @@ -99,7 +99,6 @@ _LIBCPP_INLINE_VISIBILITY ~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 @@ -40,7 +40,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/__split_buffer b/libcxx/include/__split_buffer --- a/libcxx/include/__split_buffer +++ b/libcxx/include/__split_buffer @@ -28,9 +28,6 @@ template > struct __split_buffer { -private: - __split_buffer(const __split_buffer&); - __split_buffer& operator=(const __split_buffer&); public: typedef _Tp value_type; typedef _Allocator allocator_type; @@ -76,6 +73,9 @@ is_nothrow_move_assignable::value) || !__alloc_traits::propagate_on_container_move_assignment::value); + __split_buffer(const __split_buffer&) = delete; + __split_buffer& operator=(const __split_buffer&) = delete; + _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;} _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;} _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;} diff --git a/libcxx/include/__tree b/libcxx/include/__tree --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -738,10 +738,9 @@ __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; + ~__tree_node_base() = delete; + __tree_node_base(__tree_node_base const&) = delete; + __tree_node_base& operator=(__tree_node_base const&) = delete; }; template @@ -753,10 +752,9 @@ __node_value_type __value_; -private: - ~__tree_node() = delete; - __tree_node(__tree_node const&) = delete; - __tree_node& operator=(__tree_node const&) = delete; + ~__tree_node() = delete; + __tree_node(__tree_node const&) = delete; + __tree_node& operator=(__tree_node const&) = delete; }; diff --git a/libcxx/include/deque b/libcxx/include/deque --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -922,8 +922,6 @@ template class __deque_base { - __deque_base(const __deque_base& __c); - __deque_base& operator=(const __deque_base& __c); public: typedef _Allocator allocator_type; typedef allocator_traits __alloc_traits; @@ -1041,6 +1039,8 @@ _LIBCPP_INLINE_VISIBILITY explicit __deque_base(const allocator_type& __a); public: + __deque_base(const __deque_base& __c) = delete; + __deque_base& operator=(const __deque_base& __c) = delete; ~__deque_base(); #ifndef _LIBCPP_CXX03_LANG diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list --- a/libcxx/include/forward_list +++ b/libcxx/include/forward_list @@ -503,8 +503,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); @@ -512,11 +513,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 @@ -1619,13 +1619,12 @@ 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() {} - _LIBCPP_INLINE_VISIBILITY - virtual ~__packaged_task_base() {} + _LIBCPP_HIDE_FROM_ABI __packaged_task_base() {} + _LIBCPP_HIDE_FROM_ABI virtual ~__packaged_task_base() {} + __packaged_task_base(const __packaged_task_base&) = delete; + __packaged_task_base& operator=(const __packaged_task_base&) = delete; + virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0; virtual void destroy() = 0; virtual void destroy_deallocate() = 0; diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd --- a/libcxx/include/iosfwd +++ b/libcxx/include/iosfwd @@ -269,8 +269,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) @@ -284,6 +282,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 @@ -205,9 +205,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 @@ -523,9 +523,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 @@ -3627,8 +3627,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 @@ -3651,6 +3649,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);} @@ -3905,9 +3906,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) {} @@ -3923,6 +3921,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 @@ -667,8 +667,6 @@ private: allocator_type& __na_; - __map_node_destructor& operator=(const __map_node_destructor&); - public: bool __first_constructed; bool __second_constructed; @@ -691,6 +689,8 @@ } #endif // _LIBCPP_CXX03_LANG + __map_node_destructor& operator=(const __map_node_destructor&) = delete; + _LIBCPP_INLINE_VISIBILITY void operator()(pointer __p) _NOEXCEPT { @@ -786,7 +786,6 @@ return *this; } -private: __value_type() = delete; ~__value_type() = delete; __value_type(const __value_type&) = delete; diff --git a/libcxx/include/ostream b/libcxx/include/ostream --- a/libcxx/include/ostream +++ b/libcxx/include/ostream @@ -165,6 +165,10 @@ explicit basic_ostream(basic_streambuf* __sb) { this->init(__sb); } virtual ~basic_ostream(); + + 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); @@ -177,9 +181,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 @@ -1422,16 +1422,17 @@ template class __node { - __node(const __node&); - __node& operator=(const __node&); public: - typedef _VSTD::__state<_CharT> __state; + typedef __state<_CharT> __state; _LIBCPP_INLINE_VISIBILITY __node() {} _LIBCPP_INLINE_VISIBILITY virtual ~__node() {} + __node(const __node&) = delete; + __node& operator=(const __node&) = delete; + _LIBCPP_INLINE_VISIBILITY virtual void __exec(__state&) const {} _LIBCPP_INLINE_VISIBILITY @@ -2199,15 +2200,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; }; @@ -2239,15 +2241,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; }; @@ -2280,15 +2283,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; }; @@ -2332,10 +2336,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, @@ -2344,6 +2346,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 @@ -3132,15 +3137,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 @@ -143,9 +143,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: @@ -153,6 +150,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 @@ -234,8 +234,6 @@ #endif } - _LIBCPP_CONSTEXPR_AFTER_CXX11 - __tuple_leaf& operator=(const __tuple_leaf&); public: _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf() _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_() @@ -300,11 +298,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_AFTER_CXX11 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) { - _VSTD::swap(*this, __t); + std::swap(*this, __t); return 0; } @@ -316,8 +315,6 @@ class __tuple_leaf<_Ip, _Hp, true> : private _Hp { - _LIBCPP_CONSTEXPR_AFTER_CXX11 - __tuple_leaf& operator=(const __tuple_leaf&); public: _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf() _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {} @@ -365,12 +362,13 @@ __tuple_leaf(__tuple_leaf const &) = default; __tuple_leaf(__tuple_leaf &&) = default; + __tuple_leaf& operator=(const __tuple_leaf&) = delete; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 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 @@ -740,14 +740,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; @@ -780,6 +777,8 @@ } #endif // _LIBCPP_CXX03_LANG + __hash_map_node_destructor& operator=(const __hash_map_node_destructor&) = delete; + _LIBCPP_INLINE_VISIBILITY void operator()(pointer __p) _NOEXCEPT { @@ -868,7 +867,6 @@ return *this; } -private: __hash_value_type(const __hash_value_type& __v) = delete; __hash_value_type(__hash_value_type&& __v) = delete; template diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -774,6 +774,7 @@ __v_.__annotate_increase(__n); #endif } + ~_ConstructTransaction() { __v_.__end_ = __pos_; #ifndef _LIBCPP_HAS_NO_ASAN @@ -783,13 +784,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