[clang] [Sema] Suggest missing format attributes (PR #166738)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 7 10:19:22 PST 2025
================
@@ -3478,6 +3478,10 @@ def err_format_attribute_result_not : Error<"function does not return %0">;
def err_format_attribute_implicit_this_format_string : Error<
"format attribute cannot specify the implicit this argument as the format "
"string">;
+def warn_missing_format_attribute : Warning<
+ "diagnostic behavior may be improved by adding the '%0' format "
+ "attribute to the declaration of %1">,
+ InGroup<DiagGroup<"missing-format-attribute">>, DefaultIgnore;
----------------
apple-fcloutier wrote:
Can you help me put in context how -Wmissing-format-attribute works with GCC and its relationship with -Wformat, -Wformat=2 and -Wformat-nonliteral? It's kind of a least favorite way forward to add new off-by-default diagnostics.
Here's my thinking (before knowing how GCC deals with this):
* Could -Wmissing-format-attribute be enabled by default and/or be part of -Wformat? (Do we need an adult to confirm the bar for adding on-by-default diagnostics? I think this should be OK given that this shouldn't have false positives at all.)
* If -Wmissing-format-attribute cannot be enabled by default, what are our options for splitting the difference between it and -Wformat-nonliteral? Should -Wmissing-format-attribute be part of -Wformat-nonliteral so that users of -Wformat-nonliteral get it when possible?
* In all cases, -Wformat-nonliteral always hitting when -Wmissing-format-attribute does is an overlook that we should address.
https://github.com/llvm/llvm-project/pull/166738
More information about the cfe-commits
mailing list