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',
30 'gcc_gfc: -Wignored-attributes', '-Wchar-subscripts',
31 'string literal (potentially insecure): -Wformat-security',
32 '-Wdeprecated-register',
33 '-Wvarargs', 'keyword is hidden by macro definition',
34 "but the argument has type 'char *': -Wformat-pedantic",
35 '-Wnested-anon-types',
36 'qualifier in explicit instantiation of',
37 'attribute argument not supported: asm_fprintf',
38 'when in C++ mode, this behavior is deprecated',
39 '-Wignored-attributes', '-Wgnu-zero-variadic-macro-arguments',
40 '-Wformat-security', '-Wundefined-internal',
41 '-Wunknown-warning-option', '-Wc++20-extensions',
42 '-Wbitwise-instead-of-logical'],
43 'insn-modes.cc': ['-Wshift-count-overflow'],
44 'insn-emit.cc': ['-Wtautological-compare'],
45 'insn-attrtab.cc': ['-Wparentheses-equality'],
46 'gimple-match.cc': ['-Wunused-', '-Wtautological-compare'],
47 'generic-match.cc': ['-Wunused-', '-Wtautological-compare'],
48 'i386.md': ['-Wparentheses-equality', '-Wtautological-compare',
49 '-Wtautological-overlap-compare'],
50 'sse.md': ['-Wparentheses-equality', '-Wtautological-compare',
51 '-Wconstant-logical-operand'],
52 'mmx.md': ['-Wtautological-compare'],
53 'genautomata.cc': ['-Wstring-plus-int'],
54 'fold-const-call.cc': ['-Wreturn-type'],
55 'gfortran.texi': [''],
57 'lex.cc': ['-Wc++20-attribute-extensions'],
60 for name
, ignores
in ignores
.items():
62 if name
in filename
and i
in message
:
67 parser
= argparse
.ArgumentParser()
68 parser
.add_argument('log', help='Log file with clang warnings')
69 args
= parser
.parse_args()
71 lines
= [line
.strip() for line
in open(args
.log
)]
79 message
= line
[i
+ len(token
):]
80 if not skip_warning(location
, message
):
84 for line
in sorted(messages
):
86 print('\nTotal warnings: %d' % total
)