Skip to content

Commit b86aaac

Browse files
authored
Revert "[libc++] Avoid constructing additional objects when using map::at" (#160738)
Reverts #157866 It breaks a lot of sanitizer buildbots
1 parent 57947ac commit b86aaac

File tree

13 files changed

+8
-211
lines changed

13 files changed

+8
-211
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,6 @@ set(files
839839
__type_traits/is_floating_point.h
840840
__type_traits/is_function.h
841841
__type_traits/is_fundamental.h
842-
__type_traits/is_generic_transparent_comparator.h
843842
__type_traits/is_implicit_lifetime.h
844843
__type_traits/is_implicitly_default_constructible.h
845844
__type_traits/is_integral.h
@@ -882,7 +881,6 @@ set(files
882881
__type_traits/make_32_64_or_128_bit.h
883882
__type_traits/make_const_lvalue_ref.h
884883
__type_traits/make_signed.h
885-
__type_traits/make_transparent.h
886884
__type_traits/make_unsigned.h
887885
__type_traits/maybe_const.h
888886
__type_traits/nat.h

libcxx/include/__algorithm/comp.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include <__config>
1313
#include <__type_traits/desugars_to.h>
14-
#include <__type_traits/is_generic_transparent_comparator.h>
1514
#include <__type_traits/is_integral.h>
1615

1716
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -49,9 +48,6 @@ inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true;
4948
template <class _Tp>
5049
inline const bool __desugars_to_v<__totally_ordered_less_tag, __less<>, _Tp, _Tp> = is_integral<_Tp>::value;
5150

52-
template <>
53-
inline const bool __is_generic_transparent_comparator_v<__less<> > = true;
54-
5551
_LIBCPP_END_NAMESPACE_STD
5652

5753
#endif // _LIBCPP___ALGORITHM_COMP_H

libcxx/include/__functional/is_transparent.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ inline const bool __is_transparent_v<_Tp, _Key, __void_t<typename _Tp::is_transp
2929

3030
#endif
3131

32-
// Two types are considered transparently comparable if `comparator(key, arg)` is equivalent to `comparator(key,
33-
// <implicit cast to KeyT>(arg))`.
34-
//
35-
// This is different from `__is_transparent_v`, which is only a property of the comparator and doesn't provide
36-
// additional semantic guarantees.
37-
template <class _Comparator, class _KeyT, class _Arg, class = void>
38-
inline const bool __is_transparently_comparable_v = false;
39-
4032
_LIBCPP_END_NAMESPACE_STD
4133

4234
#endif // _LIBCPP___FUNCTIONAL_IS_TRANSPARENT

libcxx/include/__functional/operations.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
#include <__functional/unary_function.h>
1616
#include <__fwd/functional.h>
1717
#include <__type_traits/desugars_to.h>
18-
#include <__type_traits/is_generic_transparent_comparator.h>
1918
#include <__type_traits/is_integral.h>
20-
#include <__type_traits/make_transparent.h>
2119
#include <__utility/forward.h>
2220

2321
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -379,14 +377,6 @@ struct less<void> {
379377
typedef void is_transparent;
380378
};
381379

382-
template <class _Tp>
383-
struct __make_transparent<less<_Tp> > {
384-
using type _LIBCPP_NODEBUG = less<>;
385-
};
386-
387-
template <>
388-
inline const bool __is_generic_transparent_comparator_v<less<>> = true;
389-
390380
template <class _Tp, class _Up>
391381
inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Up> = true;
392382

@@ -476,14 +466,6 @@ struct greater<void> {
476466

477467
template <class _Tp, class _Up>
478468
inline const bool __desugars_to_v<__greater_tag, greater<>, _Tp, _Up> = true;
479-
480-
template <class _Tp>
481-
struct __make_transparent<greater<_Tp>> {
482-
using type _LIBCPP_NODEBUG = greater<>;
483-
};
484-
485-
template <>
486-
inline const bool __is_generic_transparent_comparator_v<greater<>> = true;
487469
#endif
488470

489471
// Logical operations

libcxx/include/__functional/ranges_operations.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <__concepts/totally_ordered.h>
1515
#include <__config>
1616
#include <__type_traits/desugars_to.h>
17-
#include <__type_traits/is_generic_transparent_comparator.h>
1817
#include <__utility/forward.h>
1918

2019
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -109,12 +108,6 @@ inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true;
109108
template <class _Tp, class _Up>
110109
inline const bool __desugars_to_v<__greater_tag, ranges::greater, _Tp, _Up> = true;
111110

112-
template <>
113-
inline const bool __is_generic_transparent_comparator_v<ranges::less> = true;
114-
115-
template <>
116-
inline const bool __is_generic_transparent_comparator_v<ranges::greater> = true;
117-
118111
#endif // _LIBCPP_STD_VER >= 20
119112

120113
_LIBCPP_END_NAMESPACE_STD

libcxx/include/__tree

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include <__type_traits/is_same.h>
3535
#include <__type_traits/is_specialization.h>
3636
#include <__type_traits/is_swappable.h>
37-
#include <__type_traits/make_transparent.h>
3837
#include <__type_traits/remove_const.h>
3938
#include <__utility/forward.h>
4039
#include <__utility/lazy_synth_three_way_comparator.h>
@@ -1750,8 +1749,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const _Key& __v) {
17501749
}
17511750

17521751
__node_base_pointer* __node_ptr = __root_ptr();
1753-
auto&& __transparent = std::__as_transparent(value_comp());
1754-
auto __comp = __lazy_synth_three_way_comparator<__make_transparent_t<_Compare>, _Key, value_type>(__transparent);
1752+
auto __comp = __lazy_synth_three_way_comparator<_Compare, _Key, value_type>(value_comp());
17551753

17561754
while (true) {
17571755
auto __comp_res = __comp(__v, __nd->__get_value());

libcxx/include/__type_traits/is_generic_transparent_comparator.h

Lines changed: 0 additions & 30 deletions
This file was deleted.

libcxx/include/__type_traits/make_transparent.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

libcxx/include/map

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -600,10 +600,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
600600
# include <__ranges/from_range.h>
601601
# include <__tree>
602602
# include <__type_traits/container_traits.h>
603-
# include <__type_traits/desugars_to.h>
604603
# include <__type_traits/is_allocator.h>
605-
# include <__type_traits/is_convertible.h>
606-
# include <__type_traits/make_transparent.h>
607604
# include <__type_traits/remove_const.h>
608605
# include <__type_traits/type_identity.h>
609606
# include <__utility/forward.h>
@@ -669,11 +666,6 @@ public:
669666
# endif
670667
};
671668

672-
template <class _Key, class _MapValueT, class _Compare>
673-
struct __make_transparent<__map_value_compare<_Key, _MapValueT, _Compare> > {
674-
using type _LIBCPP_NODEBUG = __map_value_compare<_Key, _MapValueT, __make_transparent_t<_Compare> >;
675-
};
676-
677669
# if _LIBCPP_STD_VER >= 14
678670
template <class _MapValueT, class _Key, class _Compare>
679671
struct __lazy_synth_three_way_comparator<__map_value_compare<_Key, _MapValueT, _Compare>, _MapValueT, _MapValueT> {
@@ -1056,24 +1048,6 @@ public:
10561048
_LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k);
10571049
# endif
10581050

1059-
template <class _Arg,
1060-
__enable_if_t<__is_transparently_comparable_v<_Compare, key_type, __remove_cvref_t<_Arg> >, int> = 0>
1061-
_LIBCPP_HIDE_FROM_ABI mapped_type& at(_Arg&& __arg) {
1062-
auto [_, __child] = __tree_.__find_equal(__arg);
1063-
if (__child == nullptr)
1064-
std::__throw_out_of_range("map::at: key not found");
1065-
return static_cast<__node_pointer>(__child)->__get_value().second;
1066-
}
1067-
1068-
template <class _Arg,
1069-
__enable_if_t<__is_transparently_comparable_v<_Compare, key_type, __remove_cvref_t<_Arg> >, int> = 0>
1070-
_LIBCPP_HIDE_FROM_ABI const mapped_type& at(_Arg&& __arg) const {
1071-
auto [_, __child] = __tree_.__find_equal(__arg);
1072-
if (__child == nullptr)
1073-
std::__throw_out_of_range("map::at: key not found");
1074-
return static_cast<__node_pointer>(__child)->__get_value().second;
1075-
}
1076-
10771051
_LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k);
10781052
_LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const;
10791053

@@ -1268,15 +1242,11 @@ public:
12681242
_LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
12691243
_LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
12701244
# if _LIBCPP_STD_VER >= 14
1271-
template <typename _K2,
1272-
enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1273-
int> = 0>
1245+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
12741246
_LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
12751247
return __tree_.find(__k);
12761248
}
1277-
template <typename _K2,
1278-
enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1279-
int> = 0>
1249+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
12801250
_LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
12811251
return __tree_.find(__k);
12821252
}
@@ -1292,9 +1262,7 @@ public:
12921262

