[kaffe] CVS kaffe (doogie): Start adding description support to the
various detected warnings.
Kaffe CVS
cvs-commits at kaffe.org
Thu Dec 9 22:24:43 PST 2004
PatchSet 5592
Date: 2004/12/10 06:20:16
Author: doogie
Branch: HEAD
Tag: (none)
Log:
Start adding description support to the various detected warnings.
Currently, only -Wmissing-braces has a description; this was copied from
the gcc info docs.
Members:
ChangeLog:1.3137->1.3138
scripts/LogWarning.pm:1.1->1.2
scripts/WarningDescription.pm:INITIAL->1.1
scripts/sort-warnings.pl:1.8->1.9
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3137 kaffe/ChangeLog:1.3138
--- kaffe/ChangeLog:1.3137 Fri Dec 10 05:36:23 2004
+++ kaffe/ChangeLog Fri Dec 10 06:20:16 2004
@@ -1,3 +1,15 @@
+2004-12-10 Adam Heath <doogie at brainfood.com>
+
+ * scripts/sort-warnings.pl, scripts/LogWarning.pl,
+ scripts/WarningDescription.pl:
+ Start adding description support to the various detected
+ warnings. Currently, only -Wmissing-braces has a description;
+ this was copied from the gcc info docs.
+
+2004-12-10 Adam Heath <doogie at brainfood.com>
+
+ * I'm 30 today!
+
2004-12-09 Adam Heath <doogie at brainfood.com>
* scripts/sort-warnings.pl:
Index: kaffe/scripts/LogWarning.pm
diff -u kaffe/scripts/LogWarning.pm:1.1 kaffe/scripts/LogWarning.pm:1.2
--- kaffe/scripts/LogWarning.pm:1.1 Fri Dec 10 05:07:03 2004
+++ kaffe/scripts/LogWarning.pm Fri Dec 10 06:20:18 2004
@@ -4,14 +4,19 @@
use strict;
use warnings;
+use WarningDescription;
+
sub new {
my $class = shift;
- return bless( {
+ my %data = (
'compiler' => $_[ 0 ],
'simple-name' => $_[ 1 ],
- 'regex' => $_[ 2 ],
- 'description' => $_[ 3 ]
- }, $class );
+ 'regex' => $_[ 2 ]
+ );
+
+ my $self = bless( \%data, $class );
+ $data{ 'description' } = ref( $_[ 3 ] ) ? $_[ 3 ] : new WarningDescription( $self, $_[ 3 ] );
+ return $self;
}
sub compiler {
@@ -25,8 +30,13 @@
sub name {
my $self = shift;
+ return $self->shortName() . $self->index();
+}
+
+sub shortName {
+ my $self = shift;
my $compiler = $self->compiler();
- return ( $compiler ? $compiler . "/" : "" ) . $self->{ 'simple-name' } . $self->index();
+ return ( $compiler ? $compiler . "/" : "" ) . $self->{ 'simple-name' };
}
sub index {
@@ -44,9 +54,9 @@
return $self->{ 'regex' };
}
-sub description {
+sub description_text {
my $self = shift;
- return $self->{ 'description' };
+ return $self->{ 'description' }->description();
}
1;
===================================================================
Checking out kaffe/scripts/WarningDescription.pm
RCS: /home/cvs/kaffe/kaffe/scripts/WarningDescription.pm,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/scripts/WarningDescription.pm Fri Dec 10 06:24:43 2004
@@ -0,0 +1,40 @@
+#!/usr/bin/perl -w
+package WarningDescription;
+
+use strict;
+use warnings;
+
+sub new {
+ my $class = shift;
+ my %data;
+ if ( ref( $_[ 0 ] ) ) {
+ $data{ 'parent' } = shift;
+ } else {
+ $data{ 'compiler' } = shift;
+ $data{ 'simple-name' } = shift;
+ }
+ $data{ 'description' } = shift;
+ return bless( \%data, $class );
+}
+
+sub compiler {
+ my $self = shift;
+ if ( $_[ 0 ] ) {
+ $self->{ 'compiler' } = $_[ 0 ];
+ } else {
+ return $self->{ 'parent' } ? $self->{ 'parent' }->compiler() : $self->{ 'compiler' };
+ }
+}
+
+sub name {
+ my $self = shift;
+ my $compiler = $self->compiler();
+ return ( $compiler ? $compiler . "/" : "" ) . $self->{ 'simple-name' };
+}
+
+sub description {
+ my $self = shift;
+ return $self->{ 'description' };
+}
+
+1;
Index: kaffe/scripts/sort-warnings.pl
diff -u kaffe/scripts/sort-warnings.pl:1.8 kaffe/scripts/sort-warnings.pl:1.9
--- kaffe/scripts/sort-warnings.pl:1.8 Fri Dec 10 05:36:29 2004
+++ kaffe/scripts/sort-warnings.pl Fri Dec 10 06:20:18 2004
@@ -49,6 +49,16 @@
awaiting\ finalization>$
),x;
+
+my @descriptions = (
+ new WarningDescription( 'gcc', '-Wmissing-braces', "Warn if an aggregate or union initializer is not fully bracketed.
+In the following example, the initializer for `a' is not fully
+bracketed, but that for `b' is fully bracketed.
+
+int a[2][2] = { 0, 1, 2, 3 };
+int b[2][2] = { { 0, 1 }, { 2, 3 } };" ),
+);
+
my @warning_types = (
new JikesWarning( 'throws-uncheck', qr/Since type "([^"]+)" is an unchecked exception, it does not need to be listed in the throws clause.$/m, '' ),
new JikesWarning( 'throws-unchecked', qr/Since type "([^"]+)" is an unchecked exception, it does not need to be listed in the throws clause.$/m ),
@@ -154,6 +164,21 @@
}
# </auto-number duplicate entries>
+# <create name warning map>
+my %warning_map;
+for ( my $i = 0; $i < @warning_types; $i++ ) {
+ $warning_map{ $warning_types[ $i ]->name() } = $warning_types[ $i ];
+}
+# </create name warning map>
+
+# <create description name map>
+my %description_map;
+for ( my $i = 0; $i < @descriptions; $i++ ) {
+ $description_map{ $descriptions[ $i ]->name() } = $descriptions[ $i ];
+}
+# </create description name map>
+print STDERR Dumper( \%description_map );
+
#print( STDERR join(',', keys( %warning_types ) )."\n" );
my $text;
my $removeNext = 0;
@@ -220,7 +245,15 @@
print( "\n" );
foreach my $type ( sort( { $error_counts{ $b } <=> $error_counts{ $a } } keys( %errors ) ) ) {
my $h1 = $errors{ $type };
- print( "Type: $type\nCount: $error_counts{ $type }\n" );
+ my $warning = $warning_map{ $type };
+ print( "Type: $type\n" );
+ my $description = $warning->description_text();
+ if ( !$description ) {
+ $description = $description_map{ $warning->shortName() };
+ $description = $description->description() if ( $description );
+ }
+ print( "Description:\n" . join( "", map( { "\t$_\n" } split( "\n", $description ) ) ) ) if ( $description );
+ print( "Count: $error_counts{ $type }\n" );
foreach my $file ( sort( keys( %$h1 ) ) ) {
my @text = ();
my $file_warning_count = 0;
More information about the kaffe
mailing list