https://github.com/mcmimik created 
https://github.com/llvm/llvm-project/pull/226626

The helpers in this example passed `BLOCK_FIELD_IS_BYREF | BLOCK_BYREF_CALLER`, 
but clang passes only `BLOCK_FIELD_IS_BYREF` there, as the rest of the document 
says.

Also fixed the field names, the type of `forwarding`, the helpers of the `int` 
variable and a missing comma, to match what clang generates. Checked with 
`clang -cc1 -rewrite-objc -fblocks` from clang 3.0 on this example; current 
clang passes the same flag.

See also #90341.

Assisted-by: Claude

>From 52703c337b9fa6b644f5fd8b0834f36697450873 Mon Sep 17 00:00:00 2001
From: Andrei Iugai <[email protected]>
Date: Sat, 26 Sep 2026 04:59:53 +0300
Subject: [PATCH] [clang][docs] Fix the __block import example in the Block ABI

The helpers in this example passed `BLOCK_FIELD_IS_BYREF | BLOCK_BYREF_CALLER`, 
but clang passes only `BLOCK_FIELD_IS_BYREF` there, as the rest of the document 
says. Also fix the field names, the type of `forwarding`, the helpers of the 
`int` variable and a missing comma, to match what clang generates.

See also #90341.

Assisted-by: Claude
---
 clang/docs/Block-ABI-Apple.md | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/clang/docs/Block-ABI-Apple.md b/clang/docs/Block-ABI-Apple.md
index b1a4c8bc12a33..3c4499d6ceab9 100644
--- a/clang/docs/Block-ABI-Apple.md
+++ b/clang/docs/Block-ABI-Apple.md
@@ -479,11 +479,9 @@ would translate to:
 ```c
 struct _block_byref_i {
     void *isa;  // set to NULL
-    struct _block_byref_voidBlock *forwarding;
+    struct _block_byref_i *forwarding;
     int flags;   //refcount;
     int size;
-    void (*byref_keep)(struct _block_byref_i *dst, struct _block_byref_i *src);
-    void (*byref_dispose)(struct _block_byref_i *);
     int captured_i;
 };
 
@@ -498,17 +496,17 @@ struct __block_literal_5 {
 };
 
 void __block_invoke_5(struct __block_literal_5 *_block) {
-   _block->forwarding->captured_i = 10;
+   _block->i_holder->forwarding->captured_i = 10;
 }
 
 void __block_copy_5(struct __block_literal_5 *dst, struct __block_literal_5 
*src) {
-     //_Block_byref_assign_copy(&dst->captured_i, src->captured_i);
-     _Block_object_assign(&dst->captured_i, src->captured_i, 
BLOCK_FIELD_IS_BYREF | BLOCK_BYREF_CALLER);
+     //_Block_byref_assign_copy(&dst->i_holder, src->i_holder);
+     _Block_object_assign(&dst->i_holder, src->i_holder, BLOCK_FIELD_IS_BYREF);
 }
 
 void __block_dispose_5(struct __block_literal_5 *src) {
-     //_Block_byref_release(src->captured_i);
-     _Block_object_dispose(src->captured_i, BLOCK_FIELD_IS_BYREF | 
BLOCK_BYREF_CALLER);
+     //_Block_byref_release(src->i_holder);
+     _Block_object_dispose(src->i_holder, BLOCK_FIELD_IS_BYREF);
 }
 
 static struct __block_descriptor_5 {
@@ -516,7 +514,7 @@ static struct __block_descriptor_5 {
     unsigned long int Block_size;
     void (*copy_helper)(struct __block_literal_5 *dst, struct 
__block_literal_5 *src);
     void (*dispose_helper)(struct __block_literal_5 *);
-} __block_descriptor_5 = { 0, sizeof(struct __block_literal_5) __block_copy_5, 
__block_dispose_5 };
+} __block_descriptor_5 = { 0, sizeof(struct __block_literal_5), 
__block_copy_5, __block_dispose_5 };
 ```
 
 and:

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to