On Wed, Jan 22, 2025 at 9:08 AM Peter Eisentraut <pe...@eisentraut.org> wrote: > > It might be worth holding off for now. It's possible that I'll find > > --header-insertion=iwyu has big problems in some unforeseen way. But > > offhand it looks like a real improvement, even though I foresee > > certain minor downsides. What do you think? > > I had turned automatic header insertion off until now and didn't think > to turn it back on yet. I'll give it another try sometime.
I'm now a week into this experiment. So far, the results have been mixed. I'm tempted to turn --header-insertion=iwyu off now, since clangd header insertion with completion is in fact still adding what seem to me to be superfluous includes in some cases (though much less so compared to before your recent work). So it's still useful, but it might be more annoying than useful. Particularly compared to my original approach of relying on clangd errors + quick-fix actions to add required headers -- that doesn't have these problems (I seem to only be offered the option of a quick-fix when I get certain compile errors), and requires only minimal effort. > I'm unclear on what role clang-tidy would play in this. Sorry, I meant clang-format. The relevant section of my .clang-format file: SortIncludes: true IncludeIsMainSourceRegex: '(postgres\.h)$' IncludeCategories: - Regex: '^<.*\.h>' Priority: 1 SortPriority: 1 - Regex: 'postgres.h' Priority: 2 SortPriority: 2 - Regex: '.*' Priority: 3 SortPriority: 3 I'm guessing that you already have something like this (I believe I copied it from somebody else). This config is respected by clangd whenever it adds a header file (whether it's fully automatic or whether it's via a "missing header" quick-fix). -- Peter Geoghegan