[llvm] [ADT] Document the UniquingSet contracts. NFC (PR #221860)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 20:49:41 PDT 2026
================
@@ -635,6 +635,10 @@ TEST(UniquingSetTest, Basic) {
KeyedPair B(2, 1);
Set.insert(&B, Token);
+ KeyedPair ADup(1, 2);
+ EXPECT_EQ(&A, Set.getOrInsert(&ADup));
+ EXPECT_EQ(2u, Set.size());
----------------
kazutakahirata wrote:
Both this test and the one in `StandaloneInfoAliasingKeyAcrossGrowth` only test `getOrInsert` with a node that is already present in the set. Could we also test the case where the node is absent, verifying that `getOrInsert` inserts the new node, returns it, and increments `size()`?
For example, at the end of `TEST(UniquingSetTest, Basic)`:
```cpp
KeyedPair C(3, 4);
EXPECT_EQ(&C, Set.getOrInsert(&C));
EXPECT_EQ(2u, Set.size());
EXPECT_EQ(&C, Set.lookup({3, 4}, Token));
```
https://github.com/llvm/llvm-project/pull/221860
More information about the llvm-commits
mailing list