Skip to content

Commit

Permalink
[ARC][Documentation] Explicitly state that messaging weak objects kee…
Browse files Browse the repository at this point in the history
…ps a strong reference during call lifetime (#72169)

rdar://113636046
  • Loading branch information
ahatanak committed Nov 14, 2023
1 parent e9453f3 commit 5079b27
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions clang/docs/AutomaticReferenceCounting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5079b27

Please sign in to comment.