+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>
* gcc-changelog/git_update_version.py:
# Author: Martin Liska <mliska@suse.cz>
import argparse
-import bs4
import os
import re
-import requests
import sys
+import bs4
+
+import requests
+
from unidiff import PatchSet
pr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<pr>PR [a-z+-]+\/[0-9]+)')
identifier_regex = re.compile(r'^([a-zA-Z0-9_#].*)')
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_]+)')
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*\([^*]')
m = struct_regex.search(line)
if m:
# Struct declaration
- return m.group(1)
+ return m.group(1) + ' ' + m.group(3)
m = macro_regex.search(line)
if m:
# Macro definition
output += '\n'
return output
+
def generate_changelog(data, no_functions=False, fill_pr_titles=False):
changelogs = {}
changelog_list = []
'''
+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):
def test_macro_definition(self):
changelog = generate_changelog(PATCH1)
def test_pr_bugzilla_download(self):
changelog = generate_changelog(PATCH5, fill_pr_titles=True)
assert changelog == EXPECTED5
+
+ def test_gty_in_struct(self):
+ changelog = generate_changelog(PATCH6, fill_pr_titles=True)
+ assert changelog == EXPECTED6