https://github.com/philnik777 created 
https://github.com/llvm/llvm-project/pull/216967

The `malloc_span` attribute is intended to be used for `allocate_at_least`-like 
functions. Part of that interface is a guarantee that the number of bytes 
returned are actually dereferenceable. Document that, so that we can optimize 
on it in the future.


>From 5f515ec6d007ae21ae7cd90a4b661e62c8c2813b Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <[email protected]>
Date: Tue, 18 Aug 2026 11:02:50 +0200
Subject: [PATCH] [Clang] Document the interaction of malloc_span and
 alloc_size

---
 clang/include/clang/Basic/AttrDocs.td | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 3052dd6c77ab1..22355bf47c2a8 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5592,6 +5592,11 @@ members, one of which is a pointer to the start of the 
allocated memory and
 the other one is either an integer type containing the size of the actually
 allocated memory or a pointer to the end of the allocated region. Note, static
 data members do not impact whether a type is span-like or not.
+
+In combination with the `alloc_size` attribute, if the begin pointer is
+non-null, the size of the returned span-like object has to be greater or equal
+to the number of bytes guaranteed to be dereferenceable by `alloc_size`. It 
also
+guarantees that the number of dereferenceable bytes is at least size.
   }];
 }
 

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

Reply via email to