Skip to content

Commit 70d94c3

Browse files
committed
[libc++] __bit_iterator mustn't rely on deprecated SMF generation.
This allows us to turn -Wdeprecated-copy back on. We turned it off in 3b71de4 because Clang's implementation became more stringent and started diagnosing the old code here. Differential Revision: https://reviews.llvm.org/D101183
1 parent 5529878 commit 70d94c3

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

libcxx/include/__bit_reference

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,28 +1114,26 @@ public:
11141114
#endif
11151115
{}
11161116

1117-
// avoid re-declaring a copy constructor for the non-const version.
1118-
using __type_for_copy_to_const =
1119-
_If<_IsConst, __bit_iterator<_Cp, false>, struct __private_nat>;
1120-
1117+
// When _IsConst=false, this is the copy constructor.
1118+
// It is non-trivial. Making it trivial would break ABI.
1119+
// When _IsConst=true, this is a converting constructor;
1120+
// the copy and move constructors are implicitly generated
1121+
// and trivial.
11211122
_LIBCPP_INLINE_VISIBILITY
1122-
__bit_iterator(const __type_for_copy_to_const& __it) _NOEXCEPT
1123+
__bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
11231124
: __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
11241125

1125-
// The non-const __bit_iterator has historically had a non-trivial
1126-
// copy constructor (as a quirk of its construction). We need to maintain
1127-
// this for ABI purposes.
1128-
using __type_for_abi_non_trivial_copy_ctor =
1129-
_If<!_IsConst, __bit_iterator, struct __private_nat>;
1130-
1131-
_LIBCPP_INLINE_VISIBILITY
1132-
__bit_iterator(__type_for_abi_non_trivial_copy_ctor const& __it) _NOEXCEPT
1133-
: __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
1134-
1135-
// Always declare the copy assignment operator since the implicit declaration
1136-
// is deprecated.
1126+
// When _IsConst=false, we have a user-provided copy constructor,
1127+
// so we must also provide a copy assignment operator because
1128+
// the implicit generation of a defaulted one is deprecated.
1129+
// When _IsConst=true, the assignment operators are
1130+
// implicitly generated and trivial.
11371131
_LIBCPP_INLINE_VISIBILITY
1138-
__bit_iterator& operator=(__bit_iterator const&) = default;
1132+
__bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {
1133+
__seg_ = __it.__seg_;
1134+
__ctz_ = __it.__ctz_;
1135+
return *this;
1136+
}
11391137

11401138
_LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT
11411139
{return reference(__seg_, __storage_type(1) << __ctz_);}

libcxx/utils/libcxx/test/params.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
'-Werror',
1414
'-Wall',
1515
'-Wextra',
16-
'-Wno-deprecated-copy',
1716
'-Wshadow',
1817
'-Wundef',
1918
'-Wno-unused-command-line-argument',

0 commit comments

Comments
 (0)