[clang] [APINotes] Update the documentation with new features (PR #95162)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 11 12:07:46 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Egor Zhdan (egorzhdan)

<details>
<summary>Changes</summary>

This adds the documentation for a few recently added Clang API Notes features: C++ namespaces, `SwiftImportAs` and `SwiftCopyable`.

---
Full diff: https://github.com/llvm/llvm-project/pull/95162.diff


1 Files Affected:

- (modified) clang/docs/APINotes.rst (+34-3) 


``````````diff
diff --git a/clang/docs/APINotes.rst b/clang/docs/APINotes.rst
index a6e200e8bffde..2a688e3dca24d 100644
--- a/clang/docs/APINotes.rst
+++ b/clang/docs/APINotes.rst
@@ -80,11 +80,12 @@ entries:
 
     Name: MyFramework
 
-:Classes, Protocols, Tags, Typedefs, Globals, Enumerators, Functions:
+:Classes, Protocols, Tags, Typedefs, Globals, Enumerators, Functions, Namespaces:
 
   Arrays of top-level declarations. Each entry in the array must have a
-  'Name' key with its Objective-C name. "Tags" refers to structs, enums, and
-  unions; "Enumerators" refers to enum cases.
+  'Name' key with its Objective-C or C++ name. "Tags" refers to structs,
+  C++ classes, enums, and unions; "Classes" refers to Objective-C classes;
+  "Enumerators" refers to enum cases.
 
   ::
 
@@ -157,6 +158,36 @@ declaration kind), all of which are optional:
     - Class: NSBundle
       SwiftName: Bundle
 
+:SwiftImportAs:
+
+  For a class, possible values are ``owned`` (equivalent to
+  ``SWIFT_SELF_CONTAINED``), ``reference`` (equivalent to
+  ``SWIFT_SHARED_REFERENCE``, also requires specifying ``SwiftReleaseOp`` and
+  ``SwiftRetainOp``).
+
+  For a method, possible values are ``unsafe`` (equivalent
+  to ``SWIFT_RETURNS_INDEPENDENT_VALUE``), ``computed_property`` (equivalent to
+  ``SWIFT_COMPUTED_PROPERTY``).
+
+  ::
+
+    Tags:
+    - Name: RefCountedStorage
+      SwiftImportAs: reference
+      SwiftReleaseOp: RCRelease
+      SwiftRetainOp: RCRetain
+
+:SwiftCopyable:
+
+  Allows annotating a C++ class as non-copyable in Swift. Equivalent to
+  ``SWIFT_NONCOPYABLE``, or to an explicit conformance ``: ~Copyable``.
+
+  ::
+
+    Tags:
+    - Name: tzdb
+      SwiftCopyable: false
+
 :Availability, AvailabilityMsg:
 
   A value of "nonswift" is equivalent to ``NS_SWIFT_UNAVAILABLE``. A value of

``````````

</details>


https://github.com/llvm/llvm-project/pull/95162


More information about the cfe-commits mailing list