diff options
author | Quincey Koziol <koziol@koziol.gov> | 2019-07-03 04:43:45 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@koziol.gov> | 2019-07-03 04:43:45 (GMT) |
commit | 3b594992d6b062cf350d3f03e4b5c5d27b83a245 (patch) | |
tree | 42392ac76ff26413e3aee3989d60658189e2b57b /bin/warnhist | |
parent | d0bc570c2cdc4cbbb42cc1d4dac61aba67e20892 (diff) | |
download | hdf5-3b594992d6b062cf350d3f03e4b5c5d27b83a245.zip hdf5-3b594992d6b062cf350d3f03e4b5c5d27b83a245.tar.gz hdf5-3b594992d6b062cf350d3f03e4b5c5d27b83a245.tar.bz2 |
Add support for GCC9, update warnhist script, and clean up warnings.
Diffstat (limited to 'bin/warnhist')
-rwxr-xr-x | bin/warnhist | 279 |
1 files changed, 217 insertions, 62 deletions
diff --git a/bin/warnhist b/bin/warnhist index df7565e..499886b 100755 --- a/bin/warnhist +++ b/bin/warnhist @@ -40,6 +40,8 @@ my @ignorenames; my %ignored_files = (); my %warn_file_indices = (); my %file_warn_indices = (); +my @warn_match_strings; +my @file_match_strings; my %file_warn = (); my %file_warn_line = (); my $current_warning = 0; @@ -49,14 +51,10 @@ my $last_c_name; my $last_fort_name; my $last_fort_line; -# declare the Perl command line flags/options we want to allow -my %options=(); -getopts("FWht:w:f:i:l", \%options); - -# Display usage, if requested -if($options{h}) { - print "Usage: 'warnhist [-h] [-t <prefix>] [-w <n>] [-W] [-f <n>] [-F] [-l] [-i <name list> [file]'\n"; - print "\t-h\tDisplay this usage\n"; +# Display usage +sub do_help { + print "Usage: 'warnhist [-h, --help] [-t <prefix>] [-w <n>] [-W] [-f <n>] [-F] [-s <warning string list>] [-S <file string list] [-l] [-i <name list>] [file]'\n"; + print "\t-h, --help\tDisplay this usage\n"; print "\t-t <prefix>\tTrim pathname prefix from filenames, <prefix>\n"; print "\t-w <n>\tDisplay files for a given warning index list, <n>\n"; print "\t\t<n> can be a single value, a range, or a comma separated list\n"; @@ -66,6 +64,12 @@ if($options{h}) { print "\t\t<n> can be a single value, a range, or a comma separated list\n"; print "\t\tFor example: '0' or '0,4' or '8-10' or '0,2-4,8-10,13'\n"; print "\t-F\tDisplay warnings for all files\n"; + print "\t-s <warning string list>\tDisplay files for warnings which contain a string, <warning string list>\n"; + print "\t\t<warning string list> is a comma separated list, with no spaces\n"; + print "\t\tFor example: 'Wunused-dummy-argument' or 'Wunused-dummy-argument,Wunused-variable'\n"; + print "\t-S <file string list>\tDisplay warnings for files which contain a string, <file string list>\n"; + print "\t\t<file string list> is a comma separated list, with no spaces\n"; + print "\t\tFor example: 'H5Fint' or 'H5Fint,H5Gnode'\n"; print "\t-l\tDisplay line nunbers for file/warning\n"; print "\t-i <name list>\tIgnore named files, <name list>\n"; print "\t\t<name list> is a comma separated list, with no spaces\n"; @@ -75,6 +79,19 @@ if($options{h}) { exit; } +sub main::HELP_MESSAGE { + do_help(); +} + +# declare the Perl command line flags/options we want to allow +my %options=(); +getopts("FWht:w:f:s:S:i:l", \%options); + +# Display usage, if requested +if($options{h}) { + do_help(); +} + # Parse list of file names to ignore if(exists $options{i}) { @ignorenames = split /,/, $options{i}; @@ -98,13 +115,13 @@ if(exists $options{w}) { #print "start_index = '$start_index', end_index = '$end_index'\n"; for my $y ($start_index..$end_index) { #print "y = '$y'\n"; - if(!(exists $warn_file_indices{$y})) { + if(!exists $warn_file_indices{$y}) { $warn_file_indices{$y} = $y; } } } else { - if(!(exists $warn_file_indices{$x})) { + if(!exists $warn_file_indices{$x}) { $warn_file_indices{$x} = $x; } } @@ -114,6 +131,12 @@ if(exists $options{w}) { #} } +# Parse list of warning strings to expand file names +if(exists $options{s}) { + @warn_match_strings = split /,/, $options{s}; +# print @warn_match_strings; +} + # Parse list of file indices to expand warnings if(exists $options{f}) { my @tmp_indices; @@ -131,13 +154,13 @@ if(exists $options{f}) { #print "start_index = '$start_index', end_index = '$end_index'\n"; for my $y ($start_index..$end_index) { #print "y = '$y'\n"; - if(!(exists $file_warn_indices{$y})) { + if(!exists $file_warn_indices{$y}) { $file_warn_indices{$y} = $y; } } } else { - if(!(exists $file_warn_indices{$x})) { + if(!exists $file_warn_indices{$x}) { $file_warn_indices{$x} = $x; } } @@ -147,6 +170,12 @@ if(exists $options{f}) { #} } +# Parse list of warning strings for files to expand warnings +if(exists $options{S}) { + @file_match_strings = split /,/, $options{S}; +# print @file_match_strings; +} + PARSE_LINES: while (<>) { my $name; @@ -164,8 +193,8 @@ while (<>) { ($last_fort_line, $toss) = split /\./, $last_fort_line; } - # Retain last C compile line, which possibly comes a few lines before warning - if($_ =~ /.*[A-Za-z0-9_]\.c:.*/) { + # Retain last C/C++ compile line, which possibly comes a few lines before warning + if($_ =~ /.*[A-Za-z0-9_]\.[cC]:.*/) { ($last_c_name, $toss) = split /\:/, $_; } @@ -175,6 +204,9 @@ while (<>) { # Skip warnings from linker next if $_ =~ /ld: warning:/; + # Skip warnings from build_py and install_lib + next if $_ =~ /warning: (build_py|install_lib)/; + # "Hide" the C++ '::' symbol until we've parsed out the parts of the line while($_ =~ /\:\:/) { $_ =~ s/\:\:/@@@@/g; @@ -185,6 +217,11 @@ while (<>) { $name = $last_c_name; $line = "??"; ($toss, $toss, $warning, $extra, $extra2) = split /\:/, $_; + # Check for CMAKE build with warning on first line and no filename + } elsif($_ =~ /^\s*[Ww]arning:.*/) { + $name = $last_c_name; + $line = "??"; + ($toss, $warning, $extra, $extra2) = split /\:/, $_; # Check for FORTRAN warning output } elsif($_ =~ /^Warning:.*/) { $name = $last_fort_name; @@ -287,8 +324,8 @@ while (<>) { next if $_ =~ /\(this will be reported only once per input file\)/; # Eliminate "{aka <some type>}" and "{aka '<some type>'}" info - if($warning =~ /\s\{aka '?[A-Za-z_0-9]+[A-Za-z_0-9\(\)\*\,\ ]*'?/) { - $warning =~ s/\s\{aka '?[A-Za-z_0-9]+[A-Za-z_0-9\(\)\*\,\ ]*'?\}//g; + if($warning =~ /\s(\{|\()aka '?[A-Za-z_0-9]+[A-Za-z_0-9\(\)\*\,\[\]\ ]*'?(\}|\))/) { + $warning =~ s/\s(\{|\()aka '?[A-Za-z_0-9]+[A-Za-z_0-9\(\)\*\,\[\]\ ]*'?(\}|\))//g; } # print "warning = $warning\n"; @@ -297,6 +334,8 @@ while (<>) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; } elsif($warning =~ /unused variable '[A-Za-z_0-9]*'.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; + } elsif($warning =~ /unused function '[A-Za-z_0-9]*'.*/) { + $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; } elsif($warning =~ /implicit conversion from '[A-Za-z_0-9]*' to '[A-Za-z_0-9]*' when passing argument to function.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; } elsif($warning =~ /implicit conversion from '[A-Za-z_0-9]*' to '[A-Za-z_0-9]*' to match other operand of binary expression.*/) { @@ -361,15 +400,21 @@ while (<>) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; } elsif($warning =~ /Unused dummy argument '[A-Za-z_0-9]*'.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; + $warning =~ s/\([0-9]+\)/\(-\)/g; } elsif($warning =~ /Unused parameter '[A-Za-z_0-9]*' declared at.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; + $warning =~ s/\([0-9]+\)/\(-\)/g; } elsif($warning =~ /Unused variable '[A-Za-z_0-9]*' declared at.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; } elsif($warning =~ /Inequality comparison for REAL\([0-9]*\) at.*/) { $warning =~ s/REAL\([0-9]*\)/REAL\(-\)/g; + $warning =~ s/\([0-9]+\)/\(-\)/g; } elsif($warning =~ /Possible change of value in conversion from INTEGER\([0-9]*\) to (INTEGER|REAL)\([0-9]*\) at.*/) { $warning =~ s/INTEGER\([0-9]*\)/INTEGER\(-\)/g; $warning =~ s/REAL\([0-9]*\)/REAL\(-\)/g; + } elsif($warning =~ /Equality comparison for REAL\([0-9]*\) at.*/) { + $warning =~ s/REAL\([0-9]*\)/REAL\(-\)/g; + $warning =~ s/\([0-9]+\)/\(-\)/g; } elsif($warning =~ /passing argument [0-9]* of '[A-Za-z_0-9]*' with different width due to prototype.*/) { $warning =~ s/passing argument [0-9]*/passing argument -/g; $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; @@ -394,8 +439,8 @@ while (<>) { $warning =~ s/'[a-z][a-z_,\s\*\(\)]*'/'-'/g; } elsif($warning =~ /implicit declaration of function '[A-Za-z_0-9]*'.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; - } elsif($warning =~ /'[A-Za-z_\.\[\]0-9]*' may be used uninitialized in this function.*/) { - $warning =~ s/'[A-Za-z_\.\[\]0-9]*'/'-'/g; + } elsif($warning =~ /'[A-Za-z_\.\[\]\(\)\*\&\+0-9]+[A-Za-z_\.\[\]\(\)\*\&\+0-9\ ]*' may be used uninitialized in this function.*/) { + $warning =~ s/'[A-Za-z_\.\[\]\(\)\*\&\+0-9]+[A-Za-z_\.\[\]\(\)\*\&\+0-9\ ]*'/'-'/g; } elsif($warning =~ /redundant redeclaration of '[A-Za-z_0-9]*'.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; } elsif($warning =~ /declaration of '[A-Za-z_0-9]*' shadows a parameter.*/) { @@ -411,6 +456,8 @@ while (<>) { } elsif($warning =~ /enum conversion when passing argument [0-9]* of '[A-Za-z_0-9]*' is invalid.*/) { $warning =~ s/passing argument [0-9]*/passing argument -/g; $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; + } elsif($warning =~ /enum conversion from '[A-Za-z_0-9]*' to '[A-Za-z_0-9]*' in assignment is invalid in C\+\+.*/) { + $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; } elsif($warning =~ /duplicate declaration of '[A-Za-z_0-9]*' is invalid in.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; } elsif($warning =~ /Variable '[A-Za-z_0-9]*' at \([0-9]*\) is a dummy argument of the BIND\(C\) procedure '[A-Za-z_0-9]*' but may not be C interoperable.*/) { @@ -422,64 +469,142 @@ while (<>) { } elsif($warning =~ /Component '[A-Za-z_0-9]*' in derived type '[A-Za-z_0-9]*' at \([0-9]*\) may not be C interoperable, even though derived type '[A-Za-z_0-9]*' is BIND\(C\).*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; $warning =~ s/at \([0-9]*\)/at \(-\)/g; - } elsif($warning =~ /function might be candidate for attribute '[A-Za-z_0-9]*' if it is known to return normally \[-Wsuggest-attribute=[A-Za-z_0-9]*\].*/) { + } elsif($warning =~ /function might be candidate for attribute '[A-Za-z_0-9]*' if it is known to return normally.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; $warning =~ s/=[A-Za-z_0-9]*\]/=-\]/g; - } elsif($warning =~ /function might be candidate for attribute '[A-Za-z_0-9]*' \[-Wsuggest-attribute=[A-Za-z_0-9]*\].*/) { + } elsif($warning =~ /function might be candidate for attribute '[A-Za-z_0-9]*'.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; $warning =~ s/=[A-Za-z_0-9]*\]/=-\]/g; - } elsif($warning =~ /passing argument [0-9]+ of '[A-Za-z_0-9]*' makes integer from pointer without a cast \[-Wint-conversion\].*/) { + } elsif($warning =~ /passing argument [0-9]+ of '[A-Za-z_0-9]*' makes integer from pointer without a cast.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; $warning =~ s/[0-9]+/-/g; - } elsif($warning =~ /function '[A-Za-z_0-9]*' might be a candidate for '[A-Za-z_0-9]*' format attribute \[-Wsuggest-attribute=format\].*/) { + } elsif($warning =~ /function '[A-Za-z_0-9]*' might be a candidate for '[A-Za-z_0-9]*' format attribute.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; - } elsif($warning =~ /inlining failed in call to '[A-Za-z_0-9]*': call is unlikely and code size would grow \[-Winline\].*/) { + } elsif($warning =~ /inlining failed in call to '[A-Za-z_0-9]*': call is unlikely and code size would grow.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; - } elsif($warning =~ /'%[0-9]*[\.\*]*[0-9]*[L]*[dfsu]' directive writing (between [0-9]+ and [0-9]+)|(up to [0-9]+) bytes into a region of size (between [0-9]+ and [0-9]+)|([0-9]+) \[-Wformat-overflow=\].*/) { - $warning =~ s/'%[0-9]*[\.\*]*[0-9]*[L]*[dfsu]'/'-'/g; + } elsif($warning =~ /'%[0-9]*[\.\*]*[0-9]*L*[dfsu]' directive writing ((between [0-9]+ and [0-9]+)|(up to [0-9]+)) bytes into a region of size ((between [0-9]+ and [0-9]+)|([0-9]+)).*/) { + $warning =~ s/'%[0-9]*[\.\*]*[0-9]*L*[dfsu]'/'-'/g; $warning =~ s/[0-9]+/-/g; - } elsif($warning =~ /'(%[0-9]*[\.\*]*[0-9]*[dfsu])|([A-Za-z_0-9\/]+)' directive output may be truncated writing (between [0-9]+ and [0-9]+)|(up to [0-9]+)|(likely 1 or more) byte(s)? into a region of size (between [0-9]+ and [0-9]+)|([0-9]+) \[-Wformat-truncation=\].*/) { + } elsif($warning =~ /'((%[0-9]*[\.\*]*[0-9]*[dfsu])|([A-Za-z_0-9\/]+))' directive output may be truncated writing ((between [0-9]+ and [0-9]+)|(up to [0-9]+)|([0-9+)|(likely 1 or more)) byte(s)? into a region of size ((between [0-9]+ and [0-9]+)|([0-9]+)).*/) { $warning =~ s/'%[0-9]*[\.\*]*[0-9]*[dfsu]'/'-'/g; $warning =~ s/'[A-Za-z_0-9\/]+'/'-'/g; $warning =~ s/[0-9]+/-/g; - } elsif($warning =~ /conversion to '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' from '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' may change the sign of the result \[-Wsign-conversion\].*/) { + } elsif($warning =~ /'%[0-9]*[\.\*]*[0-9]*[dfsu]' directive argument is null.*/) { + $warning =~ s/'%[0-9]*[\.\*]*[0-9]*[dfsu]'/'-'/g; + } elsif($warning =~ /conversion to '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' from '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' may change the sign of the result.*/) { $warning =~ s/'[A-Za-z_0-9]+[A-Za-z_0-9\ ]*'/'-'/g; - } elsif($warning =~ /unsigned conversion from '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' to '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' changes value from '-?[0-9]+' to '[0-9]+' \[-Wsign-conversion\].*/) { + } elsif($warning =~ /unsigned conversion from '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' to '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' changes value from '-?[0-9]+' to '[0-9]+'.*/) { $warning =~ s/'[A-Za-z_0-9]+[A-Za-z_0-9\ ]*'/'-'/g; $warning =~ s/'-?[0-9]+'/'-'/g; - } elsif($warning =~ /conversion from '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' to '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' may change value \[-Wconversion\].*/) { + } elsif($warning =~ /conversion from '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' to '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' may change value.*/) { $warning =~ s/'[A-Za-z_0-9]+[A-Za-z_0-9\ ]*'/'-'/g; - } elsif($warning =~ /overflow in conversion from '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' to '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' changes value from '-?[0-9]+' to '-?[0-9]+' \[-Woverflow\].*/) { + } elsif($warning =~ /overflow in conversion from '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' to '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' changes value from '-?[0-9]+' to '-?[0-9]+'.*/) { $warning =~ s/'[A-Za-z_0-9]+[A-Za-z_0-9\ ]*'/'-'/g; $warning =~ s/'-?[0-9]+'/'-'/g; - } elsif($warning =~ /cast between incompatible function types from '[A-Za-z_0-9]+[A-Za-z_0-9\(\)\*\,\ ]*' to '[A-Za-z_0-9]+[A-Za-z_0-9\(\)\*\,\ ]*' \[-Wcast-function-type\].*/) { + } elsif($warning =~ /cast between incompatible function types from '[A-Za-z_0-9]+[A-Za-z_0-9\(\)\*\,\ ]*' to '[A-Za-z_0-9]+[A-Za-z_0-9\(\)\*\,\ ]*'.*/) { $warning =~ s/'[A-Za-z_0-9]+[A-Za-z_0-9\(\)\*\,\ ]*'/'-'/g; - } elsif($warning =~ /(return|initialization|assignment) discards '[A-Za-z_0-9]*' qualifier from pointer target type \[-Wdiscarded-qualifiers\].*/) { + } elsif($warning =~ /(return|initialization|assignment) discards '[A-Za-z_0-9]*' qualifier from pointer target type.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; - } elsif($warning =~ /'[A-Za-z_0-9]*' attribute on function returning '[A-Za-z_0-9]*' \[-Wattributes\].*/) { + } elsif($warning =~ /'[A-Za-z_0-9]*' attribute on function returning '[A-Za-z_0-9]*'.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; - } elsif($warning =~ /ignoring return value of '[A-Za-z_0-9]*', declared with attribute warn_unused_result \[-Wunused-result\].*/) { + } elsif($warning =~ /ignoring return value of '[A-Za-z_0-9]*', declared with attribute warn_unused_result.*/) { $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; - } elsif($warning =~ /passing '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' chooses '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' over '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' \[-Wsign-promo\].*/) { + } elsif($warning =~ /passing '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' chooses '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*' over '[A-Za-z_0-9]+[A-Za-z_0-9\ ]*'.*/) { $warning =~ s/'[A-Za-z_0-9]+[A-Za-z_0-9\ ]*'/'-'/g; - } elsif($warning =~ /'[A-Za-z_\:0-9]+[A-Za-z_\:0-9\ ]*' should be initialized in the member initialization list \[-Weffc\+\+\].*/) { + } elsif($warning =~ /'[A-Za-z_\:0-9]+[A-Za-z_\:0-9\ ]*' should be initialized in the member initialization list.*/) { $warning =~ s/'[A-Za-z_\:0-9]+[A-Za-z_\:0-9\ ]*'/'-'/g; } elsif($warning =~ /\[deprecation\] [A-Za-z_0-9]*\([A-Za-z_,0-9]*\) in [A-Za-z_0-9]* has been deprecated.*/) { $warning =~ s/[A-Za-z_0-9]*\([A-Za-z_,0-9]*\) in [A-Za-z_0-9]*/-\(-\) in -/g; + } elsif($warning =~ /size of '[A-Za-z_\*0-9]*' [0-9]+ bytes exceeds maximum object size [0-9]+ .*/) { + $warning =~ s/'[A-Za-z_\*0-9]*'/'-'/g; + $warning =~ s/[0-9]+/-/g; + } elsif($warning =~ /'[A-Za-z_0-9]*' output truncated before terminating nul copying [0-9]+ bytes from a string of the same length.*/) { + $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; + $warning =~ s/[0-9]+/-/g; + } elsif($warning =~ /assignment to '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' from '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' makes pointer from integer without a cast.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'/'-'/g; + } elsif($warning =~ /assignment to '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' from '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' makes integer from pointer without a cast.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'/'-'/g; + } elsif($warning =~ /assignment to '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' from incompatible pointer type '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'/'-'/g; + } elsif($warning =~ /ignoring attribute '[a-z]*' because it conflicts with attribute '[a-z]*'.*/) { + $warning =~ s/'[a-z]*'/'-'/g; + } elsif($warning =~ /passing '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' to parameter of type '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' discards qualifiers.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'/'-'/g; + } elsif($warning =~ /assigning to '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' from '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' discards qualifiers.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'/'-'/g; + } elsif($warning =~ /unknown warning group '[A-Za-z-=]*', ignored.*/) { + $warning =~ s/'[A-Za-z-=]*'/'-'/g; + } elsif($warning =~ /'[A-Za-z_0-9]*' macro redefined.*/) { + $warning =~ s/'[A-Za-z_0-9]*'/'-'/g; + } elsif($warning =~ /"[A-Za-z_0-9]*" redefined.*/) { + $warning =~ s/"[A-Za-z_0-9]*"/"-"/g; + } elsif($warning =~ /incompatible (pointer|integer) to (pointer|integer) conversion assigning to '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' from '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'/'-'/g; + } elsif($warning =~ /returning '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' from a function with result type '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' discards qualifiers.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'/'-'/g; + } elsif($warning =~ /array index [0-9]+ is past the end of the array \(which contains [0-9]+ elements\).*/) { + $warning =~ s/[0-9]+/-/g; + } elsif($warning =~ /array subscript [0-9]+ is above array bounds of '[A-Za-z_\*\.0-9]+[A-Za-z_\*\.\[\]0-9\ ]*'.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*\.\[\]0-9\ ]*'/'-'/g; + $warning =~ s/[0-9]+/-/g; + } elsif($warning =~ /expression which evaluates to zero treated as a null pointer constant of type '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'/'-'/g; + } elsif($warning =~ /result of comparison of constant [0-9]+ with expression of type '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' is always (true|false).*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'/'-'/g; + $warning =~ s/[0-9]+/-/g; + } elsif($warning =~ /initializing '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' with an expression of type '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' discards qualifiers.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'/'-'/g; + } elsif($warning =~ /implicit conversion from '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' to '[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*' changes value from -?[0-9]+ to -?[0-9]+.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*0-9\ ]*'/'-'/g; + $warning =~ s/-?[0-9]+/-/g; + } elsif($warning =~ /passing '[A-Za-z_\*0-9]+[A-Za-z_\*\[\]0-9\ ]*' to parameter of type '[A-Za-z_\*0-9]+[A-Za-z_\*\[\]0-9\ ]*' converts between pointers to integer types with different sign.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*\[\]0-9\ ]*'/'-'/g; + } elsif($warning =~ /address of '[A-Za-z_\*\.0-9]+[A-Za-z_\*\.0-9\ ]*' will always evaluate to 'true'.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*\.0-9\ ]*'/'-'/g; + } elsif($warning =~ /length modifier '[A-Za-z]' results in undefined behavior or no effect with '[A-Za-z]' conversion specifier.*/) { + $warning =~ s/'[A-Za-z]'/'-'/g; + } elsif($warning =~ /'[A-Za-z_]+' specified bound depends on the length of the source argument.*/) { + $warning =~ s/'[A-Za-z_]+'/'-'/g; + } elsif($warning =~ /'[A-Za-z_]+' specified bound [0-9]+ equals destination size.*/) { + $warning =~ s/'[A-Za-z_]+'/'-'/g; + $warning =~ s/[0-9]+/-/g; + } elsif($warning =~ /'[A-Za-z_]+' output may be truncated copying between [0-9]+ and [0-9]+ bytes from a string of length [0-9]+.*/) { + $warning =~ s/'[A-Za-z_]+'/'-'/g; + $warning =~ s/[0-9]+/-/g; + } elsif($warning =~ /'[A-Za-z_]+' output may be truncated before the last format character.*/) { + $warning =~ s/'[A-Za-z_]+'/'-'/g; + } elsif($warning =~ /'[A-Za-z_]+' output truncated before terminating nul copying as many bytes from a string as its length.*/) { + $warning =~ s/'[A-Za-z_]+'/'-'/g; + } elsif($warning =~ /'[A-Za-z_\:0-9]+' hides overloaded virtual function.*/) { + $warning =~ s/'[A-Za-z_\:0-9]+'/'-'/g; + } elsif($warning =~ /'[A-Za-z_]+' storage class specifier is deprecated and incompatible with C\+\+1z.*/) { + $warning =~ s/'[A-Za-z_]+'/'-'/g; + } elsif($warning =~ /explicitly assigning value of variable of type '[A-Za-z_\*\.0-9]+[A-Za-z_\*\.0-9\ ]*' to itself.*/) { + $warning =~ s/'[A-Za-z_\*0-9]+[A-Za-z_\*\.0-9\ ]*'/'-'/g; + } elsif($warning =~ /private field '[A-Za-z_0-9]+' is not used.*/) { + $warning =~ s/'[A-Za-z_0-9]+'/'-'/g; + } elsif($warning =~ /field '[A-Za-z_0-9]+' will be initialized after field '[A-Za-z_0-9]+'.*/) { + $warning =~ s/'[A-Za-z_0-9]+'/'-'/g; } +# print "warning = $warning\n"; - # Increment count for [generic] warning - $warn_count{$warning}++; - $warn_file{$warning}{$name}++; - push(@{ $warn_file_line{$warning}{$name} }, $line); - - # Increment count for filename - $file_count{$name}++; - $file_warn{$name}{$warning}++; - push(@{ $file_warn_line{$name}{$warning} }, $line); - - # Increment total count of warnings - $totalcount++; + # Check if we've already seen this warning on this line in this file + # (Can happen for warnings from inside header files) + if( !exists $warn_file_line{$warning}{$name}{$line} ) { + # Increment count for [generic] warning + $warn_count{$warning}++; + $warn_file{$warning}{$name}++; + $warn_file_line{$warning}{$name}{$line}++; + + # Increment count for filename + $file_count{$name}++; + $file_warn{$name}{$warning}++; + $file_warn_line{$name}{$warning}{$line}++; + + # Increment total count of warnings + $totalcount++; + } # print "name = $name\n"; # print "line = $line\n"; @@ -487,7 +612,7 @@ while (<>) { # print "warning = \"$warning\"\n"; } -print "Total [non-ignored] warnings: $totalcount\n"; +print "Total unique [non-ignored] warnings: $totalcount\n"; print "Total ignored warnings: $ignorecount\n"; $warncount = keys %warn_count; print "Total unique kinds of warnings: $warncount\n"; @@ -499,18 +624,33 @@ print "# of Warnings by frequency (file count)\n"; print "=======================================\n"; for my $x (sort {$warn_count{$b} <=> $warn_count{$a}} keys(%warn_count)) { printf ("[%2d] %4d (%2d) - %s\n", $current_warning++, $warn_count{$x}, scalar(keys %{$warn_file_line{$x}}), $x); - if((exists $options{W}) || (exists $options{w})) { + if((exists $options{W}) || (exists $options{w}) || (exists $options{s})) { my $curr_index = $current_warning - 1; - + my $match = 0; + + # Check for string from list in current warning + if(exists $options{s}) { + for my $y (@warn_match_strings) { +# print "y = '$y'\n"; + if($x =~ /$y/) { +# print "matched warning = '$x'\n"; + $match = 1; + last; + } + } + } + + # Check if current warning index matches if((exists $warn_file_indices{$curr_index}) && $curr_index == $warn_file_indices{$curr_index}) { + $match = 1; + } + + if($match) { for my $y (sort {$warn_file{$x}{$b} <=> $warn_file{$x}{$a}} keys(%{$warn_file{$x}})) { printf ("\t%4d - %s\n", $warn_file{$x}{$y}, $y); if(exists $options{l}) { - printf ("\t\tLines: "); - for my $z ( @{ $warn_file_line{$x}{$y} } ) { - printf ("%s, ", $z); - } - printf("\n"); + my $lines = join ", ", sort {$a <=> $b} keys $warn_file_line{$x}{$y}; + printf("\t\tLines: $lines \n"); } } } @@ -524,16 +664,31 @@ for my $x (sort {$file_count{$b} <=> $file_count{$a}} keys(%file_count)) { printf ("[%3d] %4d (%2d) - %s\n", $current_file++, $file_count{$x}, scalar(keys %{$file_warn_line{$x}}), $x); if((exists $options{F}) || (exists $options{f})) { my $curr_index = $current_file - 1; - + my $match = 0; + + # Check for string from list in current file + if(exists $options{S}) { + for my $y (@file_match_strings) { +# print "y = '$y'\n"; + if($x =~ /$y/) { +# print "matched warning = '$x'\n"; + $match = 1; + last; + } + } + } + + # Check if current file index matches if((exists $file_warn_indices{$curr_index}) && $curr_index == $file_warn_indices{$curr_index}) { + $match = 1; + } + + if($match) { for my $y (sort {$file_warn{$x}{$b} <=> $file_warn{$x}{$a}} keys(%{$file_warn{$x}})) { printf ("\t%4d - %s\n", $file_warn{$x}{$y}, $y); if(exists $options{l}) { - printf ("\t\tLines: "); - for my $z ( @{ $file_warn_line{$x}{$y} } ) { - printf ("%s, ", $z); - } - printf("\n"); + my $lines = join ", ", sort {$a <=> $b} keys $file_warn_line{$x}{$y}; + printf("\t\tLines: $lines \n"); } } } |