[clang] [Clang] Fix FixIt for implicit-int diagnostics. (PR #179356)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 9 04:37:41 PST 2026
Sirraide wrote:
> In essence, the `DeclSpec` points to where the type specifier would need to be (at the very start), but in a declaration group, the warning/error will be raised for every identifier that is declared, at the location of the identifier. Inserting the declarator at the indicated location would be wrong. And, without the check, you'll get `int int int ` at the start. Again, feel free to try the LIT test.
>
> Also, not emitting a FixIt for the subsequent identifiers in the declaration group will mean that clang infers that it couldn't fix all the issues in the file, and abort the automatic FixIt process. I assume we also don't want that, because we quite clearly were able to fix it.
I feel like a better fix would be to emit the warning only once per decl group, but I haven’t looked into how complicated it would be to do that, but if that’s possible then I think we’d prefer that, because emitting a `FixItHint::CreateInsertion("")` is a bit horrible candidly.
The space after the `int` probably needs to be added regardless though; that part is fine.
https://github.com/llvm/llvm-project/pull/179356
More information about the cfe-commits
mailing list