This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Allow empty string in StringSet
ClosedPublic

Authored by sbc100 on Feb 13 2020, 10:09 PM.

Details

Summary

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.

Diff Detail

Event Timeline

sbc100 created this revision.Feb 13 2020, 10:09 PM
sbc100 edited the summary of this revision. (Show Details)Feb 13 2020, 10:11 PM
sbc100 added a reviewer: chandlerc.

Probably best to test this functionality with a unit test for StringSet - but also please check if there's a reason StringSet might not support empty strings in its implementation in some way? (tombstone/other marker objects might be using "length 0" as a marker of some kind?)

sbc100 updated this revision to Diff 253239.Mar 27 2020, 3:42 PM

add test

sbc100 updated this revision to Diff 253240.Mar 27 2020, 3:43 PM

whitespace

Added tests.

From inspection I can't see why this limitation would be needed. I also looked back though the history to identify the original reason for this limitation and it came, not from the data structure but from its domain-specific origin (a place where empty strings were not expected).

dblaikie accepted this revision.Mar 27 2020, 4:21 PM

Sounds good - please commit the StringPool fix separately & I'd personally probably remove the wasm test, but I can see the merit in including it too, so up to you there.

I also looked back though the history to identify the original reason for this limitation and it came, not from the data structure but from its domain-specific origin (a place where empty strings were not expected).

Could you include a few of the details from the history there to explain it in the commit message?

This revision is now accepted and ready to land.Mar 27 2020, 4:21 PM

Will do

Could you include a few of the details from the history there to explain it in the commit message?

The change description goes into quite a bit of detail already no? Or am I missing something?

sbc100 updated this revision to Diff 253252.Mar 27 2020, 4:55 PM

Revert misc changes

Will do

Could you include a few of the details from the history there to explain it in the commit message?

The change description goes into quite a bit of detail already no? Or am I missing something?

ah, sure - that's quite sufficient - thanks!

This revision was automatically updated to reflect the committed changes.