Update pgindent's typedefs blacklist, and make it easier to adjust.

It seems that all buildfarm members are now using the <stdbool.h> code
path, so that none of them report "bool" as a typedef.  We still need it
to be treated that way, so adjust pgindent to force that whether or not
it's in the given list.

Also, the recent introduction of LLVM infrastructure has caused the
appearance of some typedef names that we definitely *don't* want
treated as typedefs, such as "string" and "abs".  Extend the existing
blacklist to include these.  (Additions based on comparing v10's
typedefs list to what the buildfarm is currently emitting.)

Rearrange the code so that the lists of whitelisted/blacklisted
names are a bit easier to find and modify.

Andrew Dunstan and Tom Lane

Discussion: https://postgr.es/m/28690.1521912334@sss.pgh.pa.us
This commit is contained in:
Tom Lane 2018-03-27 18:15:39 -04:00
parent 442accc3fe
commit ef1978d6ed
1 changed files with 18 additions and 3 deletions

View File

@ -50,6 +50,19 @@ $code_base ||= '.' unless @ARGV;
$excludes ||= "$code_base/src/tools/pgindent/exclude_file_patterns"
if $code_base && -f "$code_base/src/tools/pgindent/exclude_file_patterns";
# The typedef list that's mechanically extracted by the buildfarm may omit
# some names we want to treat like typedefs, e.g. "bool" (which is a macro
# according to <stdbool.h>), and may include some names we don't want
# treated as typedefs, although various headers that some builds include
# might make them so. For the moment we just hardwire a whitelist of names
# to add and a blacklist of names to remove; eventually this may need to be
# easier to configure. Note that the typedefs need trailing newlines.
my @whitelist = ("bool\n");
my %blacklist = map { +"$_\n" => 1 }
qw( FD_SET date interval timestamp ANY
abs allocfunc iterator other pointer printfunc reference string type );
# globals
my @files;
my $filtered_typedefs_fh;
@ -118,9 +131,11 @@ sub load_typedefs
}
}
# remove certain entries
@typedefs =
grep { !m/^(FD_SET|date|interval|timestamp|ANY)\n?$/ } @typedefs;
# add whitelisted entries
push(@typedefs, @whitelist);
# remove blacklisted entries
@typedefs = grep { ! $blacklist{$_} } @typedefs;
# write filtered typedefs
my $filter_typedefs_fh = new File::Temp(TEMPLATE => "pgtypedefXXXXX");