[PATCH] D128204: [clangd] Add fix-it for inserting IWYU pragma: keep

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 22 00:09:01 PDT 2022


kadircet added a comment.

> I had another idea about offering the export pragma when in a header file but I don't know if that's going too far

There are definitely cases where this is conceptually "right" fix, but it's hard to guess that in clangd (well at least without having some codebase wide analysis), and offering it all the time would definitely confuse users.

> One of the main issues I have is due to templates not being instantiated which can result in symbols that are actually used not being picked up as the template instantiation that uses them isn't actually instantiated.

I guess you're talking about having the template pattern in the main file, but all the instantiations are in dependents of the code. My mental model was around making the dependents have the include for the type, instead of having it in the file providing the template pattern (header).  Does that make sense?
This kind of breaks down when there's actually some types used by all the instantiations, as you'd want them to be included by the header. But I think we should be able to diagnose these cases, as usage of this type should be non-dependent (at least in the cases I can think of), so this sounds like a bug/improvement.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128204/new/

https://reviews.llvm.org/D128204



More information about the cfe-commits mailing list