-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Adopt @abi
in the standard library
#79937
Draft
beccadax
wants to merge
18
commits into
swiftlang:main
Choose a base branch
from
beccadax:abi-rewrote-your-history
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Correct an issue with `ImplementsAttr` that would come up if you ever tried to clone an attribute that had been deserialized. No tests because there’s nothing in the compiler yet that might actually do so.
Allows code to get this for any AbstractStorageDecl.
Make this logic accessible outside of the mangler.
Create a helper method which looks for an `@objc` attribute with an explicit name and returns it, and adopt it in various existing places.
Adds assertions in various places where properties that can vary between ABI-only decls and their counterparts—particularly function and parameter attributes—are handled in SILGen, ensuring that we don’t accidentally end up processing ABI-only decls there.
This commit compares the decl inside the `@abi` attribute to the decl it’s attached to, diagnosing ABI-incompatible differences. It does not yet cover attributes, which are a large undertaking.
ABI-only declarations now query their API counterpart for things like `isObjC()`, their ObjC name, dynamic status, etc. This means that `@objc` and friends can simply be omitted from an `@abi` attribute. No tests in this commit since attribute checking hasn’t landed yet.
ABI-only declarations now inherit access control modifiers like `public` or `private(set)`, as well as `@usableFromInline` and `@_spi`, from their API counterpart. This means these attributes and modifiers don’t need to be specified in an `@abi` attribute. Very few tests because we aren’t yet enforcing the absence of these attributes.
ABI-only declarations now inherit `@available`, `@backDeployed`, etc. from their ABI counterpart. This will make it unnecessary to specify these attributes in `@abi`. Also some changes to make sure we suggest inserting `@available` in the correct place. No tests because the enforcement is not yet in.
ABI-only decls will now inherit `override` from their API counterpart; the keyword is unnecessary and `getOverriddenDecls()` will get the ABI counterparts of the decls the API counterpart overrides. No tests because we don’t have the enforcement mechanism in yet.
It’s unnecessary, shouldn’t be serialized into module interfaces, and Swift doesn’t know how to compute it for an ABI-only decl since it doesn’t have accessors or an initial value. No tests because enforcement isn’t in yet.
Adds a new method to `DeclAttribute` which can compare two attributes and see if they would be “equivalent” in light of the given decl. “Equivalent” here means that they would have the same effect on the declaration; for instance, two attrs with different source locations can be equivalent, and two attributes with the same arguments in a different order are equivalent if the ordering of those argumetns is not semantically equivalent. This capability is not yet used in this commit, but in a future commit `@abi` will check if certain attributes are equivalent or not.
This PR adds a set of DeclAttr.def flags for specifying how a given attribute interacts with `@abi`, and declares a behavior for each existing attribute. Future attributes will be *required* to declare an `@abi` behavior lest they fail a static assert. Note that the behavior is not actually enforced in this commit—it is merely specified here.
This commit compares the attributes on the decl inside the `@abi` attribute to those in the decl it’s attached to, diagnosing ABI-incompatible differences. It also rejects many attributes that don’t need to be specified in the `@abi` attribute, such as ObjC-ness, access control, or ABI-neutral traits like `@discardableResult`, so developers know to remove them.
And make sure we reject it on `deinit`s and accessors.
When printing an `@abi` attribute’s decl, we now filter out any attrs that are not valid in that position. Fixes a broken test.
This commit enables the ABIAttribute feature in the standard library build and replaces (nearly) every instance of `@_silgen_name(<mangled Swift name>)` in stdlib/public with an `@abi` attribute.
02b3318
to
ed8e82d
Compare
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces eligible uses of
@_silgen_name
in the standard library with@abi
.It temporarily includes the commits in #79466; I'll eventually remove them by rebasing it.