[PATCH] D74589: [ADT] Allow empty string in StringSet
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 13:05:20 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGde77d2312751: [ADT] Allow empty string in StringSet (authored by sbc100).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74589/new/
https://reviews.llvm.org/D74589
Files:
llvm/include/llvm/ADT/StringSet.h
llvm/unittests/ADT/StringSetTest.cpp
Index: llvm/unittests/ADT/StringSetTest.cpp
===================================================================
--- llvm/unittests/ADT/StringSetTest.cpp
+++ 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
Index: llvm/include/llvm/ADT/StringSet.h
===================================================================
--- llvm/include/llvm/ADT/StringSet.h
+++ llvm/include/llvm/ADT/StringSet.h
@@ -36,7 +36,6 @@
explicit StringSet(AllocatorTy A) : base(A) {}
std::pair<typename base::iterator, bool> insert(StringRef Key) {
- assert(!Key.empty());
return base::insert(std::make_pair(Key, None));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74589.253677.patch
Type: text/x-patch
Size: 950 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200330/111ea142/attachment-0001.bin>
More information about the llvm-commits
mailing list