Commit 247b63e3 by Martin Liska Committed by Martin Liska

Transform filter-rtags-warnings to filter-clang-warnings.

2019-06-25  Martin Liska  <mliska@suse.cz>

	contrib/filter-clang-warnings.py: Transform from
	filter-rtags-warnings.py.

From-SVN: r272652
parent adef5d4f
2019-06-25 Martin Liska <mliska@suse.cz>
contrib/filter-clang-warnings.py: Transform from
filter-rtags-warnings.py.
2019-06-15 Tom Tromey <tom@tromey.com> 2019-06-15 Tom Tromey <tom@tromey.com>
* configure.ac (host_libs): Add gnulib. * configure.ac (host_libs): Add gnulib.
......
#!/usr/bin/env python3 #!/usr/bin/env python3
# #
# Script to analyze warnings produced by rtags command (using LLVM): # Script to analyze warnings produced by clang.
# rc --diagnose-all --synchronous-diagnostics --json
# #
# This file is part of GCC. # This file is part of GCC.
# #
...@@ -23,26 +22,26 @@ ...@@ -23,26 +22,26 @@
# #
import sys import sys
import json
import argparse import argparse
def skip_warning(filename, warning): def skip_warning(filename, message):
ignores = { ignores = {
'': ['-Warray-bounds', '-Wmismatched-tags', 'gcc_gfc: -Wignored-attributes', '-Wchar-subscripts', '': ['-Warray-bounds', '-Wmismatched-tags', 'gcc_gfc: -Wignored-attributes', '-Wchar-subscripts',
'string literal (potentially insecure): -Wformat-security', '-Wdeprecated-register', 'string literal (potentially insecure): -Wformat-security', '-Wdeprecated-register',
'-Wvarargs', 'keyword is hidden by macro definition', "but the argument has type 'char *': -Wformat-pedantic", '-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'], '-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'],
'insn-modes.c': ['-Wshift-count-overflow'], 'insn-modes.c': ['-Wshift-count-overflow'],
'insn-emit.c': ['-Wtautological-compare'], 'insn-emit.c': ['-Wtautological-compare'],
'insn-attrtab.c': ['-Wparentheses-equality'], 'insn-attrtab.c': ['-Wparentheses-equality'],
'gimple-match.c': ['-Wunused-', '-Wtautological-compare'], 'gimple-match.c': ['-Wunused-', '-Wtautological-compare'],
'generic-match.c': ['-Wunused-', '-Wtautological-compare'], 'generic-match.c': ['-Wunused-', '-Wtautological-compare'],
} 'i386.md': ['-Wparentheses-equality', '-Wtautological-compare'],
'sse.md': ['-Wparentheses-equality', '-Wtautological-compare'],
message = warning['message'] 'genautomata.c': ['-Wstring-plus-int']
if warning['type'] == 'fixit': }
return True
for name, ignores in ignores.items(): for name, ignores in ignores.items():
for i in ignores: for i in ignores:
...@@ -52,20 +51,22 @@ def skip_warning(filename, warning): ...@@ -52,20 +51,22 @@ def skip_warning(filename, warning):
return False return False
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('json_file', help = 'Rtags JSON file with diagnostics') parser.add_argument('log', help = 'Log file with clang warnings')
parser.add_argument('-n', '--no-filter', action = 'store_true', help = 'No filter')
args = parser.parse_args() args = parser.parse_args()
data = json.load(open(args.json_file)) lines = [l.strip() for l in open(args.log)]
file_warnings = data['checkStyle']
total = 0 total = 0
for filename, warnings in file_warnings.items(): messages = []
if warnings: for l in lines:
for w in warnings: token = ': warning: '
if args.no_filter or not skip_warning(filename, w): i = l.find(token)
if i != -1:
location = l[:i]
message = l[i + len(token):]
if not skip_warning(location, message):
total += 1 total += 1
print('%s:%d:%d:%s' % (filename, w['line'], w['column'], w['message'])) messages.append(l)
print('Total: %d' % total) for l in sorted(messages):
print(l)
print('\nTotal warnings: %d' % total)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment