[llvm-branch-commits] [libcxx] release/21.x: [libc++] Fix hash_multi{map, set}::insert (#149290) (PR #149435)
github-actions[bot] wrote: @frederick-vs-ja (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/149435 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/21.x: [libc++] Fix hash_multi{map, set}::insert (#149290) (PR #149435)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/149435 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/21.x: [libc++] Fix hash_multi{map, set}::insert (#149290) (PR #149435)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/149435
>From 564ed8e06421148f4a415df1cb154cd28572bfdb Mon Sep 17 00:00:00 2001
From: Nikolas Klauser
Date: Thu, 17 Jul 2025 23:23:04 +0200
Subject: [PATCH] [libc++] Fix hash_multi{map,set}::insert (#149290)
(cherry picked from commit be3d614cc13f016b16634e18e10caed508d183d2)
---
libcxx/include/ext/hash_map | 4 +--
libcxx/include/ext/hash_set | 4 +--
.../gnu/hash_multimap/insert.pass.cpp | 35 +++
.../gnu/hash_multiset/insert.pass.cpp | 35 +++
4 files changed, 74 insertions(+), 4 deletions(-)
create mode 100644 libcxx/test/extensions/gnu/hash_multimap/insert.pass.cpp
create mode 100644 libcxx/test/extensions/gnu/hash_multiset/insert.pass.cpp
diff --git a/libcxx/include/ext/hash_map b/libcxx/include/ext/hash_map
index d6b92204f4376..46815eaffa8bd 100644
--- a/libcxx/include/ext/hash_map
+++ b/libcxx/include/ext/hash_map
@@ -744,7 +744,7 @@ public:
_LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return
__table_.begin(); }
_LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }
- _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return
__table_.__emplace_unique(__x); }
+ _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return
__table_.__emplace_multi(__x); }
_LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x)
{ return insert(__x); }
template
_LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator
__last);
@@ -831,7 +831,7 @@ template
template
inline void hash_multimap<_Key, _Tp, _Hash, _Pred,
_Alloc>::insert(_InputIterator __first, _InputIterator __last) {
for (; __first != __last; ++__first)
-__table_.__emplace_unique(*__first);
+__table_.__emplace_multi(*__first);
}
template
diff --git a/libcxx/include/ext/hash_set b/libcxx/include/ext/hash_set
index 7fd5df24ed3a8..62a7a0dbcffb9 100644
--- a/libcxx/include/ext/hash_set
+++ b/libcxx/include/ext/hash_set
@@ -458,7 +458,7 @@ public:
_LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return
__table_.begin(); }
_LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }
- _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return
__table_.__emplace_unique(__x); }
+ _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return
__table_.__emplace_multi(__x); }
_LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x)
{ return insert(__x); }
template
_LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator
__last);
@@ -543,7 +543,7 @@ template
template
inline void hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator
__first, _InputIterator __last) {
for (; __first != __last; ++__first)
-__table_.__emplace_unique(*__first);
+__table_.__emplace_multi(*__first);
}
template
diff --git a/libcxx/test/extensions/gnu/hash_multimap/insert.pass.cpp
b/libcxx/test/extensions/gnu/hash_multimap/insert.pass.cpp
new file mode 100644
index 0..ea80359f1fea2
--- /dev/null
+++ b/libcxx/test/extensions/gnu/hash_multimap/insert.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated
+
+// hash_multimap::insert
+
+#include
+#include
+
+int main(int, char**) {
+ __gnu_cxx::hash_multimap map;
+
+ map.insert(std::make_pair(1, 1));
+ map.insert(std::make_pair(1, 1));
+
+ assert(map.size() == 2);
+ assert(map.equal_range(1).first == map.begin());
+ assert(map.equal_range(1).second == map.end());
+
+ std::pair arr[] = {std::make_pair(1, 1), std::make_pair(1, 1)};
+
+ map.insert(arr, arr + 2);
+
+ assert(map.size() == 4);
+ assert(map.equal_range(1).first == map.begin());
+ assert(map.equal_range(1).second == map.end());
+
+ return 0;
+}
diff --git a/libcxx/test/extensions/gnu/hash_multiset/insert.pass.cpp
b/libcxx/test/extensions/gnu/hash_multiset/insert.pass.cpp
new file mode 100644
index 0..1a60cac158a40
--- /dev/null
+++ b/libcxx/test/extensions/gnu/hash_multiset/insert.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated
+
+// hash_multimap
[llvm-branch-commits] [libcxx] release/21.x: [libc++] Fix hash_multi{map, set}::insert (#149290) (PR #149435)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/149435
>From 4a4071dc71d87357ea27e81bf46078e03ca9630e Mon Sep 17 00:00:00 2001
From: Nikolas Klauser
Date: Thu, 17 Jul 2025 23:23:04 +0200
Subject: [PATCH] [libc++] Fix hash_multi{map,set}::insert (#149290)
(cherry picked from commit be3d614cc13f016b16634e18e10caed508d183d2)
---
libcxx/include/ext/hash_map | 4 +--
libcxx/include/ext/hash_set | 4 +--
.../gnu/hash_multimap/insert.pass.cpp | 35 +++
.../gnu/hash_multiset/insert.pass.cpp | 35 +++
4 files changed, 74 insertions(+), 4 deletions(-)
create mode 100644 libcxx/test/extensions/gnu/hash_multimap/insert.pass.cpp
create mode 100644 libcxx/test/extensions/gnu/hash_multiset/insert.pass.cpp
diff --git a/libcxx/include/ext/hash_map b/libcxx/include/ext/hash_map
index d6b92204f4376..46815eaffa8bd 100644
--- a/libcxx/include/ext/hash_map
+++ b/libcxx/include/ext/hash_map
@@ -744,7 +744,7 @@ public:
_LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return
__table_.begin(); }
_LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }
- _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return
__table_.__emplace_unique(__x); }
+ _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return
__table_.__emplace_multi(__x); }
_LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x)
{ return insert(__x); }
template
_LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator
__last);
@@ -831,7 +831,7 @@ template
template
inline void hash_multimap<_Key, _Tp, _Hash, _Pred,
_Alloc>::insert(_InputIterator __first, _InputIterator __last) {
for (; __first != __last; ++__first)
-__table_.__emplace_unique(*__first);
+__table_.__emplace_multi(*__first);
}
template
diff --git a/libcxx/include/ext/hash_set b/libcxx/include/ext/hash_set
index 7fd5df24ed3a8..62a7a0dbcffb9 100644
--- a/libcxx/include/ext/hash_set
+++ b/libcxx/include/ext/hash_set
@@ -458,7 +458,7 @@ public:
_LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return
__table_.begin(); }
_LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }
- _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return
__table_.__emplace_unique(__x); }
+ _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return
__table_.__emplace_multi(__x); }
_LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x)
{ return insert(__x); }
template
_LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator
__last);
@@ -543,7 +543,7 @@ template
template
inline void hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator
__first, _InputIterator __last) {
for (; __first != __last; ++__first)
-__table_.__emplace_unique(*__first);
+__table_.__emplace_multi(*__first);
}
template
diff --git a/libcxx/test/extensions/gnu/hash_multimap/insert.pass.cpp
b/libcxx/test/extensions/gnu/hash_multimap/insert.pass.cpp
new file mode 100644
index 0..ea80359f1fea2
--- /dev/null
+++ b/libcxx/test/extensions/gnu/hash_multimap/insert.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated
+
+// hash_multimap::insert
+
+#include
+#include
+
+int main(int, char**) {
+ __gnu_cxx::hash_multimap map;
+
+ map.insert(std::make_pair(1, 1));
+ map.insert(std::make_pair(1, 1));
+
+ assert(map.size() == 2);
+ assert(map.equal_range(1).first == map.begin());
+ assert(map.equal_range(1).second == map.end());
+
+ std::pair arr[] = {std::make_pair(1, 1), std::make_pair(1, 1)};
+
+ map.insert(arr, arr + 2);
+
+ assert(map.size() == 4);
+ assert(map.equal_range(1).first == map.begin());
+ assert(map.equal_range(1).second == map.end());
+
+ return 0;
+}
diff --git a/libcxx/test/extensions/gnu/hash_multiset/insert.pass.cpp
b/libcxx/test/extensions/gnu/hash_multiset/insert.pass.cpp
new file mode 100644
index 0..1a60cac158a40
--- /dev/null
+++ b/libcxx/test/extensions/gnu/hash_multiset/insert.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated
+
+// hash_multimap
[llvm-branch-commits] [libcxx] release/21.x: [libc++] Fix hash_multi{map, set}::insert (#149290) (PR #149435)
frederick-vs-ja wrote: I opened #150002 to manually backport #149415. https://github.com/llvm/llvm-project/pull/149435 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/21.x: [libc++] Fix hash_multi{map, set}::insert (#149290) (PR #149435)
tru wrote: Can we get that fix backported so that the CI works on libc++ for the release branch properly? https://github.com/llvm/llvm-project/pull/149435 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/21.x: [libc++] Fix hash_multi{map, set}::insert (#149290) (PR #149435)
philnik777 wrote: The failures are unrelated. It's #149415. https://github.com/llvm/llvm-project/pull/149435 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/21.x: [libc++] Fix hash_multi{map, set}::insert (#149290) (PR #149435)
tru wrote: This one seems to have some CI failures - can they be checked before I merge this? https://github.com/llvm/llvm-project/pull/149435 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/21.x: [libc++] Fix hash_multi{map, set}::insert (#149290) (PR #149435)
https://github.com/ldionne approved this pull request. https://github.com/llvm/llvm-project/pull/149435 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
