-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ParseableInterfaces] Handle lazy vars #21996
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
Conversation
The first commit is kinda noisy, so I'd recommend reviewing commit-by-commit. |
I also need to write a client test for this, which I will do in a follow-up PR that also re-enables |
lib/Sema/CodeSynthesis.cpp
Outdated
SmallString<64> NameBuf = VD->getName().str(); | ||
NameBuf += ".storage"; | ||
SmallString<64> NameBuf; | ||
NameBuf += "$__lazy_storage_"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: maybe separate the prefix from the name even harder? ObjC does _$_
between sections, so __lazy_storage_$_foo
or $__lazy_storage_$_foo
. The former also makes it even less likely to conflict with a debugger variable, which probably only has the $
at the beginning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to write it without the $
at the beginning, as that makes it a valid identifier. Do you think the potential name conflict matters there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I forgot we allowed $
in non-initial positions. Okay.
fbc0bb5
to
9e5dde6
Compare
9e5dde6
to
38f9254
Compare
Previously, the Lexer kept a single flag whether we’re lexing Swift or SIL. Instead, keep track if we’re parsing Swift, SIL, or a Swiftinterface file. .swiftinterface files allow $-prefixed identifiers anywhere.
We’re printing a new name for lazy storage in parseable interfaces, `$__lazy_storage_$_{propname}`. This is intentionally $-prefixed so it cannot conflict with variables written in source, but it doesn’t use a `.` anymore because parseable interfaces need to be...parseable.
For lazy vars, we need to make public the top-level entry point, and the fact that the lazy storage contributes to the layout of a type (if it’s fixed layout, or if the type is not resilient.) We also shouldn’t ever print `lazy` in a parseable interface. Since we need to parse these identifiers, give them a new name, `$__lazy_storage_$_{propname}`, which is parseable only in parseable interfaces so it doesn’t conflict with other properties.
38f9254
to
dd5a677
Compare
@swift-ci please test |
Build failed |
Build failed |
For lazy vars, we need to make public the top-level entry point, and the fact that the lazy storage contributes to the layout of a type (if it’s fixed layout, or if the type is not resilient.) We also shouldn’t ever print
lazy
in a parseable interface.Since we need to parse these identifiers, give them a new name,
$__lazy_storage_{propname}
, which is parseable only in parseable interfaces so it doesn’t conflict with other properties.