[clang] [Clang] Allow malloc for functions returning structs (PR #165433)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 6 07:13:18 PST 2025


AaronBallman wrote:

> Is there a reason why a new attribute name can't be used instead? Like say `malloc_span` and `alloc_size_span`. This should make easier to keep things working when trying with say `__has_attribute` and older clang/gcc and you don't need to hard code the exact version of clang/gcc where the support was added. I know GCC's malloc attribute added an extra argument which is hard to test for except via a feature test via an autoconf like but I feel like that was a mistake [one which we need to live with now] (I didn't think of the issue back when GCC added that support nor I responded to the review back then either).

I think that's a reasonable idea; I'd be happy with `malloc_span`

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


More information about the cfe-commits mailing list