[clang] [clang] Catch missing format attributes (PR #105479)
Aaron Puchert via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 7 16:05:37 PDT 2025
https://github.com/aaronpuchert commented:
> As I understand your change, it can only trip when `-Wformat-nonliteral` also trips. I think that you should implement this as a note/fixit on `-Wformat-nonliteral`.
Good observation, and I agree. It's even documented that this is one way to fix the warning:
> Clang implements this mostly the same way as GCC, but there is a difference for functions that accept a `va_list` argument (for example, `vprintf`). GCC does not emit `-Wformat-nonliteral` warning for calls to such functions. Clang does not warn if the format string comes from a function parameter, where the function is annotated with a compatible attribute, otherwise it warns.
An interesting question is whether we should have a separate warning about forwarding that doesn't warn about other nonliterals. But I don't see why one would want that. After all the idea of these warnings is to follow format strings all the way up the stack until we reach a constant string that we can check.
This could also simplify the change a lot.
https://github.com/llvm/llvm-project/pull/105479
More information about the cfe-commits
mailing list