Skip to content

AST: Refactor semantic unavailability queries #77907

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 4 commits into from
Dec 3, 2024

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Dec 2, 2024

Improve the efficiency and correctness of queries related to semantic availability of decls. Previously, Decl::getSemanticUnavailableAttr() was the designated query for semantic unavailability, but it cached much richer information than most callers needed and bloated the storage requirements of the request evaluator. Additionally, its results were not actually accurate for Decl::isUnreachableAtRuntime(), since that query has a stricter notion of unavailability. The new request implementation computes a semantic decl availability classification that is suitable for all callers and also can be stored much more efficiently.

@tshortli
Copy link
Contributor Author

tshortli commented Dec 2, 2024

@swift-ci please test

Adopt it in a few places as a replacement for `Decl::getSemanticUnavailableAttr()`.
Also remove the underlying `SemanticUnavailableAttrRequest`, which used memory
very inefficiently in order to cache a detailed answer to what was usually a
much simpler question.

The only remaining use of `Decl::getSemanticUnavailableAttr()` that actually
needed to locate the semantic attribute making a declaration unavailable was in
`TypeCheckAttr.cpp`. The implementation of the request could just be used
directly in that one location. The other remaining callers only needed to know
if the decl was unavailable or not, which there are simpler queries for.

 # Please enter the commit message for your changes. Lines starting
@tshortli tshortli force-pushed the semantic-decl-availability branch from 9e9dd4a to 64f9d5b Compare December 3, 2024 07:00
@tshortli
Copy link
Contributor Author

tshortli commented Dec 3, 2024

swiftlang/swift-driver#1744

@swift-ci please test

@tshortli tshortli merged commit ecf7ac9 into swiftlang:main Dec 3, 2024
5 checks passed
@tshortli tshortli deleted the semantic-decl-availability branch December 3, 2024 16:30
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.

1 participant