2018-09-25 09:12:52 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
2019-06-25 14:30:19 +02:00
|
|
|
# Script to analyze warnings produced by clang.
|
2018-09-25 09:12:52 +02:00
|
|
|
#
|
|
|
|
# This file is part of GCC.
|
|
|
|
#
|
|
|
|
# GCC is free software; you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU General Public License as published by the Free
|
|
|
|
# Software Foundation; either version 3, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
#
|
|
|
|
# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
# for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with GCC; see the file COPYING3. If not see
|
|
|
|
# <http://www.gnu.org/licenses/>. */
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import argparse
|
|
|
|
|
2019-06-25 14:30:19 +02:00
|
|
|
def skip_warning(filename, message):
|
2018-09-25 09:12:52 +02:00
|
|
|
ignores = {
|
|
|
|
'': ['-Warray-bounds', '-Wmismatched-tags', 'gcc_gfc: -Wignored-attributes', '-Wchar-subscripts',
|
|
|
|
'string literal (potentially insecure): -Wformat-security', '-Wdeprecated-register',
|
|
|
|
'-Wvarargs', 'keyword is hidden by macro definition', "but the argument has type 'char *': -Wformat-pedantic",
|
2019-06-25 14:30:19 +02:00
|
|
|
'-Wnested-anon-types', 'qualifier in explicit instantiation of', 'attribute argument not supported: asm_fprintf',
|
|
|
|
'when in C++ mode, this behavior is deprecated', '-Wignored-attributes', '-Wgnu-zero-variadic-macro-arguments',
|
|
|
|
'-Wformat-security'],
|
2018-09-25 09:12:52 +02:00
|
|
|
'insn-modes.c': ['-Wshift-count-overflow'],
|
|
|
|
'insn-emit.c': ['-Wtautological-compare'],
|
|
|
|
'insn-attrtab.c': ['-Wparentheses-equality'],
|
|
|
|
'gimple-match.c': ['-Wunused-', '-Wtautological-compare'],
|
|
|
|
'generic-match.c': ['-Wunused-', '-Wtautological-compare'],
|
2019-06-25 14:30:19 +02:00
|
|
|
'i386.md': ['-Wparentheses-equality', '-Wtautological-compare'],
|
|
|
|
'sse.md': ['-Wparentheses-equality', '-Wtautological-compare'],
|
|
|
|
'genautomata.c': ['-Wstring-plus-int']
|
2018-09-25 09:12:52 +02:00
|
|
|
|
2019-06-25 14:30:19 +02:00
|
|
|
}
|
2018-09-25 09:12:52 +02:00
|
|
|
|
|
|
|
for name, ignores in ignores.items():
|
|
|
|
for i in ignores:
|
|
|
|
if name in filename and i in message:
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
2019-06-25 14:30:19 +02:00
|
|
|
parser.add_argument('log', help = 'Log file with clang warnings')
|
2018-09-25 09:12:52 +02:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2019-06-25 14:30:19 +02:00
|
|
|
lines = [l.strip() for l in open(args.log)]
|
2018-09-25 09:12:52 +02:00
|
|
|
total = 0
|
2019-06-25 14:30:19 +02:00
|
|
|
messages = []
|
|
|
|
for l in lines:
|
|
|
|
token = ': warning: '
|
|
|
|
i = l.find(token)
|
|
|
|
if i != -1:
|
|
|
|
location = l[:i]
|
|
|
|
message = l[i + len(token):]
|
|
|
|
if not skip_warning(location, message):
|
|
|
|
total += 1
|
|
|
|
messages.append(l)
|
2018-09-25 09:12:52 +02:00
|
|
|
|
2019-06-25 14:30:19 +02:00
|
|
|
for l in sorted(messages):
|
|
|
|
print(l)
|
|
|
|
print('\nTotal warnings: %d' % total)
|