================
@@ -174,12 +174,21 @@ If a project uses custom functions for dynamic memory 
management (that e.g. act
 Attribute 'ownership_returns' (Clang-specific)
 ----------------------------------------------
 
-Use this attribute to mark functions that return dynamically allocated memory. 
Takes a single argument, the type of the allocation (e.g. ``malloc`` or 
``new``).
+Use this attribute to mark functions that return dynamically allocated memory.
+The first argument is the type of the allocation (e.g. ``malloc``, ``new``, or 
any other identifier).
+An optional second argument is the 1-based index of the function parameter 
that specifies the allocation size in bytes.
+The referenced parameter must have an integral type.
+
+This attribute may appear at most once per function declaration.
 
 .. code-block:: c
 
+  // Without size parameter:
   void __attribute((ownership_returns(malloc))) *my_malloc(size_t);
----------------
steakhal wrote:

```suggestion
  void __attribute((ownership_returns(malloc))) *my_malloc(size_t sz);
```

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

Reply via email to