summaryrefslogtreecommitdiffstats
path: root/bin/warnhist
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2022-04-13 21:17:29 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2022-04-13 21:17:29 (GMT)
commitcabc39c3e197e2591449d2604bfee26465fb60e1 (patch)
treed5f39f5f5965584bf9bf49646a2af617adfd3e4e /bin/warnhist
parent7355f4c505092a7a85474b47f18d5206028e2c95 (diff)
parentab69f5df770ee3cc6cd6c81d905a5317b894a002 (diff)
downloadhdf5-feature/coding_standards.zip
hdf5-feature/coding_standards.tar.gz
hdf5-feature/coding_standards.tar.bz2
Merge branch 'develop' into feature/coding_standardsfeature/coding_standards
Diffstat (limited to 'bin/warnhist')
-rwxr-xr-xbin/warnhist135
1 files changed, 80 insertions, 55 deletions
diff --git a/bin/warnhist b/bin/warnhist
index 7e56246..0150138 100755
--- a/bin/warnhist
+++ b/bin/warnhist
@@ -1,5 +1,6 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
require 5.003;
+use warnings;
#
# Copyright by The HDF Group.
@@ -14,7 +15,7 @@ require 5.003;
# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
# access to either file, you may request a copy from help@hdfgroup.org.
#
-# Quincey Koziol, koziol@hdfgroup.org
+# Quincey Koziol
# 9 Aug 2013
#
# Purpose: Given an input file containing the output from a build of the
@@ -29,10 +30,13 @@ use Getopt::Std;
# Global variables, for accumulating information
my $totalcount = 0;
+my $notecount = 0;
+my $dupcount = 0;
my %warn_count = ();
my $warncount;
my %warn_file = ();
my %warn_file_line = ();
+my %warn_file_line_offset = ();
my %file_count = ();
my $filecount;
my $ignorecount = 0;
@@ -47,10 +51,13 @@ my %file_warn_line = ();
my $current_warning = 0;
my $current_file = 0;
my $warn_index;
+my $genericize = 1;
+
+# Info about last name / line / offset for file
my $last_c_name;
my $last_fort_name;
my $last_fort_line;
-my $genericize = 1;
+my $last_fort_offset;
# Display usage
sub do_help {
@@ -71,7 +78,7 @@ sub do_help {
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-l\tDisplay line numbers for file/warning\n";
print "\t-u\tLeave 'unique' types in warnings, instead of genericizing them\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";
@@ -97,7 +104,7 @@ if($options{h}) {
# Parse list of file names to ignore
if(exists $options{i}) {
@ignorenames = split /,/, $options{i};
-#print @ignorenames;
+#print STDERR @ignorenames;
}
# Parse list of warning indices to expand file names
@@ -105,18 +112,18 @@ if(exists $options{w}) {
my @tmp_indices;
@tmp_indices = split /,/, $options{w};
-#print @tmp_indices;
+#print STDERR @tmp_indices;
for my $x (@tmp_indices) {
-#print "x = '$x'\n";
+#print STDERR "x = '$x'\n";
if($x =~ /\-/) {
my $start_index;
my $end_index;
-#print "matched = '$x'\n";
+#print STDERR "matched = '$x'\n";
($start_index, $end_index) = split /\-/, $x;
-#print "start_index = '$start_index', end_index = '$end_index'\n";
+#print STDERR "start_index = '$start_index', end_index = '$end_index'\n";
for my $y ($start_index..$end_index) {
-#print "y = '$y'\n";
+#print STDERR "y = '$y'\n";
if(!exists $warn_file_indices{$y}) {
$warn_file_indices{$y} = $y;
}
@@ -129,14 +136,14 @@ if(exists $options{w}) {
}
}
#foreach (sort keys %warn_file_indices) {
-# print "$_ : $warn_file_indices{$_}\n";
+# print STDERR "$_ : $warn_file_indices{$_}\n";
#}
}
# Parse list of warning strings to expand file names
if(exists $options{s}) {
@warn_match_strings = split /,/, $options{s};
-# print @warn_match_strings;
+# print STDERR @warn_match_strings;
}
# Parse list of file indices to expand warnings
@@ -144,18 +151,18 @@ if(exists $options{f}) {
my @tmp_indices;
@tmp_indices = split /,/, $options{f};
-#print @tmp_indices;
+#print STDERR @tmp_indices;
for my $x (@tmp_indices) {
-#print "x = '$x'\n";
+#print STDERR "x = '$x'\n";
if($x =~ /\-/) {
my $start_index;
my $end_index;
-#print "matched = '$x'\n";
+#print STDERR "matched = '$x'\n";
($start_index, $end_index) = split /\-/, $x;
-#print "start_index = '$start_index', end_index = '$end_index'\n";
+#print STDERR "start_index = '$start_index', end_index = '$end_index'\n";
for my $y ($start_index..$end_index) {
-#print "y = '$y'\n";
+#print STDERR "y = '$y'\n";
if(!exists $file_warn_indices{$y}) {
$file_warn_indices{$y} = $y;
}
@@ -168,14 +175,14 @@ if(exists $options{f}) {
}
}
#foreach (sort keys %warn_file_indices) {
-# print "$_ : $warn_file_indices{$_}\n";
+# print STDERR "$_ : $warn_file_indices{$_}\n";
#}
}
# Parse list of warning strings for files to expand warnings
if(exists $options{S}) {
@file_match_strings = split /,/, $options{S};
-# print @file_match_strings;
+# print STDERR @file_match_strings;
}
# Check if warnings should stay unique and not be "genericized"
@@ -196,7 +203,7 @@ while (<>) {
# Retain last FORTRAN compile line, which comes a few lines before warning
if($_ =~ /.*\.[fF]90:.*/) {
- ($last_fort_name, $last_fort_line, $toss) = split /\:/, $_;
+ ($last_fort_name, $last_fort_line, $last_fort_offset) = split /\:/, $_;
($last_fort_line, $toss) = split /\./, $last_fort_line;
}
@@ -205,44 +212,45 @@ while (<>) {
($last_c_name, $toss) = split /\:/, $_;
}
+ # Retain C/C++ compile line, which comes with the line of warning
+ if($_ =~ /.*[A-Za-z0-9_]\.[chC]\(.*[0-9]\):.*#.*/) {
+ $last_c_name = $_;
+ }
+
# Skip lines that don't have the word "warning"
- next if $_ !~ /[Ww]arning:/;
+ next if $_ !~ /[Ww]arning/;
# Skip warnings from linker
next if $_ =~ /ld: warning:/;
- # Skip warnings from build_py and install_lib
+ # Skip warnings from build_py and install_lib
next if $_ =~ /warning: (build_py|install_lib)/;
+ # Skip variables with the word 'warning' in them
+ next if $_ =~ /_warning_/;
+
# "Hide" the C++ '::' symbol until we've parsed out the parts of the line
while($_ =~ /\:\:/) {
$_ =~ s/\:\:/@@@@/g;
}
# Check for weird formatting of warning message
+ $line = "??";
+ $offset = "??";
if($_ =~ /^cc1: warning:.*/) {
$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;
$line = $last_fort_line;
+ $offset = $last_fort_offset;
($toss, $warning, $extra, $extra2) = split /\:/, $_;
-#print "1:",$.,":",$_;
-# $_ = <>;
-#print "2:",$.,":",$_;
-# if($_ =~ /^\sFC.*/) {
-# $_ = <>;
-#print "3:",$.,":",$_;
-# }
-# ($name, $line, $toss) = split /\:/, $_;
-#print "4:","'",$name,"'","-","'",$line,"'","\n";
+
# Check for improperly parsed filename or line
if($name =~ /^$/) {
print "Filename is a null string! Input line #$. is: '$_'";
@@ -256,11 +264,14 @@ while (<>) {
} elsif($_ =~ /^\".*, line [0-9]+: *[Ww]arning:.*/) {
($name, $toss, $warning, $extra, $extra2) = split /\:/, $_;
($name, $line) = split /\,/, $name;
- $name =~ s/^\"//g;
- $name =~ s/\"$//g;
- $line =~ s/^\s*line\s*//g;
-# print "name:'", $name, "'-'", $line, "'\n";
-# print "warning:'", $warning, "'\n";
+ $name =~ s/^\"//g;
+ $name =~ s/\"$//g;
+ $line =~ s/^\s*line\s*//g;
+ # Check for Intel icc warning
+ } elsif($_ =~ /.*[A-Za-z0-9_]\.[chC]\(.*[0-9]\):.*#.*/) {
+ ($last_c_name, $toss, $warning) = split /\:/, $last_c_name;
+ ($name, $line) = split /\(/, $last_c_name;
+ $line =~ s/\)//g;
} else {
# Check for 'character offset' field appended to file & line #
# (This is probably specific to GCC)
@@ -299,9 +310,7 @@ while (<>) {
# Check for ignored file
if(exists $options{i}) {
for my $x (@ignorenames) {
-#print "x = '$x'\n";
if($name =~ /$x/) {
-# print "matched name = '$name'\n";
$ignorecount++;
if(!(exists $ignored_files{$name})) {
$ignored_files{$name} = $name;
@@ -330,18 +339,28 @@ while (<>) {
# Convert all quotes to '
$warning =~ s/‘/'/g;
$warning =~ s/’/'/g;
+ $warning =~ s/"/'/g;
#
# These skipped messages & "genericizations" may be specific to GCC
# Skip supplemental warning message
- next if $warning =~ /near initialization for/;
+ if($warning =~ /near initialization for/) {
+ $notecount++;
+ next
+ }
# Skip C++ supplemental warning message
- next if $warning =~ /in call to/;
+ if($warning =~ /in call to/) {
+ $notecount++;
+ next
+ }
# Skip GCC warning that should be a note
- next if $_ =~ /\(this will be reported only once per input file\)/;
+ if($_ =~ /\(this will be reported only once per input file\)/) {
+ $notecount++;
+ next
+ }
if($genericize) {
# Eliminate C/C++ "{aka <some type>}" and "{aka '<some type>'}" info
@@ -390,16 +409,16 @@ while (<>) {
$warning =~ s/[A-Za-z_0-9]*\([A-Za-z_,0-9]*\) in [A-Za-z_0-9]*/-\(-\) in -/g;
}
}
-# print "warning = $warning\n";
# <end possible GCC-specific code>
# 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} ) {
+ if( !exists $warn_file_line_offset{$warning}{$name}{$line}{$offset} ) {
# Increment count for [generic] warning
$warn_count{$warning}++;
$warn_file{$warning}{$name}++;
$warn_file_line{$warning}{$name}{$line}++;
+ $warn_file_line_offset{$warning}{$name}{$line}{$offset}++;
# Increment count for filename
$file_count{$name}++;
@@ -409,14 +428,20 @@ while (<>) {
# Increment total count of warnings
$totalcount++;
}
+ else {
+ # Increment count of duplicate warnings
+ $dupcount++;
+ }
-# print "name = $name\n";
-# print "line = $line\n";
-# print "offset = $offset\n";
-# print "warning = \"$warning\"\n";
+# print STDERR "name = $name\n";
+# print STDERR "line = $line\n";
+# print STDERR "offset = $offset\n";
+# print STDERR "warning = \"$warning\"\n";
}
print "Total unique [non-ignored] warnings: $totalcount\n";
+print "Ignored notes / supplemental warning lines [not counted in unique warnings]: $notecount\n";
+print "Duplicated warning lines [not counted in unique warnings]: $dupcount\n";
print "Total ignored warnings: $ignorecount\n";
$warncount = keys %warn_count;
print "Total unique kinds of warnings: $warncount\n";
@@ -427,7 +452,7 @@ print "Total files with warnings: $filecount\n\n";
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);
+ printf ("[%2d] %4d (%2d) - %s\n", $current_warning++, $warn_count{$x}, scalar(keys %{$warn_file{$x}}), $x);
if((exists $options{W}) || (exists $options{w}) || (exists $options{s})) {
my $curr_index = $current_warning - 1;
my $match = 0;
@@ -435,9 +460,9 @@ for my $x (sort {$warn_count{$b} <=> $warn_count{$a}} keys(%warn_count)) {
# Check for string from list in current warning
if(exists $options{s}) {
for my $y (@warn_match_strings) {
-# print "y = '$y'\n";
+# print STDERR "y = '$y'\n";
if($x =~ /$y/) {
-# print "matched warning = '$x'\n";
+# print STDERR "matched warning = '$x'\n";
$match = 1;
last;
}
@@ -465,7 +490,7 @@ for my $x (sort {$warn_count{$b} <=> $warn_count{$a}} keys(%warn_count)) {
print "\n# of Warnings by filename (warning type)\n";
print "========================================\n";
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);
+ printf ("[%3d] %4d (%2d) - %s\n", $current_file++, $file_count{$x}, scalar(keys %{$file_warn{$x}}), $x);
if((exists $options{F}) || (exists $options{f}) || (exists $options{S})) {
my $curr_index = $current_file - 1;
my $match = 0;
@@ -473,9 +498,9 @@ for my $x (sort {$file_count{$b} <=> $file_count{$a}} keys(%file_count)) {
# Check for string from list in current file
if(exists $options{S}) {
for my $y (@file_match_strings) {
-# print "y = '$y'\n";
+# print STDERR "y = '$y'\n";
if($x =~ /$y/) {
-# print "matched warning = '$x'\n";
+# print STDERR "matched warning = '$x'\n";
$match = 1;
last;
}