Skip to content

Commit 7ae1424

Browse files
[libc++] Fix uses of non-empty transparent comparator in <map> (#152624)
The `__get_value()` member function was removed in LLVM 21, but the calls in `<map>` weren't removed. This patch completes the removal and adds regression test cases. Fixes #152543.
1 parent b698927 commit 7ae1424

File tree

12 files changed

+65
-2
lines changed

12 files changed

+65
-2
lines changed

libcxx/include/map

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,12 +691,12 @@ public:
691691
# if _LIBCPP_STD_VER >= 14
692692
template <typename _K2>
693693
_LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {
694-
return __comp_(__x, __y.__get_value().first);
694+
return __comp_(__x, __y.first);
695695
}
696696

697697
template <typename _K2>
698698
_LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {
699-
return __comp_(__x.__get_value().first, __y);
699+
return __comp_(__x.first, __y);
700700
}
701701
# endif
702702
};

libcxx/test/std/containers/associative/map/map.ops/count0.pass.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ int main(int, char**) {
3333
typedef std::map<int, double, transparent_less_not_referenceable> M;
3434
assert(M().count(C2Int{5}) == 0);
3535
}
36+
{
37+
using M = std::map<int, double, transparent_less_nonempty>;
38+
assert(M().count(C2Int{5}) == 0);
39+
}
3640

3741
return 0;
3842
}

libcxx/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ int main(int, char**) {
4040
P result = example.equal_range(C2Int{5});
4141
assert(result.first == result.second);
4242
}
43+
{
44+
using M = std::map<int, double, transparent_less_nonempty>;
45+
using P = std::pair<typename M::iterator, typename M::iterator>;
46+
M example;
47+
P result = example.equal_range(C2Int{5});
48+
assert(result.first == result.second);
49+
}
4350

4451
return 0;
4552
}

libcxx/test/std/containers/associative/map/map.ops/find0.pass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ int main(int, char**) {
3636
M example;
3737
assert(example.find(C2Int{5}) == example.end());
3838
}
39+
{
40+
using M = std::map<int, double, transparent_less_nonempty>;
41+
M example;
42+
assert(example.find(C2Int{5}) == example.end());
43+
}
3944

4045
return 0;
4146
}

libcxx/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ int main(int, char**) {
3636
M example;
3737
assert(example.lower_bound(C2Int{5}) == example.end());
3838
}
39+
{
40+
using M = std::map<int, double, transparent_less_nonempty>;
41+
M example;
42+
assert(example.lower_bound(C2Int{5}) == example.end());
43+
}
3944

4045
return 0;
4146
}

libcxx/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ int main(int, char**) {
3636
M example;
3737
assert(example.upper_bound(C2Int{5}) == example.end());
3838
}
39+
{
40+
using M = std::map<int, double, transparent_less_nonempty>;
41+
M example;
42+
assert(example.upper_bound(C2Int{5}) == example.end());
43+
}
3944

4045
return 0;
4146
}

libcxx/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ int main(int, char**) {
3333
typedef std::multimap<int, double, transparent_less_not_referenceable> M;
3434
assert(M().count(C2Int{5}) == 0);
3535
}
36+
{
37+
using M = std::multimap<int, double, transparent_less_nonempty>;
38+
assert(M().count(C2Int{5}) == 0);
39+
}
3640

3741
return 0;
3842
}

libcxx/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ int main(int, char**) {
4040
P result = example.equal_range(C2Int{5});
4141
assert(result.first == result.second);
4242
}
43+
{
44+
using M = std::multimap<int, double, transparent_less_nonempty>;
45+
using P = std::pair<typename M::iterator, typename M::iterator>;
46+
M example;
47+
P result = example.equal_range(C2Int{5});
48+
assert(result.first == result.second);
49+
}
4350

4451
return 0;
4552
}

libcxx/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ int main(int, char**) {
3636
M example;
3737
assert(example.find(C2Int{5}) == example.end());
3838
}
39+
{
40+
using M = std::multimap<int, double, transparent_less_nonempty>;
41+
M example;
42+
assert(example.find(C2Int{5}) == example.end());
43+
}
3944

4045
return 0;
4146
}

libcxx/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ int main(int, char**) {
3636
M example;
3737
assert(example.lower_bound(C2Int{5}) == example.end());
3838
}
39+
{
40+
using M = std::multimap<int, double, transparent_less_nonempty>;
41+
M example;
42+
assert(example.lower_bound(C2Int{5}) == example.end());
43+
}
3944

4045
return 0;
4146
}

0 commit comments

Comments
 (0)