From: marxin <mliska@suse.cz>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH 1/4] Add filter-rtags-warnings.py script.
Date: Mon, 24 Sep 2018 07:37:00 -0000 [thread overview]
Message-ID: <f560db8b257c31dc90a59cb9d1d9d3b2cf53c74d.1537774329.git.mliska@suse.cz> (raw)
In-Reply-To: <cover.1537774329.git.mliska@suse.cz>
[-- Attachment #1: Type: text/plain, Size: 268 bytes --]
contrib/ChangeLog:
2018-09-24 Martin Liska <mliska@suse.cz>
* filter-rtags-warnings.py: New file.
---
contrib/filter-rtags-warnings.py | 71 ++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
create mode 100755 contrib/filter-rtags-warnings.py
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-filter-rtags-warnings.py-script.patch --]
[-- Type: text/x-patch; name="0001-Add-filter-rtags-warnings.py-script.patch", Size: 2825 bytes --]
diff --git a/contrib/filter-rtags-warnings.py b/contrib/filter-rtags-warnings.py
new file mode 100755
index 00000000000..ee27e7c8942
--- /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)
next prev parent reply other threads:[~2018-09-24 7:37 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-24 7:37 [PATCH 0/4] Clean-up warnings spotted by Rtags marxin
2018-09-24 7:37 ` [PATCH 3/4] Fix small coding style issues (PR fortran/87394) marxin
2018-09-24 14:39 ` Jeff Law
2018-09-24 7:37 ` [PATCH 4/4] Fix scaling of a sreal number marxin
2018-09-24 14:42 ` Jeff Law
2018-09-24 7:37 ` marxin [this message]
2018-09-24 14:45 ` [PATCH 1/4] Add filter-rtags-warnings.py script Jeff Law
2018-09-24 7:39 ` [PATCH 2/4] Remove unused functions and fields marxin
2018-09-24 14:42 ` Jeff Law
2018-09-25 7:18 ` Martin Liška
2018-09-25 12:31 ` Richard Biener
2018-09-25 13:40 ` Jeff Law
2018-09-26 9:01 ` Martin Liška
2018-09-27 11:18 ` Bernhard Reutner-Fischer
2018-10-03 16:46 ` Jeff Law
2018-10-03 19:35 ` Bernhard Reutner-Fischer
2018-10-05 2:19 ` Bernhard Reutner-Fischer
2018-10-05 13:41 ` Martin Liška
2018-10-09 8:52 ` [PATCH] Remove dead functions and fix VMS target by moving back some functions Martin Liška
2018-10-09 22:53 ` Martin Jambor
2018-10-10 11:13 ` Martin Liška
2018-10-10 11:17 ` Martin Jambor
2018-10-18 23:55 ` [PATCH 2/4] Remove unused functions and fields Ian Lance Taylor
2018-10-22 13:05 ` Martin Liška
2018-10-22 17:50 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f560db8b257c31dc90a59cb9d1d9d3b2cf53c74d.1537774329.git.mliska@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).