Skip to content

Commit f4d8b67

Browse files
committed
[libc++] Split removing iterator bases and removing the second member in reverse_iterator
1 parent 9f9b480 commit f4d8b67

File tree

13 files changed

+61
-69
lines changed

13 files changed

+61
-69
lines changed

libcxx/docs/ABIGuarantees.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ This removes the ``iterator`` base class from ``back_insert_iterator``, ``front_
4444
This doesn't directly affect the layout of these types in most cases, but may result in more padding being used when
4545
they are used in combination, for example ``reverse_iterator<reverse_iterator<T>>``.
4646

47+
``_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER``
48+
-------------------------------------------------
49+
This removes a second member in ``reverse_iterator`` that is unused after LWG2360.
50+
4751
``_LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION``
4852
-------------------------------------------------
4953
This changes the index type used inside ``variant`` to the smallest required type to reduce the datasize of variants in

libcxx/docs/ReleaseNotes/22.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,19 @@ Potentially breaking changes
7575
first element being returned from ``find`` will be broken, and ``lower_bound`` or ``equal_range`` should be used
7676
instead.
7777

78+
- The ABI flag ``_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER`` has been split off from
79+
``_LIBCPP_ABI_NO_ITERATOR_BASES``. If you are using this flag and care about ABI stability, you should set
80+
``_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER`` as well.
81+
7882
Announcements About Future Releases
7983
-----------------------------------
8084

8185
ABI Affecting Changes
8286
---------------------
8387

88+
- The ABI flag ``_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER`` has been split off from
89+
``_LIBCPP_ABI_NO_ITERATOR_BASES``. If you are using this flag and care about ABI stability, you should set
90+
``_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER`` as well.
91+
8492
Build System Changes
8593
--------------------

libcxx/include/__configuration/abi.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
# define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE
7373
# define _LIBCPP_ABI_NO_ITERATOR_BASES
7474
# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
75+
# define _LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER
7576
# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
7677
# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
7778
# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
@@ -98,6 +99,15 @@
9899
# endif
99100
#endif
100101

102+
// TODO(LLVM 22): Remove this check
103+
#if defined(_LIBCPP_ABI_NO_ITERATOR_BASES) && !defined(_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER)
104+
# ifndef _LIBCPP_ONLY_NO_ITERATOR_BASES
105+
# error "You probably want to define _LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER. This has been split out from" \
106+
" _LIBCPP_ABI_NO_ITERATOR_BASES to allow only removing the second iterator member, since they aren't really related." \
107+
"If you actually want this ABI configuration, please define _LIBCPP_ONLY_NO_ITERATOR_BASES instead."
108+
# endif
109+
#endif
110+
101111
// We had some bugs where we use [[no_unique_address]] together with construct_at,
102112
// which causes UB as the call on construct_at could write to overlapping subobjects
103113
//

libcxx/include/__iterator/back_insert_iterator.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,9 @@ _LIBCPP_PUSH_MACROS
2626

2727
_LIBCPP_BEGIN_NAMESPACE_STD
2828

