[PATCH] D74589: [ADT] Allow empty string in StringSet

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 22:12:26 PST 2020


sbc100 created this revision.
Herald added subscribers: llvm-commits, dexonsmith, sunfish, aheejin.
Herald added a project: LLVM.
sbc100 edited the summary of this revision.
sbc100 added a reviewer: chandlerc.

Also add a test case to wasm-ld that asserts without this change.
Internally wasm-ld builds a StringMap of exported functions and it seems
like allowing empty string in the set is preferable to adding checks.

This assert looks like it was most likely just a history accident.
It started life here purely to support InputLanguagesSet:

  eeac27e38c5c567d63bbfa5410620d955696491b

Then got extracted here:

  e57a4033385c5976cbb17af1e962b1224a61183b

Then got moved to ADT here

  5c48bae209bcbd261886f63abac695b1e30544e6

With the `InLang` paramater name still intact which suggested is
InputLanguagesSet origins.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74589

Files:
  lld/test/wasm/export-empty.test
  llvm/include/llvm/ADT/StringSet.h


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.244572.patch
Type: text/x-patch
Size: 796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200214/20ff12bd/attachment.bin>


More information about the llvm-commits mailing list