#!/usr/bin/env perl
# warning-summary.pl

use strict;
use warnings;

use encoding 'utf8';

binmode(STDIN, ":utf8");

open(OUT, "| sort | uniq -c | sort -nr");
binmode(OUT, ":utf8");

while (<>)
{
	/warning:/ || next;
	/near initialization for/ && next;
	/shadowed declaration is here/ && next;
	/\(this will be reported only once per input file\)/ && next;

	s/^.*: warning: //g;

	tr/\x{2018}\x{2019}/''/;

	s/\barg(ument|) \d+\b/arg$1 N/g;

	s/\b(type|function|variable|enumeration value|declaration of|argument N of|parameter|type of|type of bit-field|prototype for) '[^']+'/$1 'blah'/g;

	s/"[^"]+" (is not defined)/"BLAH" $1/g;

	s/'[^']+' (defined but not used)/'blah' $1/g;

	s/format '%\w+'/format '%blah'/g;

	s/'%\w+' printf format/'%blah' printf format/g;

	s/'\d+'/'NNN'/g;

	s/'[^']+' (declared 'static' but never defined)/'blah' $1/g;

	s/(missing braces around initializer for) '\w+'/$1 'blah'/g;

	s/(missing initializer for member) '\w+::\w+'/$1 'Foo::bar'/g;

	print OUT;
}

close(OUT);

# end warning-summary.pl
