Skip to content

[Mangling] Include private discriminators in constructor manglings #9880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2017

Conversation

jrose-apple
Copy link
Contributor

@jrose-apple jrose-apple commented May 23, 2017

Previously, two constructors with the same full name and argument types would get identical manglings even if they were declared private or fileprivate in different files. This would lead to symbol collisions in whole-module builds. Add a new mangling node for private discriminators on base-name-less decls to make this unique.

This still doesn't fix the existing issue with private members, named or not, conflicting when they're in the same file, but since Swift 4 makes those members visible to one another (SE-0169) that's only an issue in Swift 3 mode anyway, and as such probably won't get fixed at all.

rdar://problem/27758199

@jrose-apple jrose-apple requested a review from eeckstein May 23, 2017 20:10
@jrose-apple jrose-apple force-pushed the private-init-mangling branch from 14f0bdd to 20fe54c Compare May 25, 2017 03:55
@jrose-apple jrose-apple changed the title [WIP] [Mangling] Include private discriminators in constructor manglings [Mangling] Include private discriminators in constructor manglings May 25, 2017
@jrose-apple jrose-apple force-pushed the private-init-mangling branch from 20fe54c to 20365a9 Compare May 25, 2017 03:58
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test Linux

@jrose-apple jrose-apple force-pushed the private-init-mangling branch from 20365a9 to 55462f1 Compare May 25, 2017 17:25
@jrose-apple
Copy link
Contributor Author

Already passed full testing before I added more tests.

@swift-ci Please smoke test

docs/ABI.rst Outdated
entity-spec ::= type 'fC' // allocating constructor
entity-spec ::= type 'fc' // non-allocating constructor
entity-spec ::= file-discriminator? type 'fC' // allocating constructor
entity-spec ::= file-discriminator? type 'fc' // non-allocating constructor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to add the optional discriminator after the type:

entity-spec ::= type file-discriminator? 'fc'

Having optional terms at the beginning of a rule can be problematic because when demangling it's not clear if they belong to that rule or to then "enclosing" rule.
For the file-discriminator it's actually not a problem because it's not used elsewhere. But to be consistent (and future prove) I'd prefer to change it.

Alternatively you could also just add a new character to 'f' instead of file-discriminator

entity-spec ::= type identifier 'fB' // allocating file-discriminated constructor
entity-spec ::= type identifier 'fb' // non-allocating file-discriminated constructor

Previously, two constructors with the same full name and argument
types would get identical manglings even if they were declared
'private' or 'fileprivate' in different files. This would lead to
symbol collisions in whole-module builds. Add a new mangling node for
private discriminators on base-name-less decls to make this unique.

This still doesn't fix the existing issue with private members, named
or not, conflicting when they're in the /same/ file, but since Swift 4
makes those members visible to one another (SE-0169) that's only an
issue in Swift 3 mode anyway, and as such probably won't get fixed at
all.

rdar://problem/27758199
@jrose-apple jrose-apple force-pushed the private-init-mangling branch from 55462f1 to 7ff8e0b Compare June 1, 2017 00:16
@jrose-apple
Copy link
Contributor Author

@swift-ci Please smoke test

@jrose-apple jrose-apple merged commit c1c4f52 into swiftlang:master Jun 1, 2017
@jrose-apple jrose-apple deleted the private-init-mangling branch June 1, 2017 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants