diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h index 453d91349e358..daaf82654e094 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h @@ -291,8 +291,10 @@ class LLVM_ALLOCATORHOLDER_EMPTYBASE StringMap if (FindInRHS == RHS.end()) return false; - if (!(KeyValue.getValue() == FindInRHS->getValue())) - return false; + if constexpr (!std::is_same_v) { + if (!(KeyValue.getValue() == FindInRHS->getValue())) + return false; + } } return true; diff --git a/llvm/unittests/ADT/StringSetTest.cpp b/llvm/unittests/ADT/StringSetTest.cpp index e3703f6f01508..a804c1f17d1ce 100644 --- a/llvm/unittests/ADT/StringSetTest.cpp +++ b/llvm/unittests/ADT/StringSetTest.cpp @@ -73,4 +73,12 @@ TEST_F(StringSetTest, Contains) { EXPECT_FALSE(Set.contains("test")); } +TEST_F(StringSetTest, Equal) { + StringSet<> A = {"A"}; + StringSet<> B = {"B"}; + ASSERT_TRUE(A != B); + ASSERT_FALSE(A == B); + ASSERT_TRUE(A == A); +} + } // end anonymous namespace