Skip to content

Commit c092e2a

Browse files
frederick-vs-jatru
authored andcommitted
[libc++] Fix uses of non-empty transparent comparator in <map> (llvm#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 llvm#152543. (cherry picked from commit 7ae1424)
1 parent ba87d05 commit c092e2a

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
@@ -692,12 +692,12 @@ public:
692692
# if _LIBCPP_STD_VER >= 14
693693
template <typename _K2>
694694
_LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {
695-
return __comp_(__x, __y.__get_value().first);
695+
return __comp_(__x, __y.first);
696696
}
697697

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

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)