12931263
# if _LIBCPP_STD_VER >= 20
12941264
_LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1295-
template <typename _K2,
1296-
enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1297-
int> = 0>
1265+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
12981266
_LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
12991267
return find(__k) != end();
13001268
}
@@ -1303,16 +1271,12 @@ public:
13031271
_LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
13041272
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
13051273
# if _LIBCPP_STD_VER >= 14
1306-
template <typename _K2,
1307-
enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1308-
int> = 0>
1274+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13091275
_LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
13101276
return __tree_.lower_bound(__k);
13111277
}
13121278

1313-
template <typename _K2,
1314-
enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1315-
int> = 0>
1279+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13161280
_LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
13171281
return __tree_.lower_bound(__k);
13181282
}
@@ -1321,15 +1285,11 @@ public:
13211285
_LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
13221286
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
13231287
# if _LIBCPP_STD_VER >= 14
1324-
template <typename _K2,
1325-
enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1326-
int> = 0>
1288+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13271289
_LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
13281290
return __tree_.upper_bound(__k);
13291291
}
1330-
template <typename _K2,
1331-
enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1332-
int> = 0>
1292+
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13331293
_LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
13341294
return __tree_.upper_bound(__k);
13351295
}

libcxx/include/module.modulemap.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ module std_core [system] {
200200
header "__type_traits/is_fundamental.h"
201201
export std_core.type_traits.integral_constant
202202
}
203-
module is_generic_transparent_comparator { header "__type_traits/is_generic_transparent_comparator.h" }
204203
module is_implicit_lifetime {
205204
header "__type_traits/is_implicit_lifetime.h"
206205
export std_core.type_traits.integral_constant
@@ -354,7 +353,6 @@ module std_core [system] {
354353
module make_32_64_or_128_bit { header "__type_traits/make_32_64_or_128_bit.h" }
355354
module make_const_lvalue_ref { header "__type_traits/make_const_lvalue_ref.h" }
356355
module make_signed { header "__type_traits/make_signed.h" }
357-
module make_transparent { header "__type_traits/make_transparent.h" }
358356
module make_unsigned { header "__type_traits/make_unsigned.h" }
359357
module maybe_const { header "__type_traits/maybe_const.h" }
360358
module nat { header "__type_traits/nat.h" }

0 commit comments

Comments
 (0)