Author: Egor Zhdan
Date: 2026-02-20T17:52:40Z
New Revision: 8adcf7efd16544b24e55b73ef126011b41e66192

URL: 
https://github.com/llvm/llvm-project/commit/8adcf7efd16544b24e55b73ef126011b41e66192
DIFF: 
https://github.com/llvm/llvm-project/commit/8adcf7efd16544b24e55b73ef126011b41e66192.diff

LOG: [APINotes] Document `SwiftReturnOwnership` annotation

The API Notes attribute was added in 48f7f63a, but wasn't documented.

Added: 
    

Modified: 
    clang/docs/APINotes.rst

Removed: 
    


################################################################################
diff  --git a/clang/docs/APINotes.rst b/clang/docs/APINotes.rst
index e142cfa62e5a2..0018e4c883542 100644
--- a/clang/docs/APINotes.rst
+++ b/clang/docs/APINotes.rst
@@ -438,6 +438,31 @@ declaration kind), all of which are optional:
     - Name: NSIndexSet
       SwiftBridge: IndexSet
 
+:SwiftReturnOwnership:
+
+  Used for methods and functions. Specifies the ownership convention for the
+  return value when it is a foreign reference type (a type imported as
+  ``SwiftImportAs: reference``). Possible values are:
+
+  - ``retained`` --- the caller receives an owned reference
+    (equivalent to ``__attribute__((swift_attr("returns_retained")))``).
+  - ``unretained`` --- the caller receives an unowned reference
+    (equivalent to ``__attribute__((swift_attr("returns_unretained")))``).
+
+  ::
+
+    Functions:
+    - Name: createRefCounted
+      SwiftReturnOwnership: retained
+    - Name: getSharedRefCounted
+      SwiftReturnOwnership: unretained
+    Tags:
+    - Name: ImmortalRefType
+      SwiftImportAs: reference
+      Methods:
+      - Name: createChild
+        SwiftReturnOwnership: retained
+
 :DesignatedInit:
 
   Used for init methods. Equivalent to ``NS_DESIGNATED_INITIALIZER``.


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to