================
@@ -195,6 +195,52 @@ declaration kind), all of which are optional:
SwiftReleaseOp: immortal
SwiftRetainOp: immortal
+:SwiftReturnOwnership:
+
+ Specifies the ownership convention of a function or method returning a C++
type
+ that has been imported as a Swift reference type using ``SwiftImportAs:
reference``.
+ This allows Swift to correctly manage the retain and release operations at
the
+ language boundary.
+
+ The possible values are:
+
+ - ``retained`` — Indicates that the function or method returns a +1
reference.
+ Swift will take ownership and is responsible for releasing it.
+ Equivalent to ``SWIFT_RETURNS_RETAINED``.
+ - ``unretained`` — Indicates that the function or method returns a +0
reference.
+ The caller must ensure the returned object remains alive.
+ Equivalent to ``SWIFT_RETURNS_UNRETAINED``.
+
+ This attribute can be applied to:
+
+ - **C++ functions**
+ - **C++ instance or static methods**
+ - **Objective-C / Objective-C++ methods or functions that return a C++
reference type**
----------------
Xazax-hun wrote:
I don't have a strong opinion here but I wonder if we need this enumeration at
all. If we only said functions and objective-C methods, I think people might
understand that methods (often called member functions) regardless of being
static or instance functions are also included.
Also this enumeration makes me thing that the restriction on the return type
only applies to Objective-C and Objective-C++, and I am not sure if that is the
case.
https://github.com/llvm/llvm-project/pull/143545
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits