From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25715 invoked by alias); 24 Sep 2018 07:37:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 25364 invoked by uid 89); 24 Sep 2018 07:36:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,SPF_PASS autolearn=ham version=3.3.2 spammy=insecure X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Sep 2018 07:36:56 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6E4A6B0DB for ; Mon, 24 Sep 2018 07:36:54 +0000 (UTC) Resent-From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Resent-To: GCC Patches Resent-Date: Mon, 24 Sep 2018 09:36:53 +0200 Resent-Message-ID: Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 Message-Id: In-Reply-To: References: From: marxin Date: Mon, 24 Sep 2018 07:37:00 -0000 Subject: [PATCH 1/4] Add filter-rtags-warnings.py script. To: gcc-patches@gcc.gnu.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.19.0" X-IsSubscribed: yes X-SW-Source: 2018-09/txt/msg01315.txt.bz2 This is a multi-part message in MIME format. --------------2.19.0 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit Content-length: 268 contrib/ChangeLog: 2018-09-24 Martin Liska * 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 --------------2.19.0 Content-Type: text/x-patch; name="0001-Add-filter-rtags-warnings.py-script.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-Add-filter-rtags-warnings.py-script.patch" Content-length: 2825 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 +# . */ +# +# +# + +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) --------------2.19.0--