]> git.ipfire.org Git - thirdparty/gcc.git/blame - contrib/filter-clang-warnings.py
i386: Cleanup ix86_expand_{unary|binary}_operator issues
[thirdparty/gcc.git] / contrib / filter-clang-warnings.py
CommitLineData
a0464aa0 1#!/usr/bin/env python3
81f86cb9 2
83ffe9cd 3# Copyright (C) 2018-2023 Free Software Foundation, Inc.
a0464aa0 4#
247b63e3 5# Script to analyze warnings produced by clang.
a0464aa0
ML
6#
7# This file is part of GCC.
8#
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
12# version.
13#
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
17# for more details.
18#
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/>. */
22#
23#
24#
25
a0464aa0
ML
26import argparse
27
19c1ef85 28
247b63e3 29def skip_warning(filename, message):
a0464aa0 30 ignores = {
19c1ef85
ML
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',
46cd445f 43 '-Wunknown-warning-option', '-Wc++20-extensions',
63e3cc29 44 '-Wbitwise-instead-of-logical', 'egrep is obsolescent'],
e53b6e56
ML
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'],
5b17c3c6
ML
50 'i386.md': ['-Wparentheses-equality', '-Wtautological-compare',
51 '-Wtautological-overlap-compare'],
603a9ab4
ML
52 'sse.md': ['-Wparentheses-equality', '-Wtautological-compare',
53 '-Wconstant-logical-operand'],
d7705b0a 54 'mmx.md': ['-Wtautological-compare'],
e53b6e56
ML
55 'genautomata.cc': ['-Wstring-plus-int'],
56 'fold-const-call.cc': ['-Wreturn-type'],
5b17c3c6 57 'gfortran.texi': [''],
68fd1c9f
ML
58 'libtool': [''],
59 'lex.cc': ['-Wc++20-attribute-extensions'],
247b63e3 60 }
a0464aa0 61
63e3cc29
ML
62 for name, ignore in ignores.items():
63 for i in ignore:
a0464aa0
ML
64 if name in filename and i in message:
65 return True
a0464aa0
ML
66 return False
67
19c1ef85 68
a0464aa0 69parser = argparse.ArgumentParser()
19c1ef85 70parser.add_argument('log', help='Log file with clang warnings')
a0464aa0
ML
71args = parser.parse_args()
72
19c1ef85 73lines = [line.strip() for line in open(args.log)]
d386d399 74messages = set()
19c1ef85 75for line in lines:
247b63e3 76 token = ': warning: '
19c1ef85 77 i = line.find(token)
247b63e3 78 if i != -1:
19c1ef85
ML
79 location = line[:i]
80 message = line[i + len(token):]
0d1b5446
ML
81 if '/libffi/' in location or location.startswith('Makefile'):
82 continue
247b63e3 83 if not skip_warning(location, message):
d386d399 84 messages.add(line)
a0464aa0 85
19c1ef85
ML
86for line in sorted(messages):
87 print(line)
af49fd41
ML
88
89print('\nTotal warnings: %d' % len(messages))