-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Add SWIFT_RETURNS_RETAINED and SWIFT_RETURNS_UNRETAINED… #75897
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
[cxx-interop] Add SWIFT_RETURNS_RETAINED and SWIFT_RETURNS_UNRETAINED… #75897
Conversation
@swift-ci please smoke test |
70d72fe
to
1f150a5
Compare
@swift-ci please smoke test |
High-level question: do we need both of these? If we have a default behavior, we might be able drop the one that matches that. That being said, I don't have strong feelings about this, since these annotations can also serve as documentation and users can also use it to hedge against the defaults changing. |
Ah, never mind. So the default might be based on naming conventions, so the user needs to be able to override the defaults in both directions. |
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.
The overall approach seems reasonable to me, I have a few comments.
test/Interop/Cxx/foreign-reference/frt-retained-unretained-attributes-error.swift
Outdated
Show resolved
Hide resolved
test/Interop/Cxx/foreign-reference/Inputs/cxx-functions-and-methods-returning-frt.h
Show resolved
Hide 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 good to me as well, I only mentioned some small nits.
test/Interop/Cxx/foreign-reference/frt-retained-unretained-attributes-error.swift
Outdated
Show resolved
Hide resolved
test/Interop/Cxx/foreign-reference/frt-retained-unretained-attributes.swift
Outdated
Show resolved
Hide resolved
test/Interop/Cxx/foreign-reference/frt-retained-unretained-attributes.swift
Outdated
Show resolved
Hide resolved
test/Interop/Cxx/foreign-reference/Inputs/cxx-functions-and-methods-returning-frt.h
Show resolved
Hide resolved
1f150a5
to
b8bc313
Compare
@swift-ci please smoke test |
b8bc313
to
8c34f5a
Compare
@swift-ci please smoke test |
test/Interop/Cxx/foreign-reference/Inputs/cxx-functions-and-methods-returning-frt.h
Outdated
Show resolved
Hide resolved
In this patch I am adding two new macros I wanted to get your opinion on whether we should use the existing clang attributes |
One important detail there is that we think that the attributes would need to change in the future, regardless of whether we use the existing To provide Clang diagnostics and Clang static analyzer support for these attributes, similarly to the existing support for |
|
Another reason why Ref: https://releases.llvm.org/3.5.0/tools/clang/docs/AutomaticReferenceCounting.html#id18 |
8c34f5a
to
a9dbe65
Compare
@swift-ci please smoke test |
a9dbe65
to
493561a
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.
Overall this looks good, I only have one minor comment.
… annotations to specify ownership of FRT returned by a C++ method or function rdar://135306908
493561a
to
ea43283
Compare
@swift-ci please smoke test |
@ahatanaka I feel we should use these classes of annotations CF_ NS_ SWIFT_ as per the return type of C++ functions and/or methods: We have 3 class of annotations: They should have effect on C++ method, functions, etc only if the return type is of their respective category. Otherwise we should warn or error out in the ClangImporter. We can have additional testing to make sure that behaviour is changed only for C++ functions and methods and not for C, ObjC, CF, etc functions. Let me know if you have thoughts. |
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.
LGTM
Adding SWIFT_RETURNS_RETAINED and SWIFT_RETURNS_UNRETAINED annotations to specify ownership of FRT returned by a C++ method or function. The default behaviour without these annotations remain unchanged.
rdar://135306908