[clang] Fix the double space and double attribute printing of the final keyword. (PR #88600)

Kim Gräsman via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 13 08:21:14 PDT 2024


kimgr wrote:

> If the intent is to produce a forward declaration the final keyword cannot be attached to a forward declaration. So I am not sure what's the "right" fix here...

I don't believe that's the intent of `DeclPrinter` or `PolishForDeclaration` --

* Clangd uses `PolishForDeclaration` to print an informational "hover text" for the declaration (and I guess that's why they want to include `final` -- it's something that's good for an interactive user to know about the decl)
* IWYU uses `PolishForDeclaration` to get a valid _declaration_, and then does [some very hacky heuristic post-processing](https://github.com/include-what-you-use/include-what-you-use/blob/125341c412ceee9233ece8973848b49e770a9b82/iwyu_output.cc#L469) to turn it into a forward-decl.

Sorry for stirring confusion into this, my primary focus is IWYU, but I remember that the original double-final came from a change intended for Clangd.

Hopefully this helps clarify.

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


More information about the cfe-commits mailing list