[clang] [ARC][Documentation] Explicitly state that messaging weak objects keeps a strong reference during call lifetime (PR #72169)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 13 14:54:35 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Akira Hatanaka (ahatanak)
<details>
<summary>Changes</summary>
rdar://113636046
---
Full diff: https://github.com/llvm/llvm-project/pull/72169.diff
1 Files Affected:
- (modified) clang/docs/AutomaticReferenceCounting.rst (+15-2)
``````````diff
diff --git a/clang/docs/AutomaticReferenceCounting.rst b/clang/docs/AutomaticReferenceCounting.rst
index 820ad3978d5f206..bcac73215c9d32e 100644
--- a/clang/docs/AutomaticReferenceCounting.rst
+++ b/clang/docs/AutomaticReferenceCounting.rst
@@ -839,8 +839,21 @@ and non-ownership qualification.
object lvalue.
* For ``__weak`` objects, the current pointee is retained and then released at
- the end of the current full-expression. This must execute atomically with
- respect to assignments and to the final release of the pointee.
+ the end of the current full-expression. In particular, messaging a ``__weak``
+ object keeps the object retained until the end of the full expression.
+
+ .. code-block:: objc
+
+ __weak MyObject *weakObj;
+
+ void foo() {
+ // weakObj is retained before the message send and released at the end of
+ // the full expression.
+ [weakObj m];
+ }
+
+ This must execute atomically with respect to assignments and to the final
+ release of the pointee.
* For all other objects, the lvalue is loaded with primitive semantics.
:arc-term:`Assignment` occurs when evaluating an assignment operator. The
``````````
</details>
https://github.com/llvm/llvm-project/pull/72169
More information about the cfe-commits
mailing list