[clang] [clang][Tooling] Insert global module fragment during header insertion (PR #173724)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 30 08:25:34 PST 2025
ChuanqiXu9 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? Or this could be a step in a larger attempt that teaches clangd to auto-insert import-statements for any modules?
We can treat std module specially as the first step since we already have the ability to insert standard headers, then it will be simpler.
It will be much better too if we're able to generalize this to any modules.
https://github.com/llvm/llvm-project/pull/173724
More information about the cfe-commits
mailing list