Skip to content

Commit f96ea89

Browse files
authored
[APINotes] Document immortal reference type annotation
API Notes allow annotating a C++ reference type with its retain/release operations. These are honored by the Swift compiler when the type is used from Swift. Apart from names of C++ functions that need to be called to retain/release the object, API Notes also accept a value of `immortal` which indicates that the object is to be considered alive for the duration of the program.
1 parent afa23ea commit f96ea89

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

clang/docs/APINotes.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,31 @@ declaration kind), all of which are optional:
169169
to ``SWIFT_RETURNS_INDEPENDENT_VALUE``) or ``computed_property`` (equivalent to
170170
``SWIFT_COMPUTED_PROPERTY``).
171171

172+
::
173+
174+
Tags:
175+
- Name: OwnedStorage
176+
SwiftImportAs: owned
177+
178+
:SwiftRetainOp, SwiftReleaseOp:
179+
180+
Controls the lifetime operations of a class which uses custom reference
181+
counting. The class must be annotated as a reference type using
182+
``SwiftImportAs: reference``. The values are either names of global functions,
183+
each taking a single parameter of a pointer type, or ``immortal`` for a type
184+
that is considered alive for the duration of the program.
185+
172186
::
173187

174188
Tags:
175189
- Name: RefCountedStorage
176190
SwiftImportAs: reference
177191
SwiftReleaseOp: RCRelease
178192
SwiftRetainOp: RCRetain
193+
- Name: ImmortalSingleton
194+
SwiftImportAs: reference
195+
SwiftReleaseOp: immortal
196+
SwiftRetainOp: immortal
179197

180198
:SwiftCopyable:
181199

0 commit comments

Comments
 (0)