Skip to content

ClangImporter: Generate and call custom availability domain predicates #82940

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

Conversation

tshortli
Copy link
Contributor

When importing custom availability domains with dynamic predicates from Clang modules, synthesize predicate functions for if #available queries and call them when generating SIL.

Resolves rdar://138441312.

Nest the `if #available` queries in functions so that it's easier to check the
resulting IR unambiguously.
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

When importing custom availability domains with dynamic predicates from Clang
modules, synthesize predicate functions for `if #available` queries and call
them when generating SIL.

Resolves rdar://138441312.
@tshortli tshortli force-pushed the silgen-custom-availability-domain-query branch from 14e1e01 to 3d722e1 Compare July 10, 2025 15:15
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

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

Cool!

if (featureInfo.second.Kind != clang::FeatureAvailKind::Dynamic)
return nullptr;

if (!featureInfo.second.Call)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this happen? i.e.

featureInfo.second.Kind == clang::FeatureAvailKind::Dynamic && !featureInfo.second.Call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly a defensive measure since Clang is responsible for this invariant and I'd like to fail gracefully if it changes.

@tshortli tshortli enabled auto-merge July 10, 2025 19:12
@tshortli tshortli merged commit 96d0450 into swiftlang:main Jul 10, 2025
3 checks passed
@tshortli tshortli deleted the silgen-custom-availability-domain-query branch July 10, 2025 21:01
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