https://github.com/ahatanak created https://github.com/llvm/llvm-project/pull/72169
rdar://113636046 >From 99c6bac064fbb7eb8f5462b58389b33703faf3f2 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka <ahatan...@apple.com> Date: Mon, 13 Nov 2023 14:27:28 -0800 Subject: [PATCH] [ARC][Documentation] Explicitly state that messaging weak objects keeps a strong reference during call lifetime rdar://113636046 --- clang/docs/AutomaticReferenceCounting.rst | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits