diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp index fdecfb7bb5b0b..785ab16271d93 100644 --- a/llvm/unittests/ADT/DenseMapTest.cpp +++ b/llvm/unittests/ADT/DenseMapTest.cpp @@ -387,9 +387,16 @@ TYPED_TEST(DenseMapTest, ConstIteratorTest) { EXPECT_TRUE(cit == cit2); } +// TYPED_TEST below cycles through different types. We define UniversalSmallSet +// here so that we'll use SmallSet or SmallPtrSet depending on whether the +// element type is a pointer. +template +using UniversalSmallSet = + std::conditional_t, SmallPtrSet, SmallSet>; + TYPED_TEST(DenseMapTest, KeysValuesIterator) { - SmallSet Keys; - SmallSet Values; + UniversalSmallSet Keys; + UniversalSmallSet Values; for (int I = 0; I < 10; ++I) { auto K = this->getKey(I); auto V = this->getValue(I); @@ -398,8 +405,8 @@ TYPED_TEST(DenseMapTest, KeysValuesIterator) { this->Map[K] = V; } - SmallSet ActualKeys; - SmallSet ActualValues; + UniversalSmallSet ActualKeys; + UniversalSmallSet ActualValues; for (auto K : this->Map.keys()) ActualKeys.insert(K); for (auto V : this->Map.values()) @@ -410,8 +417,8 @@ TYPED_TEST(DenseMapTest, KeysValuesIterator) { } TYPED_TEST(DenseMapTest, ConstKeysValuesIterator) { - SmallSet Keys; - SmallSet Values; + UniversalSmallSet Keys; + UniversalSmallSet Values; for (int I = 0; I < 10; ++I) { auto K = this->getKey(I); auto V = this->getValue(I); @@ -421,8 +428,8 @@ TYPED_TEST(DenseMapTest, ConstKeysValuesIterator) { } const TypeParam &ConstMap = this->Map; - SmallSet ActualKeys; - SmallSet ActualValues; + UniversalSmallSet ActualKeys; + UniversalSmallSet ActualValues; for (auto K : ConstMap.keys()) ActualKeys.insert(K); for (auto V : ConstMap.values())