]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
contrib: modernize filter-clang-warnings.py
authorMartin Liska <mliska@suse.cz>
Tue, 8 Dec 2020 10:07:25 +0000 (11:07 +0100)
committerMartin Liska <mliska@suse.cz>
Tue, 8 Dec 2020 10:07:25 +0000 (11:07 +0100)
contrib/ChangeLog:

* filter-clang-warnings.py: Modernize and filter 2 more
patterns.

contrib/filter-clang-warnings.py

index 15cca5ff2df886d8ea2777df844e7359821f0d7e..2b7b42fd099ea041c3e85becde79629d466396e2 100755 (executable)
 #
 #
 
-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)