3 # Copyright (C) 2018-2024 Free Software Foundation, Inc.
5 # Script to analyze warnings produced by clang.
7 # This file is part of GCC.
9 # GCC is free software; you can redistribute it and/or modify it under
10 # the terms of the GNU General Public License as published by the Free
11 # Software Foundation; either version 3, or (at your option) any later
14 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 # You should have received a copy of the GNU General Public License
20 # along with GCC; see the file COPYING3. If not see
21 # <http://www.gnu.org/licenses/>.
29 def skip_warning(filename
, message
):
31 '': ['-Warray-bounds', '-Wmismatched-tags',
32 'gcc_gfc: -Wignored-attributes', '-Wchar-subscripts',
33 'string literal (potentially insecure): -Wformat-security',
34 '-Wdeprecated-register',
35 '-Wvarargs', 'keyword is hidden by macro definition',
36 "but the argument has type 'char *': -Wformat-pedantic",
37 '-Wnested-anon-types',
38 'qualifier in explicit instantiation of',
39 'attribute argument not supported: asm_fprintf',
40 'when in C++ mode, this behavior is deprecated',
41 '-Wignored-attributes', '-Wgnu-zero-variadic-macro-arguments',
42 '-Wformat-security', '-Wundefined-internal',
43 '-Wunknown-warning-option', '-Wc++20-extensions',
44 '-Wbitwise-instead-of-logical', 'egrep is obsolescent'],
45 'insn-modes.cc': ['-Wshift-count-overflow'],
46 'insn-emit.cc': ['-Wtautological-compare'],
47 'insn-attrtab.cc': ['-Wparentheses-equality'],
48 'gimple-match.cc': ['-Wunused-', '-Wtautological-compare'],
49 'generic-match.cc': ['-Wunused-', '-Wtautological-compare'],
50 'i386.md': ['-Wparentheses-equality', '-Wtautological-compare',
51 '-Wtautological-overlap-compare'],
52 'sse.md': ['-Wparentheses-equality', '-Wtautological-compare',
53 '-Wconstant-logical-operand'],
54 'mmx.md': ['-Wtautological-compare'],
55 'genautomata.cc': ['-Wstring-plus-int'],
56 'fold-const-call.cc': ['-Wreturn-type'],
57 'gfortran.texi': [''],
59 'lex.cc': ['-Wc++20-attribute-extensions'],
62 for name
, ignore
in ignores
.items():
64 if name
in filename
and i
in message
:
69 parser
= argparse
.ArgumentParser()
70 parser
.add_argument('log', help='Log file with clang warnings')
71 args
= parser
.parse_args()
73 lines
= [line
.strip() for line
in open(args
.log
)]
80 message
= line
[i
+ len(token
):]
81 if '/libffi/' in location
or location
.startswith('Makefile'):
83 if not skip_warning(location
, message
):
86 for line
in sorted(messages
):
89 print('\nTotal warnings: %d' % len(messages
))