[all-commits] [llvm/llvm-project] 8d90a5: [clang] Add comment about misleading alloc_size ar...
Jann via All-commits
all-commits at lists.llvm.org
Tue Apr 8 13:18:45 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 8d90a541537fbed7d8c2a759b4ff46192a2c436e
https://github.com/llvm/llvm-project/commit/8d90a541537fbed7d8c2a759b4ff46192a2c436e
Author: Jann <jannh at google.com>
Date: 2025-04-08 (Tue, 08 Apr 2025)
Changed paths:
M clang/include/clang/Basic/Attr.td
Log Message:
-----------
[clang] Add comment about misleading alloc_size argument names (#134899)
Attr.td names the first alloc_size argument "ElemSizeParam" and the
second optional argument "NumElemsParam"; but the semantics of how the
two-argument version is used in practice is the opposite of that.
glibc declares calloc() like this, so the second alloc_size argument is
the element size:
```
extern void *calloc (size_t __nmemb, size_t __size)
__THROW __attribute_malloc__ __attribute_alloc_size__ ((1, 2)) __wur;
```
The Linux kernel declares array allocation functions like
`kmalloc_array_noprof()` the same way.
Add a comment explaining that the names used inside clang are
misleading.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list