Re: [HACKERS] Preliminary results for proposed new pgindentimplementation - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: [HACKERS] Preliminary results for proposed new pgindentimplementation
Date
Msg-id 1b99bd34-04f1-cc33-1cfa-70501e92c008@iki.fi
Whole thread Raw
In response to Re: [HACKERS] Preliminary results for proposed new pgindentimplementation  (Stephen Frost <sfrost@snowman.net>)
Responses Re: [HACKERS] Preliminary results for proposed new pgindent implementation  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 05/19/2017 06:05 PM, Stephen Frost wrote:
> * Tom Lane (tgl@sss.pgh.pa.us) wrote:
>> Robert Haas <robertmhaas@gmail.com> writes:
>>> On Thu, May 18, 2017 at 11:00 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>>> The reason PGSSTrackLevel is "unrecognized" is that it's not in
>>>> typedefs.list, which is a deficiency in our typedef-collection
>>>> technology not in indent.  (I believe the problem is that there
>>>> are no variables declared with that typename, causing there to
>>>> not be any of the kind of symbol table entries we are looking for.)
>>
>>> This, however, doesn't sound so good.  Isn't there some way this can be fixed?
>>
>> I'm intending to look into it, but I think it's mostly independent of
>> whether we replace pgindent itself.  The existing code has the same
>> problem, really.
>>
>> One brute-force way we could deal with the problem is to have a "manual"
>> list of names to be treated as typedefs, in addition to whatever the
>> buildfarm produces.  I see no other way than that to get, for instance,
>> simplehash.h's SH_TYPE to be formatted as a typedef.  There are also
>> some typedefs that don't get formatted correctly because they are only
>> used for wonky options that no existing typedef-reporting buildfarm member
>> builds.  Manual addition might be the path of least resistance there too.
>>
>> Now the other side of this coin is that, by definition, such typedefs
>> are not getting used in a huge number of places.  If we just had to
>> live with it, it might not be awful.
>
> Dealing with the typedef lists in general is a bit of a pain to get
> right, to make sure that new just-written code gets correctly indented.
> Perhaps we could find a way to incorporate the buildfarm typedef lists
> and a manual list and a locally generated/provided set in a simpler
> fashion in general.

You can get a pretty good typedefs list just by looking for the pattern 
"} <type name>;". Something like this:

grep -o -h -I --perl-regexp -r "}\W(\w+);" src/ contrib/ | perl -pe 
's/}\W(.*);/\1/' | sort | uniq > typedefs.list

It won't cover system headers and non-struct typedefs, but it catches 
those simplehash typedefs and PGSSTrackLevel. Maybe we should run that 
and merge the result with the typedef lists we collect in the buildfarm.

- Heikki




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] PG10 Crash-safe and replicable Hash Indexes and UNIQUE
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Preliminary results for proposed new pgindent implementation