[PATCH] D74589: [ADT] Allow empty string in StringSet
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 27 16:00:05 PDT 2020
sbc100 updated this revision to Diff 253239.
sbc100 added a comment.
add test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74589/new/
https://reviews.llvm.org/D74589
Files:
lld/test/wasm/export-empty.test
llvm/include/llvm/ADT/StringSet.h
llvm/unittests/ADT/StringSetTest.cpp
llvm/unittests/Support/StringPool.cpp
Index: llvm/unittests/Support/StringPool.cpp
===================================================================
--- llvm/unittests/Support/StringPool.cpp
+++ llvm/unittests/Support/StringPool.cpp
@@ -1,4 +1,4 @@
-//===- llvm/unittest/Support/StringPoiil.cpp - StringPool tests -----------===//
+//===- llvm/unittest/Support/StringPool.cpp - StringPool tests ------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Index: llvm/unittests/ADT/StringSetTest.cpp
===================================================================
--- llvm/unittests/ADT/StringSetTest.cpp
+++ llvm/unittests/ADT/StringSetTest.cpp
@@ -41,4 +41,16 @@
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));
}
Index: lld/test/wasm/export-empty.test
===================================================================
--- /dev/null
+++ lld/test/wasm/export-empty.test
@@ -0,0 +1,4 @@
+RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.o
+RUN: not wasm-ld --export "" %t.o -o %t.wasm 2>&1 | FileCheck --match-full-lines %s
+
+CHECK: wasm-ld: error: symbol exported via --export not found:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74589.253239.patch
Type: text/x-patch
Size: 1853 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200327/cb0332c0/attachment.bin>
More information about the llvm-commits
mailing list