Re: IWYU annotations - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: IWYU annotations
Date
Msg-id 97ca4166-e858-4ac1-8abf-95c790b1a768@eisentraut.org
Whole thread Raw
In response to Re: IWYU annotations  (Peter Geoghegan <pg@bowt.ie>)
Responses Re: IWYU annotations
List pgsql-hackers
On 15.01.25 20:51, Peter Geoghegan wrote:
> On Wed, Jan 15, 2025 at 2:21 PM Peter Eisentraut <peter@eisentraut.org> wrote:
>> I have committed this.  Thanks for the feedback.
> 
> Thanks for working on this.
> 
> Is it worth documenting how to get clangd working sensibly with
> "--header-insertion=iwyu"?
> 
> I enabled it just now. I find that I can now use completion with a
> type name, and have clangd automatically include the necessary header
> file. For example, if I use completion to pull in a "StringInfoData" I
> find that clangd will automatically add the necessary #include
> "lib/stringinfo.h", without any special directions from me -- no
> context switching required. Importantly, now that we have these
> annotations, clangd won't constantly be adding useless includes that
> actually come from c.h -- that made IWYU header cleaning unusable
> before now.
> 
> Note that I'm relying on my clang-tidy config for this. clangd is able
> to respect our conventions around headers through clang-tidy, which
> has been taught Postgres-specific rules around header conventions. So
> we'd actually be documenting something about clang-tidy + clangd +
> Postgres header conventions, if we went through with something like
> this.
> 
> 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 unclear on what role clang-tidy would play in this.




pgsql-hackers by date:

Previous
From: m.litsarev@postgrespro.ru
Date:
Subject: Re: pg_stat_statements: improve loading and saving routines for the dump file
Next
From: Yura Sokolov
Date:
Subject: Re: [RFC] Lock-free XLog Reservation from WAL