-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Diagnose unannotated C++ APIs returning SWIFT_SHARED_REFERENCE at Swift call sites #83025
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
Diagnose unannotated C++ APIs returning SWIFT_SHARED_REFERENCE at Swift call sites #83025
Conversation
23b360e
to
96c60e7
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
6c52fa5
to
1024a33
Compare
test/Interop/Cxx/foreign-reference/inheritance-diagnostics.swift
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
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 looks really clean now, thanks!
5adb4f5
to
1389b87
Compare
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 have one nit inline, once that is addressed the PR looks good to me.
36af6cc
to
2bf0bb0
Compare
…D_REFERENCE without ownership annotations Move the “unannotated SWIFT_SHARED_REFERENCE return” diagnostic from ClangImporter to Sema use sites (call expressions). This reduces the noise from large headers and only warns when the API is actually used. - New warning: warn_unannotated_cxx_func_returning_frt “cannot infer the ownership of the returned value, annotate %0 with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED” plus a note on the declaration site. - Gated by -enable-experimental-feature WarnUnannotatedReturnOfCxxFrt. - Implementation: * Add diagnoseCxxFunctionCalls() walker in MiscDiagnostics. * Add helpers: ReturnOwnershipInfo, hasImmortalAttrs, isReturningFRT(). * Remove the old import-time GROUPED_WARNING and update tests. rdar://150800115
2bf0bb0
to
5df006b
Compare
@swift-ci please smoke test |
@swift-ci please smoke test windows platform |
This patch improves the warning for C++ APIs returning
SWIFT_SHARED_REFERENCE
types but not annotated with eitherSWIFT_RETURNS_RETAINED
orSWIFT_RETURNS_UNRETAINED
in the following ways:SWIFT_RETURNS_(UN)RETAINED
annotations is now emitted on Swift use sites, rather than while importing the API (func/method decls).diagnoseCxxFunctionCalls
in file lib/Sema/MiscDiagnostics.cpp.rdar://150800115