From patchwork Fri Mar 17 01:51:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 740084 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vknd645lHz9ryZ for ; Fri, 17 Mar 2017 12:22:18 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="L1ZZ5U+f"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=eKloF/x880PAFYRU+XUpJZYVMgWLVe0BOdZanHxo+k74NXWSbad09 lf6bBF4vnumsrEh80yoiIF2vjuR4CAQXLedvf1PPT9/u3/+OTJ/LBzLCXcDg37+v hbGiGMyocfdY8upwD1iV7QTh4CmT4Rxwvq+40aykxobaIiwf1ZKlwo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=PJvIlsWJk4KDiOXNI4SOksBlLW8=; b=L1ZZ5U+fjjZFn6PbCBJM ZK4OzMahirWa38kJZN5OBhAKpxPX7CkjMf1XV8ka/m4BZS7vub0RcD+g8evVqCRW 40Ch/3pPkyeJ6563C1i8CidnqCiHPztFqH46A+m+hoAE9qVQyCjrByq+hlS9x1Ne DbaOo2OmmiG4/tMJx4QTxTw= Received: (qmail 82146 invoked by alias); 17 Mar 2017 01:21:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 81362 invoked by uid 89); 17 Mar 2017 01:21:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No 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, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=multiline, 4219 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Mar 2017 01:21:45 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC55775EAA for ; Fri, 17 Mar 2017 01:21:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DC55775EAA Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dmalcolm@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DC55775EAA Received: from c64.redhat.com (vpn-236-15.phx2.redhat.com [10.3.236.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80E135C541; Fri, 17 Mar 2017 01:21:45 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 2/2] filter_params.py: GTY fix and other cleanups Date: Thu, 16 Mar 2017 21:51:40 -0400 Message-Id: <1489715500-63153-2-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1489715500-63153-1-git-send-email-dmalcolm@redhat.com> References: <1489715500-63153-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes This patch updates the removal of GTY tags in the Doxygen support script so that it can cope with multiline tags, such as that for class symtab_node. It also makes some tweaks to regexes to make them more idiomatic for Python (and stripping some whitespace). Tested via unit test suite, and by running Doxygen on the gcc source tree and verifying that it handles class symtab_node (and its subclasses). OK for trunk? contrib/ChangeLog: * filter_params.py (OPT_WS): New. (filter_src): Use OPT_WS in two places. Remove trailing whitespace after GTY tag. Make GTY tag handle multiline arguments. Use \s for ATTRIBUTE_UNUSED. (FilteringTests.test_GTY): Update expected result. (FilteringTests.test_multiline_GTY): New test case. --- contrib/filter_params.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/contrib/filter_params.py b/contrib/filter_params.py index 3c14121..f94d201 100644 --- a/contrib/filter_params.py +++ b/contrib/filter_params.py @@ -13,6 +13,9 @@ import re import sys import unittest +# Optional whitespace +OPT_WS = '\s*' + def filter_src(text): """ str -> str. We operate on the whole of the source file at once @@ -39,18 +42,19 @@ def filter_src(text): r' @endverbatim */', text) - # Remove GTY markings: - text = re.sub(r'GTY[ \t]*\(\(.*\)\)', + # Remove GTY markings (potentially multiline ones): + text = re.sub('GTY' + OPT_WS + r'\(\(.*?\)\)\s+', '', - text) + text, + flags=(re.MULTILINE|re.DOTALL)) # Strip out 'ATTRIBUTE_UNUSED' - text = re.sub('[ \t]ATTRIBUTE_UNUSED', + text = re.sub('\sATTRIBUTE_UNUSED', '', text) # PARAMS(()) is used for K&R compatibility. See ansidecl.h. - text = re.sub(r'PARAMS[ \t]*\(\((.*?)\)\)', + text = re.sub('PARAMS' + OPT_WS + r'\(\((.*?)\)\)', r'(\1)', text) @@ -97,11 +101,21 @@ class FilteringTests(unittest.TestCase): ' tree decl;\n' ' tree target;\n' '} alias_pair;\n'), - ('typedef struct alias_pair {\n' + ('typedef struct alias_pair {\n' ' tree decl;\n' ' tree target;\n' '} alias_pair;\n')) + def test_multiline_GTY(self): + # Ensure that a multiline GTY is filtered out. + self.assert_filters_to( + ('class GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"),\n' + '\t chain_next ("%h.next"), chain_prev ("%h.previous")))\n' + ' symtab_node_base\n' + '{\n'), + ('class symtab_node_base\n' + '{\n')) + def test_ATTRIBUTE_UNUSED(self): # Ensure that ATTRIBUTE_UNUSED is filtered out. self.assert_filters_to(