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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 14 10:57:13 PST 2025


================
@@ -796,6 +796,20 @@ static void instantiateDependentHLSLParamModifierAttr(
       "out or inout parameter type must be a reference and restrict qualified");
 }
 
+static void instantiateDependentMallocSpanAttr(Sema &S,
+                                               const MallocSpanAttr *Attr,
+                                               Decl *New) {
+  QualType RT = getFunctionOrMethodResultType(New);
+  if (RT->isDependentType()) {
+    // The type is still dependent.
----------------
erichkeane wrote:

Same regarding comments & curleys, comments aren't adding anything.  AND if the dependence check is in the check function, this all becomes:

```
if (!CheckSpanLikeType(...))
New->addAttr(...);
```

vastly simplifying & removing repetition

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


More information about the cfe-commits mailing list