mklog.py: improve parsing of struct names (ignore GTY).

* mklog.py: Skip GTY for struct names.  Make flake8 happy.
	* test_mklog.py: Add test for GTY.
This commit is contained in:
Martin Liska 2020-05-19 12:33:46 +02:00
parent 53cc8cf9f0
commit 4f85a52c94
No known key found for this signature in database
GPG Key ID: 4DC182DC0FA73785
3 changed files with 42 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2020-05-19 Martin Liska <mliska@suse.cz>
* mklog.py: Skip GTY for struct names. Make flake8 happy.
* test_mklog.py: Add test for GTY.
2020-05-19 Martin Liska <mliska@suse.cz> 2020-05-19 Martin Liska <mliska@suse.cz>
* gcc-changelog/git_update_version.py: * gcc-changelog/git_update_version.py:

View File

@ -27,18 +27,21 @@
# Author: Martin Liska <mliska@suse.cz> # Author: Martin Liska <mliska@suse.cz>
import argparse import argparse
import bs4
import os import os
import re import re
import requests
import sys import sys
import bs4
import requests
from unidiff import PatchSet from unidiff import PatchSet
pr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<pr>PR [a-z+-]+\/[0-9]+)') pr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<pr>PR [a-z+-]+\/[0-9]+)')
identifier_regex = re.compile(r'^([a-zA-Z0-9_#].*)') identifier_regex = re.compile(r'^([a-zA-Z0-9_#].*)')
comment_regex = re.compile(r'^\/\*') comment_regex = re.compile(r'^\/\*')
struct_regex = re.compile(r'^((class|struct|union|enum)\s+[a-zA-Z0-9_]+)') struct_regex = re.compile(r'^(class|struct|union|enum)\s+'
r'(GTY\(.*\)\s+)?([a-zA-Z0-9_]+)')
macro_regex = re.compile(r'#\s*(define|undef)\s+([a-zA-Z0-9_]+)') macro_regex = re.compile(r'#\s*(define|undef)\s+([a-zA-Z0-9_]+)')
super_macro_regex = re.compile(r'^DEF[A-Z0-9_]+\s*\(([a-zA-Z0-9_]+)') super_macro_regex = re.compile(r'^DEF[A-Z0-9_]+\s*\(([a-zA-Z0-9_]+)')
fn_regex = re.compile(r'([a-zA-Z_][^()\s]*)\s*\([^*]') fn_regex = re.compile(r'([a-zA-Z_][^()\s]*)\s*\([^*]')
@ -73,7 +76,7 @@ def extract_function_name(line):
m = struct_regex.search(line) m = struct_regex.search(line)
if m: if m:
# Struct declaration # Struct declaration
return m.group(1) return m.group(1) + ' ' + m.group(3)
m = macro_regex.search(line) m = macro_regex.search(line)
if m: if m:
# Macro definition # Macro definition
@ -117,6 +120,7 @@ def get_pr_titles(prs):
output += '\n' output += '\n'
return output return output
def generate_changelog(data, no_functions=False, fill_pr_titles=False): def generate_changelog(data, no_functions=False, fill_pr_titles=False):
changelogs = {} changelogs = {}
changelog_list = [] changelog_list = []

View File

@ -319,6 +319,31 @@ gcc/testsuite/ChangeLog:
''' '''
PATCH6 = '''\
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 5ddeb65269b..cfae6e91da9 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -937,7 +937,8 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node
split_part (false), indirect_call_target (false), local (false),
versionable (false), can_change_signature (false),
redefined_extern_inline (false), tm_may_enter_irr (false),
- ipcp_clone (false), m_uid (uid), m_summary_id (-1)
+ ipcp_clone (false), declare_variant_alt (false),
+ calls_declare_variant_alt (false), m_uid (uid), m_summary_id (-1)
{}
/* Remove the node from cgraph and all inline clones inlined into it.
'''
EXPECTED6 = '''\
gcc/ChangeLog:
* cgraph.h (struct cgraph_node):
'''
class TestMklog(unittest.TestCase): class TestMklog(unittest.TestCase):
def test_macro_definition(self): def test_macro_definition(self):
changelog = generate_changelog(PATCH1) changelog = generate_changelog(PATCH1)
@ -343,3 +368,7 @@ class TestMklog(unittest.TestCase):
def test_pr_bugzilla_download(self): def test_pr_bugzilla_download(self):
changelog = generate_changelog(PATCH5, fill_pr_titles=True) changelog = generate_changelog(PATCH5, fill_pr_titles=True)
assert changelog == EXPECTED5 assert changelog == EXPECTED5
def test_gty_in_struct(self):
changelog = generate_changelog(PATCH6, fill_pr_titles=True)
assert changelog == EXPECTED6