From 19c1ef85c3f9be7c78682135ed1f59cd093b4684 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 8 Dec 2020 11:07:25 +0100 Subject: [PATCH] contrib: modernize filter-clang-warnings.py contrib/ChangeLog: * filter-clang-warnings.py: Modernize and filter 2 more patterns. --- contrib/filter-clang-warnings.py | 41 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/contrib/filter-clang-warnings.py b/contrib/filter-clang-warnings.py index 15cca5ff2df..2b7b42fd099 100755 --- a/contrib/filter-clang-warnings.py +++ b/contrib/filter-clang-warnings.py @@ -21,17 +21,24 @@ # # -import sys import argparse + def skip_warning(filename, message): 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", - '-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'], + '': ['-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", + '-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', '-Wundefined-internal', + '-Wunknown-warning-option'], 'insn-modes.c': ['-Wshift-count-overflow'], 'insn-emit.c': ['-Wtautological-compare'], 'insn-attrtab.c': ['-Wparentheses-equality'], @@ -47,26 +54,26 @@ def skip_warning(filename, message): for i in ignores: if name in filename and i in message: return True - return False + parser = argparse.ArgumentParser() -parser.add_argument('log', help = 'Log file with clang warnings') +parser.add_argument('log', help='Log file with clang warnings') args = parser.parse_args() -lines = [l.strip() for l in open(args.log)] +lines = [line.strip() for line in open(args.log)] total = 0 messages = [] -for l in lines: +for line in lines: token = ': warning: ' - i = l.find(token) + i = line.find(token) if i != -1: - location = l[:i] - message = l[i + len(token):] + location = line[:i] + message = line[i + len(token):] if not skip_warning(location, message): total += 1 - messages.append(l) + messages.append(line) -for l in sorted(messages): - print(l) +for line in sorted(messages): + print(line) print('\nTotal warnings: %d' % total) -- 2.30.2