diff options
author | Martin Liska <mliska@suse.cz> | 2018-09-25 09:12:52 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2018-09-25 07:12:52 +0000 |
commit | a0464aa0c4a555aae0dbc0ecf586f768cf8cac6a (patch) | |
tree | 406b41c1084a6a4888d9cf136e40c57df655c537 /contrib | |
parent | 87677ac7fbe12cd180e4a3c0ab4c209e08df98e8 (diff) | |
download | gcc-a0464aa0c4a555aae0dbc0ecf586f768cf8cac6a.zip gcc-a0464aa0c4a555aae0dbc0ecf586f768cf8cac6a.tar.gz gcc-a0464aa0c4a555aae0dbc0ecf586f768cf8cac6a.tar.bz2 |
Add filter-rtags-warnings.py script.
2018-09-25 Martin Liska <mliska@suse.cz>
* filter-rtags-warnings.py: New file.
From-SVN: r264560
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/ChangeLog | 4 | ||||
-rwxr-xr-x | contrib/filter-rtags-warnings.py | 71 |
2 files changed, 75 insertions, 0 deletions
diff --git a/contrib/ChangeLog b/contrib/ChangeLog index 14b8ee2..97f70fe 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,5 +1,9 @@ 2018-09-25 Martin Liska <mliska@suse.cz> + * filter-rtags-warnings.py: New file. + +2018-09-25 Martin Liska <mliska@suse.cz> + PR middle-end/86078 * check-params-in-docs.py: New file. diff --git a/contrib/filter-rtags-warnings.py b/contrib/filter-rtags-warnings.py new file mode 100755 index 0000000..ee27e7c --- /dev/null +++ b/contrib/filter-rtags-warnings.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +# +# Script to analyze warnings produced by rtags command (using LLVM): +# rc --diagnose-all --synchronous-diagnostics --json +# +# 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 json +import argparse + +def skip_warning(filename, warning): + 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'], + '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'], + } + + message = warning['message'] + + if warning['type'] == 'fixit': + return True + + 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() +parser.add_argument('json_file', help = 'Rtags JSON file with diagnostics') +parser.add_argument('-n', '--no-filter', action = 'store_true', help = 'No filter') + +args = parser.parse_args() + +data = json.load(open(args.json_file)) +file_warnings = data['checkStyle'] + +total = 0 +for filename, warnings in file_warnings.items(): + if warnings: + for w in warnings: + if args.no_filter or not skip_warning(filename, w): + total += 1 + print('%s:%d:%d:%s' % (filename, w['line'], w['column'], w['message'])) + +print('Total: %d' % total) |