public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH 2/2] filter_params.py: GTY fix and other cleanups
Date: Fri, 17 Mar 2017 01:21:00 -0000	[thread overview]
Message-ID: <1489715500-63153-2-git-send-email-dmalcolm@redhat.com> (raw)
In-Reply-To: <1489715500-63153-1-git-send-email-dmalcolm@redhat.com>

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(
-- 
1.8.5.3

  reply	other threads:[~2017-03-17  1:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-31 22:11 [PATCH] Support multiline GTY markers in Doxygen filter; add unittests David Malcolm
2013-11-01 15:16 ` Diego Novillo
2017-03-17  1:21   ` [PATCH 1/2] Port Doxygen support script from Perl to Python; " David Malcolm
2017-03-17  1:21     ` David Malcolm [this message]
2017-04-28 12:25     ` Martin Liška
2017-05-03  9:49       ` [PATCH] Doxygen: add default location for filters and output folder Martin Liška
2017-05-31 12:43       ` [PATCH 1/2] Port Doxygen support script from Perl to Python; add unittests Martin Liška
2017-04-28 12:30     ` [PATCH 1/2] Change comment style to one we normally use Martin Liška
2017-04-28 12:41     ` [PATCH 2/2] Doxygen: transform ENUM_BITFIELD and comments starting with '/**' Martin Liška
2017-04-29  2:57     ` [PING] Re: [PATCH 1/2] Port Doxygen support script from Perl to Python; add unittests David Malcolm
2017-05-19  9:14       ` Martin Liška
2017-05-26 19:35       ` [PING^2] " David Malcolm
2017-05-31 14:07         ` [PATCH] " Martin Liška
2017-05-31 14:10           ` Martin Liška
2017-05-31 14:13             ` Martin Liška
2017-06-22 12:45               ` Martin Liška
2017-06-28  4:41               ` Jeff Law

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=1489715500-63153-2-git-send-email-dmalcolm@redhat.com \
    --to=dmalcolm@redhat.com \
    --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).