Re: IWYU annotations

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: IWYU annotations
Date: 2025-01-22 14:22:58
Message-ID: CAH2-WzmVdObC7FL-kFC61fYVH-2W0JzsyTBhF7rPvCXfpt9WAg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 22, 2025 at 9:08 AM Peter Eisentraut <peter(at)eisentraut(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2025-01-22 14:44:49 Re: [RFC] Lock-free XLog Reservation from WAL
Previous Message Matheus Alcantara 2025-01-22 14:10:38 dblink: Add SCRAM pass-through authentication