[clang] [Sema] Suggest missing format attributes (PR #166738)

Vladimir Vuksanovic via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 24 06:26:57 PST 2025


vvuksanovic wrote:

Sorry for the late response. I didn't have time to finish this last week so I only sent the first part.

> Thanks for the format_matches support (and reviewing again, I now see that ReleaseNotes.rst was updated very early on). 

Yes, but I updated it again to reflect latest changes.

> The last bits that I'm still tracking:
> 
>  1. -Wmissing-format-attribute should be a subgroup of -Wformat-nonliteral (should have a test that with both enabled, you only get -Wmissing-format-attribute).

This is now implemented. There was a problem that blocks weren't properly supported and that is now fixed. There is one issue with that: I can't emit a fixit for blocks because I can't find the end location. Both begin and end locations point to the start. Also, since a `BlockDecl` isn't a `NamedDecl` the code is a bit messier.

I am not a fan of the diagnostic message for blocks, so let me know if you have a suggestion.

>   2. We should not add the implicit attribute if diag::warn_missing_format_attribute is ignored, since it would create downstream diagnostics that cannot be disabled in any reasonable way. We should have a test that with it enabled, you do get diagnostics caused by the implicit attribute, and with it disabled, you do not.

I agree, I had that planned but didn't finish testing. It is implemented now.

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


More information about the cfe-commits mailing list