check_balanced: update to use stree
[smatch.git] / smatch_scripts / generisize.pl
blob28804db35bf227a0bbe528d0b050812e5bf43858
1 #!/usr/bin/perl
3 use strict;
5 sub help()
7 print "usage: $0 [-r]\n";
8 print "Counts the number of errors of each type.\n";
9 print "-r means down to the nearest 10.\n";
10 exit 1;
13 my $round;
14 my $arg = shift;
15 if ($arg =~ /-h/) {
16 help();
17 } elsif ($arg =~ /-r/) {
18 $round = 1;
21 my %msgs;
23 sub add_msg($)
25 my $msg = shift;
27 if (defined $msgs{$msg}) {
28 $msgs{$msg}++;
29 } else {
30 $msgs{$msg} = 1;
34 while (<>) {
35 s/^.*?:\d+(|:\d+:) .*? //;
36 s/[us](16|32|64)(min|max)//g;
37 s/[01234567890]//g;
38 if ($_ =~ /can't/) {
39 s/(.*can't.*').*?('.*)/$1 $2/;
40 } elsif ($_ =~ /don't/) {
41 s/(.*don't.*').*?('.*)/$1 $2/;
42 } else {
43 s/'.*?'/''/g;
45 s/,//g;
46 s/\(\w+ returns null\)/(... returns null)/;
47 s/dma on the stack \(.*?\)/dma on the stack (...)/;
48 s/possible ERR_PTR '' to .*/possible ERR_PTR '' to .../;
49 s/inconsistent returns ([^ ]+?) locked \(\)/inconsistent returns ... locked ()/;
50 s/(.*) [^ ]* (too large for) [^ ]+ (.*)/$1 $2 $3/;
52 add_msg($_);
55 foreach my $key (sort { $msgs{$b} <=> $msgs{$a} } keys %msgs) {
56 my $count = $msgs{$key};
58 if ($round) {
59 $count = $msgs{$key} - $msgs{$key} % 10;
61 print "$count $key";