diff --git a/llvm/include/llvm/ADT/StringSet.h b/llvm/include/llvm/ADT/StringSet.h --- a/llvm/include/llvm/ADT/StringSet.h +++ b/llvm/include/llvm/ADT/StringSet.h @@ -36,7 +36,6 @@ explicit StringSet(AllocatorTy A) : base(A) {} std::pair insert(StringRef Key) { - assert(!Key.empty()); return base::insert(std::make_pair(Key, None)); } diff --git a/llvm/unittests/ADT/StringSetTest.cpp b/llvm/unittests/ADT/StringSetTest.cpp --- a/llvm/unittests/ADT/StringSetTest.cpp +++ b/llvm/unittests/ADT/StringSetTest.cpp @@ -41,4 +41,15 @@ Element->Destroy(); } +TEST_F(StringSetTest, EmptyString) { + // Verify that the empty string can by successfully inserted + StringSet<> Set; + size_t Count = Set.count(""); + EXPECT_EQ(Count, 0UL); + + Set.insert(""); + Count = Set.count(""); + EXPECT_EQ(Count, 1UL); +} + } // end anonymous namespace