-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SPI] Requestify, inherit SPI groups and better diagnostics #30215
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 |
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.
Nice!
@swift-ci please smoke test |
} | ||
|
||
llvm::Expected<llvm::ArrayRef<Identifier>> | ||
SPIGroupsRequest::evaluate(Evaluator &evaluator, const Decl *decl) 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.
There could be a cycle in this request. Could we diagnose that explicitly?
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'll have to look into this... Do you see a direct cycle that could be created here?
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.
Not currently. My concern is when we add more recursive calls of getSPIGroups()
in this function, we may end up with unexpected cycles. The request template should allow us to diagnose cycle by overriding void diagnoseCycle(DiagnosticEngine &diags)
@@ -127,9 +127,10 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc, | |||
if (D->getDeclContext()->isLocalContext()) | |||
return false; | |||
|
|||
// Public declarations are OK. | |||
// Public non-SPI declarations are OK. |
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 we diagnose @SPI decl inside a non-resilient type marked of @frozen
? it should be disallowed.
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.
This should be diagnosed. There's a test in local_spi_decls.swift
but it could be extended to cover more edge cases.
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.
Sorry, I should be more specific here. Say when we have a frozen struct with three fields and the second field is marked as SPI. This means in the API world, the third field will be referenced as the second field in runtime even the user thinks they are referencing the third field by name. This could lead to unintended runtime behavior. I wonder whether this pattern is diagnosed in local_spi_decls.swift
.
Improve SPI support on four main points:
@_spi
instead ofinternal
.@_spi
.