3 # Script to analyze warnings produced by clang.
5 # This file is part of GCC.
7 # GCC is free software; you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free
9 # Software Foundation; either version 3, or (at your option) any later
12 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 # You should have received a copy of the GNU General Public License
18 # along with GCC; see the file COPYING3. If not see
19 # <http://www.gnu.org/licenses/>. */
27 def skip_warning(filename
, message
):
29 '': ['-Warray-bounds', '-Wmismatched-tags', 'gcc_gfc: -Wignored-attributes', '-Wchar-subscripts',
30 'string literal (potentially insecure): -Wformat-security', '-Wdeprecated-register',
31 '-Wvarargs', 'keyword is hidden by macro definition', "but the argument has type 'char *': -Wformat-pedantic",
32 '-Wnested-anon-types', 'qualifier in explicit instantiation of', 'attribute argument not supported: asm_fprintf',
33 'when in C++ mode, this behavior is deprecated', '-Wignored-attributes', '-Wgnu-zero-variadic-macro-arguments',
35 'insn-modes.c': ['-Wshift-count-overflow'],
36 'insn-emit.c': ['-Wtautological-compare'],
37 'insn-attrtab.c': ['-Wparentheses-equality'],
38 'gimple-match.c': ['-Wunused-', '-Wtautological-compare'],
39 'generic-match.c': ['-Wunused-', '-Wtautological-compare'],
40 'i386.md': ['-Wparentheses-equality', '-Wtautological-compare'],
41 'sse.md': ['-Wparentheses-equality', '-Wtautological-compare'],
42 'genautomata.c': ['-Wstring-plus-int']
46 for name
, ignores
in ignores
.items():
48 if name
in filename
and i
in message
:
53 parser
= argparse
.ArgumentParser()
54 parser
.add_argument('log', help = 'Log file with clang warnings')
55 args
= parser
.parse_args()
57 lines
= [l
.strip() for l
in open(args
.log
)]
65 message
= l
[i
+ len(token
):]
66 if not skip_warning(location
, message
):
70 for l
in sorted(messages
):
72 print('\nTotal warnings: %d' % total
)