29-
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3029
template <class _Container>
3130
class back_insert_iterator
32-
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
33-
: public iterator<output_iterator_tag, void, void, void, void>
34-
#endif
35-
{
36-
_LIBCPP_SUPPRESS_DEPRECATED_POP
37-
31+
: public __iterator_base<back_insert_iterator<_Container>, output_iterator_tag, void, void, void, void> {
3832
protected:
3933
_Container* container;
4034

libcxx/include/__iterator/front_insert_iterator.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,9 @@ _LIBCPP_PUSH_MACROS
2626

2727
_LIBCPP_BEGIN_NAMESPACE_STD
2828

29-
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3029
template <class _Container>
3130
class front_insert_iterator
32-
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
33-
: public iterator<output_iterator_tag, void, void, void, void>
34-
#endif
35-
{
36-
_LIBCPP_SUPPRESS_DEPRECATED_POP
37-
31+
: public __iterator_base<front_insert_iterator<_Container>, output_iterator_tag, void, void, void, void> {
3832
protected:
3933
_Container* container;
4034

libcxx/include/__iterator/insert_iterator.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,9 @@ template <class _Container>
3535
using __insert_iterator_iter_t _LIBCPP_NODEBUG = typename _Container::iterator;
3636
#endif
3737

38-
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3938
template <class _Container>
4039
class insert_iterator
41-
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
42-
: public iterator<output_iterator_tag, void, void, void, void>
43-
#endif
44-
{
45-
_LIBCPP_SUPPRESS_DEPRECATED_POP
46-
40+
: public __iterator_base<insert_iterator<_Container>, output_iterator_tag, void, void, void, void> {
4741
protected:
4842
_Container* container;
4943
__insert_iterator_iter_t<_Container> iter;

libcxx/include/__iterator/istream_iterator.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525

2626
_LIBCPP_BEGIN_NAMESPACE_STD
2727

28-
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
2928
template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t>
3029
class istream_iterator
31-
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
32-
: public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&>
33-
#endif
34-
{
35-
_LIBCPP_SUPPRESS_DEPRECATED_POP
36-
30+
: public __iterator_base<istream_iterator<_Tp, _CharT, _Traits, _Distance>,
31+
input_iterator_tag,
32+
_Tp,
33+
_Distance,
34+
const _Tp*,
35+
const _Tp&> {
3736
public:
3837
typedef input_iterator_tag iterator_category;
3938
typedef _Tp value_type;

libcxx/include/__iterator/istreambuf_iterator.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525

2626
_LIBCPP_BEGIN_NAMESPACE_STD
2727

28-
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
2928
template <class _CharT, class _Traits>
3029
class istreambuf_iterator
31-
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
32-
: public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT>
33-
#endif
34-
{
35-
_LIBCPP_SUPPRESS_DEPRECATED_POP
36-
30+
: public __iterator_base<istreambuf_iterator<_CharT, _Traits>,
31+
input_iterator_tag,
32+
_CharT,
33+
typename _Traits::off_type,
34+
_CharT*,
35+
_CharT> {
3736
public:
3837
typedef input_iterator_tag iterator_category;
3938
typedef _CharT value_type;

libcxx/include/__iterator/iterator.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ struct _LIBCPP_DEPRECATED_IN_CXX17 iterator {
2828
typedef _Category iterator_category;
2929
};
3030

31+
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
32+
#ifdef _LIBCPP_ABI_NO_ITERATOR_BASES
33+
template <class _Derived>
34+
struct __no_iterator_base {};
35+
36+
template <class _Derived, class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
37+
using __iterator_base _LIBCPP_NODEBUG = __no_iterator_base<_Derived>;
38+
#else
39+
template <class _Derived, class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
40+
using __iterator_base _LIBCPP_NODEBUG = iterator<_Category, _Tp, _Distance, _Pointer, _Reference>;
41+
#endif
42+
_LIBCPP_SUPPRESS_DEPRECATED_POP
43+
3144
_LIBCPP_END_NAMESPACE_STD
3245

3346
#endif // _LIBCPP___ITERATOR_ITERATOR_H

libcxx/include/__iterator/ostream_iterator.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,9 @@
2424

2525
_LIBCPP_BEGIN_NAMESPACE_STD
2626

27-
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
2827
template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
2928
class ostream_iterator
30-
#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
31-
: public iterator<output_iterator_tag, void, void, void, void>
32-
#endif
33-
{
34-
_LIBCPP_SUPPRESS_DEPRECATED_POP
35-
29+
: public __iterator_base<ostream_iterator<_Tp, _CharT, _Traits>, output_iterator_tag, void, void, void, void> {
3630
public:
3731
typedef output_iterator_tag iterator_category;
3832
typedef void value_type;

0 commit comments

Comments
 (0)