Skip to content

Commit 7bb9a6a

Browse files
committed
copilot
Created using spr 1.3.7
1 parent a88a204 commit 7bb9a6a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

llvm/include/llvm/ADT/RadixTree.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ namespace llvm {
6565
/// inserted into it. When an element is removed or the tree is destroyed,
6666
/// these objects will be destructed.
6767
/// However, if `KeyType` is a reference-like type, e.g., StringRef or range,
68-
/// the user must guarantee that destination has lifetime longer than the tree.
68+
/// the user must guarantee that the referenced data has a lifetime longer than
69+
/// the tree.
6970
template <typename KeyType, typename T> class RadixTree {
7071
public:
7172
using key_type = KeyType;
@@ -311,8 +312,8 @@ template <typename KeyType, typename T> class RadixTree {
311312
// from the argument.
312313
// FIXME: Determine that we need a new node, before expanding
313314
// `KeyValuePairs`.
314-
const value_type &NewValue =
315-
KeyValuePairs.emplace_front(std::move(Key), T(std::move(Args)...));
315+
const value_type &NewValue = KeyValuePairs.emplace_front(
316+
std::move(Key), T(std::forward<Ts>(Args)...));
316317
Node &Node = findOrCreate(NewValue.first);
317318
bool HasValue = Node.Value != typename ContainerType::iterator();
318319
if (!HasValue)

llvm/unittests/ADT/RadixTreeTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ TEST(RadixTreeTest, Complex) {
9393
EXPECT_EQ(T.countNodes(), 9u);
9494
}
9595

96+
TEST(RadixTreeTest, ValueWith2Parameters) {
97+
RadixTree<StringRef, std::pair<std::string, int>> T;
98+
T.emplace("abcd", "a", 3);
99+
100+
EXPECT_THAT(T, UnorderedElementsAre(Pair("abcd", Pair("a", 3))));
101+
}
102+
96103
// Test different types, less readable.
97104

98105
template <typename T> struct TestData {

0 commit comments

Comments
 (0)