[clang] [clang][Tooling] Insert global module fragment during header insertion (PR #173724)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 30 04:42:45 PST 2025
Lancern wrote:
> > > Maybe we can do something similar in #172966
> > > e.g, we should ask the tools to insert import std; instead of #include.
> > > We can file an issue for it as the first step.
> >
> >
> > The first step could be adding `import <header>` support to `HeaderIncludes`. Currently `HeaderIncludes` only supports `#include` and `#import`.
>
> The header units and STD module are not mutex to each other. And personally, I don't think suggesting things like `import <vector>` is very helpful. As standard header units are almost semantically the same thing with a textual include and also tools support and the practice for header units is pretty limited.
OK I got your point. I agree we should teach clangd to start inserting `import std;` if that's available.
I have a small concern here though: should we treat `std` module differently? It would be nice if clangd could auto-insert import-statements for user-defined modules as well.
https://github.com/llvm/llvm-project/pull/173724
More information about the cfe-commits
mailing list