-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema] Require explicit availability on public modules and customizable diagnostics level #61105
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
@swift-ci Please smoke test |
Should we check the effect of this on the stdlib build? I expect that we will want to potentially preemptively add the "ignore" flag there since there are so many existing APIs without availability because they have always been available. |
d4c60ef
to
0ebf98c
Compare
0ebf98c
to
a4f85e1
Compare
a4f85e1
to
4bec9d5
Compare
HelpText<"Require explicit availability on public declarations">; | ||
HelpText<"Warn on public declarations without an availability attribute">; | ||
|
||
def require_explicit_availability_EQ : Joined<["-"], "require-explicit-availability=">, |
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 you think it would make sense to name this -require-explicit-api-availability=
to help distinguish if we want to also add a similar -require-explicit-spi-availability=
flag in the future?
I suppose an alternative design could be to add a -require-explicit-availability-for-spi-groups=
flag that takes SPI group names that should be diagnosed at the same level as API, rather than having it be all or nothing for SPI.
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 was considering renaming the flag to -require-availability
, just to make it shorter even if a bit less descriptive.
Interesting idea for SPI, in most cases SPI doesn't require any availability so I don't think we'd need the "all SPI" version, but for specific SPI groups it could be useful and a good practice to apply. Users would have to learn to mark their features as SPI first before upgrading them to API instead of the other way around though.
@swift-ci Please smoke test |
1 similar comment
@swift-ci Please smoke test |
Extend the require explicit availability logic with two new features:
Enable the require explicit availability warnings by default for public modules. Public modules are usually inferred automatically and identified with
-library-level api
. rdar://99929744Intro the flag
-require-explicit-availability=<error,warn,ignore>
to define a custom diagnostic level. The default is still a warning, and the diagnostic can be promoted to an error or ignored.