Skip to content

Commit 3658fd2

Browse files
[libc++] __uglify non-conforming member typedef base
Currently, libc++'s `bitset`, `forward_list`, and `list` have non-conforming member typedef name `base`. The typedef is private, but can cause ambiguity in name lookup. Some other classes in libc++ that are either implementation details or not precisely specified by the standard also have member typdef `base`. I think this can still be conforming.
1 parent 9d469b5 commit 3658fd2

File tree

7 files changed

+233
-176
lines changed

7 files changed

+233
-176
lines changed

libcxx/docs/ReleaseNotes/20.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ Deprecations and Removals
7878
supported as an extension anymore, please migrate any code that uses e.g. ``std::vector<const T>`` to be
7979
standards conforming.
8080

81-
- Non-conforming member typedefs ``iterator`` and ``const_iterator`` of ``std::bitset`` are removed. Previously, they
82-
were private but could cause ambiguity in name lookup. Code that expects such ambiguity will possibly not compile in
83-
LLVM 20.
81+
- Non-conforming member typedefs ``base``, ``iterator`` and ``const_iterator`` of ``std::bitset``, and member typedef
82+
``base`` of ``std::forward_list`` and ``std::list`` are removed. Previously, they were private but could cause
83+
ambiguity in name lookup. Code that expects such ambiguity will possibly not compile in LLVM 20.
8484

8585
- The function ``__libcpp_verbose_abort()`` is now ``noexcept``, to match ``std::terminate()``. (The combination of
8686
``noexcept`` and ``[[noreturn]]`` has special significance for function effects analysis.)

libcxx/include/bitset

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -612,15 +612,15 @@ class _LIBCPP_TEMPLATE_VIS bitset
612612
: private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> {
613613
public:
614614
static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1;
615-
typedef __bitset<__n_words, _Size> base;
615+
typedef __bitset<__n_words, _Size> __base;
616616

617617
public:
618618
typedef typename base::reference reference;
619619
typedef typename base::const_reference const_reference;
620620

621621
// 23.3.5.1 constructors:
622622
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}
623-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : base(__v) {}
623+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : __base(__v) {}
624624
template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0>
625625
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(
626626
const _CharT* __str,
@@ -681,11 +681,15 @@ public:
681681

682682
// element access:
683683
#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
684-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const { return base::__make_ref(__p); }
684+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const { return __base::__make_ref(__p); }
685685
#else
686-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const { return base::__make_ref(__p); }
686+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {
687+
return __base::__make_ref(__p);
688+
}
687689
#endif
688-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) { return base::__make_ref(__p); }
690+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) {
691+
return __base::__make_ref(__p);
692+
}
689693
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const;
690694
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const;
691695
template <class _CharT, class _Traits, class _Allocator>
@@ -726,54 +730,54 @@ private:
726730
_CharT __c = __str[__mp - 1 - __i];
727731
(*this)[__i] = _Traits::eq(__c, __one);
728732
}
729-
std::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
733+
std::fill(__base::__make_iter(__i), __base::__make_iter(_Size), false);
730734
}
731735

732-
_LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return base::__hash_code(); }
736+
_LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return __base::__hash_code(); }
733737

734738
friend struct hash<bitset>;
735739
};
736740

737741
template <size_t _Size>
738742
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
739743
bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT {
740-
base::operator&=(__rhs);
744+
__base::operator&=(__rhs);
741745
return *this;
742746
}
743747

744748
template <size_t _Size>
745749
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
746750
bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT {
747-
base::operator|=(__rhs);
751+
__base::operator|=(__rhs);
748752
return *this;
749753
}
750754

751755
template <size_t _Size>
752756
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
753757
bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT {
754-
base::operator^=(__rhs);
758+
__base::operator^=(__rhs);
755759
return *this;
756760
}
757761

758762
template <size_t _Size>
759763
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT {
760764
__pos = std::min(__pos, _Size);
761-
std::copy_backward(base::__make_iter(0), base::__make_iter(_Size - __pos), base::__make_iter(_Size));
762-
std::fill_n(base::__make_iter(0), __pos, false);
765+
std::copy_backward(__base::__make_iter(0), __base::__make_iter(_Size - __pos), __base::__make_iter(_Size));
766+
std::fill_n(__base::__make_iter(0), __pos, false);
763767
return *this;
764768
}
765769

766770
template <size_t _Size>
767771
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT {
768772
__pos = std::min(__pos, _Size);
769-
std::copy(base::__make_iter(__pos), base::__make_iter(_Size), base::__make_iter(0));
770-
std::fill_n(base::__make_iter(_Size - __pos), __pos, false);
773+
std::copy(__base::__make_iter(__pos), __base::__make_iter(_Size), __base::__make_iter(0));
774+
std::fill_n(__base::__make_iter(_Size - __pos), __pos, false);
771775
return *this;
772776
}
773777

774778
template <size_t _Size>
775779
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set() _NOEXCEPT {
776-
std::fill_n(base::__make_iter(0), _Size, true);
780+
std::fill_n(__base::__make_iter(0), _Size, true);
777781
return *this;
778782
}
779783

@@ -788,7 +792,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>
788792

789793
template <size_t _Size>
790794
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset() _NOEXCEPT {
791-
std::fill_n(base::__make_iter(0), _Size, false);
795+
std::fill_n(__base::__make_iter(0), _Size, false);
792796
return *this;
793797
}
794798

@@ -810,7 +814,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> bitset<
810814

811815
template <size_t _Size>
812816
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip() _NOEXCEPT {
813-
base::flip();
817+
__base::flip();
814818
return *this;
815819
}
816820

@@ -819,19 +823,19 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>
819823
if (__pos >= _Size)
820824
__throw_out_of_range("bitset flip argument out of range");
821825

822-
reference __r = base::__make_ref(__pos);
826+
reference __r = __base::__make_ref(__pos);
823827
__r = ~__r;
824828
return *this;
825829
}
826830

827831
template <size_t _Size>
828832
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long bitset<_Size>::to_ulong() const {
829-
return base::to_ulong();
833+
return __base::to_ulong();
830834
}
831835

832836
template <size_t _Size>
833837
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long bitset<_Size>::to_ullong() const {
834-
return base::to_ullong();
838+
return __base::to_ullong();
835839
}
836840

837841
template <size_t _Size>
@@ -868,13 +872,13 @@ bitset<_Size>::to_string(char __zero, char __one) const {
868872

869873
template <size_t _Size>
870874
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT {
871-
return static_cast<size_t>(std::count(base::__make_iter(0), base::__make_iter(_Size), true));
875+
return static_cast<size_t>(std::count(__base::__make_iter(0), __base::__make_iter(_Size), true));
872876
}
873877

874878
template <size_t _Size>
875879
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
876880
bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT {
877-
return std::equal(base::__make_iter(0), base::__make_iter(_Size), __rhs.__make_iter(0));
881+
return std::equal(__base::__make_iter(0), __base::__make_iter(_Size), __rhs.__make_iter(0));
878882
}
879883

880884
#if _LIBCPP_STD_VER <= 17
@@ -896,12 +900,12 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(siz
896900

897901
template <size_t _Size>
898902
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::all() const _NOEXCEPT {
899-
return base::all();
903+
return __base::all();
900904
}
901905

902906
template <size_t _Size>
903907
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::any() const _NOEXCEPT {
904-
return base::any();
908+
return __base::any();
905909
}
906910

907911
template <size_t _Size>

0 commit comments

Comments
 (0)