[libc-commits] [clang] [libc] [libc] Fix modular printf attributes (PR #194003)
Daniel Thornburgh via libc-commits
libc-commits at lists.llvm.org
Thu May 7 09:06:04 PDT 2026
mysterymath wrote:
> Hi, digging into this a bit more, it looks like handling of builtins is different in C and C++ mode: in C mode attributes are initialized earlier and are available for the validation, while in C++ this is skipped, so that the format attribute is only added after the validation.
>
> I removed the hardcoded attributes from this patch and added my local fix as a demonstration - it extends the validation logic to expect that builtins and the special asprintf-like functions will get the attribute eventually.
>
> Other ways to fix would be to move validation or addition of implicit attributes around, which is a bigger structural change.
>
> Please let me know what you think, thanks!
Ah, thanks for looking into this; sorry that I've been a bit busy. I do think this patch will broadly work now, but I want to compare against one of the more intrinsic ways of solving it; duplicating the printf-like detection logic is not the greatest. But, we can fall back to this if need be and clean it up later I think.
https://github.com/llvm/llvm-project/pull/194003
More information about the libc-commits
mailing list