[clang] [Clang] Introduce malloc_span attribute (PR #167010)

Marco Elver via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 10 01:11:57 PST 2025


================
@@ -1839,6 +1839,39 @@ static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
                  RestrictAttr(S.Context, AL, DeallocE, DeallocPtrIdx));
 }
 
+static bool isSpanLikeType(const QualType &Ty) {
+  // Check that the type is a plain record with the first field being a pointer
+  // type and the second field being an integer.
+  // This matches the common implementation of std::span or sized_allocation_t
+  // in P0901R11.
+  // Note that there may also be numerous cases of pointer+integer structures
+  // not actually exhibiting a std::span-like semantics, so sometimes
----------------
melver wrote:

```suggestion
  // not actually exhibiting a span-like semantics, so sometimes
```

https://github.com/llvm/llvm-project/pull/167010


More information about the cfe-commits mailing list