-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Serialization: Encode custom availability domains #80616
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
Serialization: Encode custom availability domains #80616
Conversation
@swift-ci please test |
Partially revert swiftlang#80035 now that Clang has its own APIs for querying serialized modules for the decl representing the availability domain with a given name.
When serializing `@available` attributes, if the attribute applies to a custom domain include enough information to deserialize the reference to that domain. Resolves rdar://138441265.
cd827e7
to
10c910e
Compare
@swift-ci please smoke test |
return AvailabilityDomain::forPlatform(platformKind); | ||
case AvailabilityDomainKind::Custom: | ||
return AvailabilityDomain::forCustom(decl, ctx); | ||
} |
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.
Do I understand correctly that there's no default:
here because deserialization issues are already protected by decodeDomainKind
, so the failure case would only be from the calls to the constructors?
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.
Exactly, a covered switch should be safe here since we handle out of range enum values elsewhere.
@@ -236,6 +242,10 @@ class AvailabilityDomain final { | |||
/// Returns the string to use when printing an `@available` attribute. | |||
llvm::StringRef getNameForAttributePrinting() const; | |||
|
|||
/// Returns the decl that represents the domain, or `nullptr` if the domain | |||
/// does not have a decl. | |||
Decl *getDecl() const; |
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.
For the moment, does this always points to a clang VarDecl? And when would a domain not have a decl?
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.
Yes, right now it can only reference and imported VarDecl
. However, I anticipate it pointing to additional types of declarations once we have a Swift syntax for custom availability domains.
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.
LGTM!
@swift-ci please smoke test macOS |
When serializing
@available
attributes, if the attribute applies to a custom domain include enough information to deserialize the reference to that domain.Additionally, remove the now unnecessary ClangImporter Swift lookup table support for availability domains. Clang now handles looking up serialized availability domain declarations in precompiled modules itself.
Finally, when printing
.swiftinterfaces
guard declarations that use theCustomAvailability
feature.Resolves rdar://138441265.