diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-02-02 12:42:10 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-02-02 12:42:10 -0800 |
commit | 8910f1cd79445bbe2da01f8ccf7c37909349529e (patch) | |
tree | ba67a346969358fd7cc2b7c12384479de8364cab /contrib | |
parent | 45c32be1f96ace25b66c34a84818dc5e07e9d516 (diff) | |
parent | 8e4a738d2540ab6aff77506d368bf4e3fa6963bd (diff) | |
download | gcc-8910f1cd79445bbe2da01f8ccf7c37909349529e.zip gcc-8910f1cd79445bbe2da01f8ccf7c37909349529e.tar.gz gcc-8910f1cd79445bbe2da01f8ccf7c37909349529e.tar.bz2 |
Merge from trunk revision 8e4a738d2540ab6aff77506d368bf4e3fa6963bd.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/ChangeLog | 97 | ||||
-rwxr-xr-x | contrib/compare-lto | 21 | ||||
-rwxr-xr-x | contrib/filter-clang-warnings.py | 49 | ||||
-rwxr-xr-x | contrib/gcc-changelog/git_commit.py | 68 | ||||
-rwxr-xr-x | contrib/gcc-changelog/git_email.py | 6 | ||||
-rwxr-xr-x | contrib/gcc-changelog/git_repository.py | 6 | ||||
-rwxr-xr-x | contrib/gcc-changelog/test_email.py | 21 | ||||
-rw-r--r-- | contrib/gcc-changelog/test_patches.txt | 137 | ||||
-rwxr-xr-x | contrib/gcc_update | 4 | ||||
-rwxr-xr-x | contrib/mklog.py | 82 | ||||
-rwxr-xr-x | contrib/test_mklog.py | 42 | ||||
-rwxr-xr-x | contrib/update-copyright.py | 29 |
12 files changed, 503 insertions, 59 deletions
diff --git a/contrib/ChangeLog b/contrib/ChangeLog index a280c05..1efbbee 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,100 @@ +2021-01-28 Eric Botcazou <ebotcazou@adacore.com> + + PR lto/85574 + * compare-lto: Deal with PE-COFF executables specifically. + +2021-01-14 Martin Liska <mliska@suse.cz> + + * mklog.py: Fix infinite loop for unsupported files. + +2021-01-13 Martin Liska <mliska@suse.cz> + + * gcc-changelog/git_commit.py: Support wrapping of functions + in parentheses that can take multiple lines. + * gcc-changelog/test_email.py: Add tests for it. + * gcc-changelog/test_patches.txt: Add 2 patches. + +2021-01-13 Martin Liska <mliska@suse.cz> + + * mklog.py: Parse also define_insn_and_split and similar + directives in .md files. + * test_mklog.py: Test. + +2021-01-13 Martin Liska <mliska@suse.cz> + + * gcc-changelog/git_commit.py: Allow modifications of older + ChangeLog (or specific) files without need to make a ChangeLog + entry. + * gcc-changelog/test_email.py: Test it. + * gcc-changelog/test_patches.txt: Add new patch. + +2021-01-11 Martin Liska <mliska@suse.cz> + + * update-copyright.py: Port to python3 by guessing encoding + (first utf8, then iso8859). Add 2 more ignores: .png and .pyc. + +2021-01-06 Martin Liska <mliska@suse.cz> + + * gcc-changelog/git_commit.py: Add decode_path function. + * gcc-changelog/git_email.py: Use it in order to solve + utf8 encoding filename issues. + * gcc-changelog/git_repository.py: Likewise. + * gcc-changelog/test_email.py: Test it. + +2021-01-04 Jakub Jelinek <jakub@redhat.com> + + * update-copyright.py: Add AMD and Ulf Adams as external authors. + +2021-01-04 Jakub Jelinek <jakub@redhat.com> + + * update-copyright.py: Use 8 spaces instead of tab to indent. + +2021-01-04 Martin Liska <mliska@suse.cz> + + * mklog.py: Add --update-copyright option which adds: + "Update copyright years." to ChangeLog files belonging + to a modified file. + +2021-01-04 Martin Liska <mliska@suse.cz> + + * gcc-changelog/git_commit.py: Skip Update copyright + years commits. + +2020-12-21 Martin Liska <mliska@suse.cz> + + * gcc-changelog/git_commit.py: Add new error for quoted + filenames. + * gcc-changelog/test_email.py: Test it. + * gcc-changelog/test_patches.txt: Test it. + +2020-12-21 Martin Liska <mliska@suse.cz> + + * gcc-changelog/test_email.py: New test. + * gcc-changelog/test_patches.txt: Likewise. + +2020-12-17 Nathan Sidwell <nathan@acm.org> + + PR bootstrap/98300 + * gcc_update: Add c++tools/config.h.in. + +2020-12-15 Nathan Sidwell <nathan@acm.org> + + * gcc_update: Add c++tools & libcody. + +2020-12-15 Nathan Sidwell <nathan@acm.org> + + * gcc-changelog/git_commit.py (changelog_locations): Add + libcody, c++tools. + +2020-12-08 Martin Liska <mliska@suse.cz> + + * filter-clang-warnings.py: Filter more cases. + +2020-12-08 Martin Liska <mliska@suse.cz> + + * filter-clang-warnings.py: Modernize and filter 2 more + patterns. + 2020-12-04 Martin Liska <mliska@suse.cz> * check-params-in-docs.py: use flake8 and add some diff --git a/contrib/compare-lto b/contrib/compare-lto index 17379e1..c0bb71c 100755 --- a/contrib/compare-lto +++ b/contrib/compare-lto @@ -32,7 +32,7 @@ case $1 in esac if test $# != 2; then - echo 'usage: compare-lto file1.o file2.o' >&2 + echo 'usage: compare-lto file1 file2' >&2 exit 1 fi @@ -101,6 +101,25 @@ else else status=1 fi + + # PE-COFF executables are timestamped so skip leading bytes for them. + else + case "$1" in + *.exe) + if cmp -i 256 "$1" "$2"; then + status=0 + else + status=1 + fi + ;; + *) + if test -f "$1.exe" && cmp -i 256 "$1.exe" "$2.exe"; then + status=0 + else + status=1 + fi + ;; + esac fi fi diff --git a/contrib/filter-clang-warnings.py b/contrib/filter-clang-warnings.py index 15cca5f..72b5bbe 100755 --- a/contrib/filter-clang-warnings.py +++ b/contrib/filter-clang-warnings.py @@ -21,52 +21,61 @@ # # -import sys import argparse + def skip_warning(filename, message): 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', - 'when in C++ mode, this behavior is deprecated', '-Wignored-attributes', '-Wgnu-zero-variadic-macro-arguments', - '-Wformat-security'], + '': ['-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', + 'when in C++ mode, this behavior is deprecated', + '-Wignored-attributes', '-Wgnu-zero-variadic-macro-arguments', + '-Wformat-security', '-Wundefined-internal', + '-Wunknown-warning-option'], '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'], - 'i386.md': ['-Wparentheses-equality', '-Wtautological-compare'], + 'i386.md': ['-Wparentheses-equality', '-Wtautological-compare', + '-Wtautological-overlap-compare'], 'sse.md': ['-Wparentheses-equality', '-Wtautological-compare'], - 'genautomata.c': ['-Wstring-plus-int'] - + 'genautomata.c': ['-Wstring-plus-int'], + 'gfortran.texi': [''], + 'libtool': [''] } 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('log', help = 'Log file with clang warnings') +parser.add_argument('log', help='Log file with clang warnings') args = parser.parse_args() -lines = [l.strip() for l in open(args.log)] +lines = [line.strip() for line in open(args.log)] total = 0 messages = [] -for l in lines: +for line in lines: token = ': warning: ' - i = l.find(token) + i = line.find(token) if i != -1: - location = l[:i] - message = l[i + len(token):] + location = line[:i] + message = line[i + len(token):] if not skip_warning(location, message): total += 1 - messages.append(l) + messages.append(line) -for l in sorted(messages): - print(l) +for line in sorted(messages): + print(line) print('\nTotal warnings: %d' % total) diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py index 0c43816..e9dae0a 100755 --- a/contrib/gcc-changelog/git_commit.py +++ b/contrib/gcc-changelog/git_commit.py @@ -21,6 +21,7 @@ import os import re changelog_locations = { + 'c++tools', 'config', 'contrib', 'contrib/header-tools', @@ -51,6 +52,7 @@ changelog_locations = { 'libatomic', 'libbacktrace', 'libcc1', + 'libcody', 'libcpp', 'libcpp/po', 'libdecnumber', @@ -172,6 +174,24 @@ REVIEW_PREFIXES = ('reviewed-by: ', 'reviewed-on: ', 'signed-off-by: ', DATE_FORMAT = '%Y-%m-%d' +def decode_path(path): + # When core.quotepath is true (default value), utf8 chars are encoded like: + # "b/ko\304\215ka.txt" + # + # The upstream bug is fixed: + # https://github.com/gitpython-developers/GitPython/issues/1099 + # + # but we still need a workaround for older versions of the library. + # Please take a look at the explanation of the transformation: + # https://stackoverflow.com/questions/990169/how-do-convert-unicode-escape-sequences-to-unicode-characters-in-a-python-string + + if path.startswith('"') and path.endswith('"'): + return (path.strip('"').encode('utf8').decode('unicode-escape') + .encode('latin-1').decode('utf8')) + else: + return path + + class Error: def __init__(self, message, line=None): self.message = message @@ -194,6 +214,7 @@ class ChangeLogEntry: self.lines = [] self.files = [] self.file_patterns = [] + self.opened_parentheses = 0 def parse_file_names(self): # Whether the content currently processed is between a star prefix the @@ -203,8 +224,14 @@ class ChangeLogEntry: for line in self.lines: # If this line matches the star prefix, start the location # processing on the information that follows the star. + # Note that we need to skip macro names that can be in form of: + # + # * config/i386/i386.md (*fix_trunc<mode>_i387_1, + # *add<mode>3_ne, *add<mode>3_eq_0, *add<mode>3_ne_0, + # *fist<mode>2_<rounding>_1, *<code><mode>3_1): + # m = star_prefix_regex.match(line) - if m: + if m and len(m.group('spaces')) == 1: in_location = True line = m.group('content') @@ -274,6 +301,10 @@ class GitCommit: self.revert_commit = None self.commit_to_info_hook = commit_to_info_hook + # Skip Update copyright years commits + if self.info.lines and self.info.lines[0] == 'Update copyright years.': + return + # Identify first if the commit is a Revert commit for line in self.info.lines: m = revert_regex.match(line) @@ -284,7 +315,7 @@ class GitCommit: self.info = self.commit_to_info_hook(self.revert_commit) project_files = [f for f in self.info.modified_files - if self.is_changelog_filename(f[0]) + if self.is_changelog_filename(f[0], allow_suffix=True) or f[0] in misc_files] ignored_files = [f for f in self.info.modified_files if self.in_ignored_location(f[0])] @@ -304,6 +335,7 @@ class GitCommit: self.parse_changelog() self.parse_file_names() self.check_for_empty_description() + self.check_for_broken_parentheses() self.deduce_changelog_locations() self.check_file_patterns() if not self.errors: @@ -319,8 +351,14 @@ class GitCommit: return [x[0] for x in self.info.modified_files if x[1] == 'A'] @classmethod - def is_changelog_filename(cls, path): - return path.endswith('/ChangeLog') or path == 'ChangeLog' + def is_changelog_filename(cls, path, allow_suffix=False): + basename = os.path.basename(path) + if basename == 'ChangeLog': + return True + elif allow_suffix and basename.startswith('ChangeLog'): + return True + else: + return False @classmethod def find_changelog_location(cls, name): @@ -466,7 +504,8 @@ class GitCommit: else: m = star_prefix_regex.match(line) if m: - if len(m.group('spaces')) != 1: + if (len(m.group('spaces')) != 1 and + last_entry.opened_parentheses == 0): msg = 'one space should follow asterisk' self.errors.append(Error(msg, line)) else: @@ -478,6 +517,7 @@ class GitCommit: msg = f'empty group "{needle}" found' self.errors.append(Error(msg, line)) last_entry.lines.append(line) + self.process_parentheses(last_entry, line) else: if last_entry.is_empty: msg = 'first line should start with a tab, ' \ @@ -485,6 +525,18 @@ class GitCommit: self.errors.append(Error(msg, line)) else: last_entry.lines.append(line) + self.process_parentheses(last_entry, line) + + def process_parentheses(self, last_entry, line): + for c in line: + if c == '(': + last_entry.opened_parentheses += 1 + elif c == ')': + if last_entry.opened_parentheses == 0: + msg = 'bad wrapping of parenthesis' + self.errors.append(Error(msg, line)) + else: + last_entry.opened_parentheses -= 1 def parse_file_names(self): for entry in self.changelog_entries: @@ -508,6 +560,12 @@ class GitCommit: msg = 'missing description of a change' self.errors.append(Error(msg, line)) + def check_for_broken_parentheses(self): + for entry in self.changelog_entries: + if entry.opened_parentheses != 0: + msg = 'bad parentheses wrapping' + self.errors.append(Error(msg, entry.lines[0])) + def get_file_changelog_location(self, changelog_file): for file in self.info.modified_files: if file[0] == changelog_file: diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py index 5b53ca4..00ad004 100755 --- a/contrib/gcc-changelog/git_email.py +++ b/contrib/gcc-changelog/git_email.py @@ -22,7 +22,7 @@ from itertools import takewhile from dateutil.parser import parse -from git_commit import GitCommit, GitInfo +from git_commit import GitCommit, GitInfo, decode_path from unidiff import PatchSet, PatchedFile @@ -52,8 +52,8 @@ class GitEmail(GitCommit): modified_files = [] for f in diff: # Strip "a/" and "b/" prefixes - source = f.source_file[2:] - target = f.target_file[2:] + source = decode_path(f.source_file)[2:] + target = decode_path(f.target_file)[2:] if f.is_added_file: t = 'A' diff --git a/contrib/gcc-changelog/git_repository.py b/contrib/gcc-changelog/git_repository.py index 8edcff9..a0e293d 100755 --- a/contrib/gcc-changelog/git_repository.py +++ b/contrib/gcc-changelog/git_repository.py @@ -26,7 +26,7 @@ except ImportError: print(' Debian, Ubuntu: python3-git') exit(1) -from git_commit import GitCommit, GitInfo +from git_commit import GitCommit, GitInfo, decode_path def parse_git_revisions(repo_path, revisions, strict=True): @@ -51,11 +51,11 @@ def parse_git_revisions(repo_path, revisions, strict=True): # Consider that renamed files are two operations: # the deletion of the original name # and the addition of the new one. - modified_files.append((file.a_path, 'D')) + modified_files.append((decode_path(file.a_path), 'D')) t = 'A' else: t = 'M' - modified_files.append((file.b_path, t)) + modified_files.append((decode_path(file.b_path), t)) date = datetime.utcfromtimestamp(c.committed_date) author = '%s <%s>' % (c.author.name, c.author.email) diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py index 8f5129e..b81548f 100755 --- a/contrib/gcc-changelog/test_email.py +++ b/contrib/gcc-changelog/test_email.py @@ -395,3 +395,24 @@ class TestGccChangelog(unittest.TestCase): err = email.errors[0] assert err.message == "pattern doesn't match any changed files" assert err.line == 'libstdc++-v3/testsuite/28_regex_not-existing/' + + def test_unicode_chars_in_filename(self): + email = self.from_patch_glob('0001-Add-horse.patch') + assert not email.errors + + def test_bad_unicode_chars_in_filename(self): + email = self.from_patch_glob('0001-Add-horse2.patch') + assert not email.errors + assert email.changelog_entries[0].files == ['koníček.txt'] + + def test_modification_of_old_changelog(self): + email = self.from_patch_glob('0001-fix-old-ChangeLog.patch') + assert not email.errors + + def test_multiline_parentheses(self): + email = self.from_patch_glob('0001-Add-macro.patch') + assert not email.errors + + def test_multiline_bad_parentheses(self): + email = self.from_patch_glob('0002-Wrong-macro-changelog.patch') + assert email.errors[0].message == 'bad parentheses wrapping' diff --git a/contrib/gcc-changelog/test_patches.txt b/contrib/gcc-changelog/test_patches.txt index 02ce28d..9de2897 100644 --- a/contrib/gcc-changelog/test_patches.txt +++ b/contrib/gcc-changelog/test_patches.txt @@ -3344,3 +3344,140 @@ index f51453f019a..d10ecf483f4 100644 + -- 2.29.2 + +=== 0001-Add-horse.patch === +From 2884248d07e4e2c922e137365253e2e521c425b0 Mon Sep 17 00:00:00 2001 +From: Martin Liska <mliska@suse.cz> +Date: Mon, 21 Dec 2020 10:14:46 +0100 +Subject: [PATCH] Add horse. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +ChangeLog: + + * koníček.txt: New file. +--- + koníček.txt | 1 + + 1 file changed, 1 insertion(+) + create mode 100644 koníček.txt + +diff --git a/koníček.txt b/koníček.txt +new file mode 100644 +index 00000000000..56c67f58752 +--- /dev/null ++++ b/koníček.txt +@@ -0,0 +1 @@ ++I'm a horse. +-- +2.29.2 +=== 0001-Add-horse2.patch === +From 2884248d07e4e2c922e137365253e2e521c425b0 Mon Sep 17 00:00:00 2001 +From: Martin Liska <mliska@suse.cz> +Date: Mon, 21 Dec 2020 10:14:46 +0100 +Subject: [PATCH] Add horse. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +ChangeLog: + + * koníček.txt: New file. +--- + "kon\303\255\304\215ek.txt" | 1 + + 1 file changed, 1 insertion(+) + create mode 100644 "kon\303\255\304\215ek.txt" + +diff --git "a/kon\303\255\304\215ek.txt" "b/kon\303\255\304\215ek.txt" +new file mode 100644 +index 00000000000..56c67f58752 +--- /dev/null ++++ "b/kon\303\255\304\215ek.txt" +@@ -0,0 +1 @@ ++I'm a horse. +-- +2.29.2 + +=== 0001-fix-old-ChangeLog.patch === +From fd498465b2801203089616be9a0e3c1f4fc065a0 Mon Sep 17 00:00:00 2001 +From: Martin Liska <mliska@suse.cz> +Date: Wed, 13 Jan 2021 11:45:37 +0100 +Subject: [PATCH] Fix a changelog. + +--- + gcc/ChangeLog-2020 | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/gcc/ChangeLog-2020 b/gcc/ChangeLog-2020 +index 6553720acad..2c170ef014a 100644 +--- a/gcc/ChangeLog-2020 ++++ b/gcc/ChangeLog-2020 +@@ -1 +1,2 @@ + ++ + +-- +2.29.2 +=== 0001-Add-macro.patch === +From 9b7eedc932fe594547fb060b36dfd9e4178c4f9b Mon Sep 17 00:00:00 2001 +From: Martin Liska <mliska@suse.cz> +Date: Wed, 13 Jan 2021 16:26:45 +0100 +Subject: [PATCH 1/2] Add macro. + +gcc/ChangeLog: + + * config/i386/i386.md (*fix_trunc<mode>_i387_1, *add<mode>3_eq, + *add<mode>3_ne, *add<mode>3_eq_0, *add<mode>3_ne_0, *add<mode>3_eq, + *fist<mode>2_<rounding>_1, *<code><mode>3_1, *<code>di3_doubleword): + Use ix86_pre_reload_split instead of can_create_pseudo_p in condition. + * config/i386/sse.md + (*fix_trunc<mode>_i387_1, *add<mode>3_eq, + *add<mode>3_ne, *add<mode>3_eq_0, *add<mode>3_ne_0, *add<mode>3_eq, + *fist<mode>2_<rounding>_1): This should also work. +--- + gcc/config/i386/i386.md | 1 + + gcc/config/i386/sse.md | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md +index b60784a2908..ac63591b33f 100644 +--- a/gcc/config/i386/i386.md ++++ b/gcc/config/i386/i386.md +@@ -1 +1,2 @@ + ++ + +diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md +index 7f03fc491c3..0e17997db26 100644 +--- a/gcc/config/i386/sse.md ++++ b/gcc/config/i386/sse.md +@@ -1 +1,2 @@ + ++ + +-- +2.29.2 + +=== 0002-Wrong-macro-changelog.patch === +From 3542802111d4c6752ac7233ef96655b7fb78aae4 Mon Sep 17 00:00:00 2001 +From: Martin Liska <mliska@suse.cz> +Date: Wed, 13 Jan 2021 16:54:58 +0100 +Subject: [PATCH 2/2] Wrong macro changelog + +gcc/ChangeLog: + + * config/i386/i386.md (*fix_trunc<mode>_i387_1, + (foo): Change it. +--- + gcc/config/i386/i386.md | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md +index ac63591b33f..ff4d61764e7 100644 +--- a/gcc/config/i386/i386.md ++++ b/gcc/config/i386/i386.md +@@ -1 +1,2 @@ + ++ +-- +2.29.2 diff --git a/contrib/gcc_update b/contrib/gcc_update index 5e8af0e..43d284d 100755 --- a/contrib/gcc_update +++ b/contrib/gcc_update @@ -102,6 +102,9 @@ gcc/testsuite/gcc.dg/cpp/direct2s.c: gcc/testsuite/gcc.dg/cpp/direct2.c # lto-plugin lto-plugin/configure: lto-plugin/configure.ac lto-plugin/aclocal.m4 lto-plugin/Makefile.in: lto-plugin/Makefile.am lto-plugin/aclocal.m4 +# tools +c++tools/configure: c++tools/configure.ac +c++tools/config.h.in: c++tools/configure.ac # And libraries, at last libbanshee/configure: libbanshee/configure.ac libmudflap/configure: libmudflap/configure.ac @@ -126,6 +129,7 @@ libquadmath/configure: libquadmath/configure.ac libquadmath/aclocal.m4 libquadmath/aclocal.m4: libquadmath/configure.ac libquadmath/acinclude.m4 libquadmath/Makefile.in: libquadmath/Makefile.am libquadmath/configure.ac libgfortran/aclocal.m4 libgfortran/configure: libgfortran/configure.ac libgfortran/aclocal.m4 +libcody/configure: libcody/configure.ac libcody/config.m4 libcpp/aclocal.m4: libcpp/configure.ac libcpp/Makefile.in: libcpp/configure.ac libcpp/aclocal.m4 libcpp/configure: libcpp/configure.ac libcpp/aclocal.m4 diff --git a/contrib/mklog.py b/contrib/mklog.py index 57be299..a70536a 100755 --- a/contrib/mklog.py +++ b/contrib/mklog.py @@ -27,8 +27,10 @@ # Author: Martin Liska <mliska@suse.cz> import argparse +import datetime import os import re +import subprocess import sys from itertools import takewhile @@ -47,10 +49,11 @@ 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*\([^*]') template_and_param_regex = re.compile(r'<[^<>]*>') +md_def_regex = re.compile(r'\(define.*\s+"(.*)"') bugzilla_url = 'https://gcc.gnu.org/bugzilla/rest.cgi/bug?id=%s&' \ 'include_fields=summary' -function_extensions = {'.c', '.cpp', '.C', '.cc', '.h', '.inc', '.def'} +function_extensions = {'.c', '.cpp', '.C', '.cc', '.h', '.inc', '.def', '.md'} help_message = """\ Generate ChangeLog template for PATCH. @@ -130,6 +133,9 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False): diff = PatchSet(data) for file in diff: + # skip files that can't be parsed + if file.path == '/dev/null': + continue changelog = find_changelog(file.path) if changelog not in changelogs: changelogs[changelog] = [] @@ -198,6 +204,15 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False): for line in hunk: m = identifier_regex.match(line.value) if line.is_added or line.is_removed: + # special-case definition in .md files + m2 = md_def_regex.match(line.value) + if extension == '.md' and m2: + fn = m2.group(1) + if fn not in functions: + functions.append(fn) + last_fn = None + success = True + if not line.value.strip(): continue modified_visited = True @@ -227,6 +242,28 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False): return out +def update_copyright(data): + current_timestamp = datetime.datetime.now().strftime('%Y-%m-%d') + username = subprocess.check_output('git config user.name', shell=True, + encoding='utf8').strip() + email = subprocess.check_output('git config user.email', shell=True, + encoding='utf8').strip() + + changelogs = set() + diff = PatchSet(data) + + for file in diff: + changelog = os.path.join(find_changelog(file.path), 'ChangeLog') + if changelog not in changelogs: + changelogs.add(changelog) + with open(changelog) as f: + content = f.read() + with open(changelog, 'w+') as f: + f.write(f'{current_timestamp} {username} <{email}>\n\n') + f.write('\tUpdate copyright years.\n\n') + f.write(content) + + if __name__ == '__main__': parser = argparse.ArgumentParser(description=help_message) parser.add_argument('input', nargs='?', @@ -238,28 +275,33 @@ if __name__ == '__main__': parser.add_argument('-c', '--changelog', help='Append the ChangeLog to a git commit message ' 'file') + parser.add_argument('--update-copyright', action='store_true', + help='Update copyright in ChangeLog files') args = parser.parse_args() if args.input == '-': args.input = None data = open(args.input) if args.input else sys.stdin - output = generate_changelog(data, args.no_functions, - args.fill_up_bug_titles) - if args.changelog: - lines = open(args.changelog).read().split('\n') - start = list(takewhile(lambda l: not l.startswith('#'), lines)) - end = lines[len(start):] - with open(args.changelog, 'w') as f: - if start: - # appent empty line - if start[-1] != '': - start.append('') - else: - # append 2 empty lines - start = 2 * [''] - f.write('\n'.join(start)) - f.write('\n') - f.write(output) - f.write('\n'.join(end)) + if args.update_copyright: + update_copyright(data) else: - print(output, end='') + output = generate_changelog(data, args.no_functions, + args.fill_up_bug_titles) + if args.changelog: + lines = open(args.changelog).read().split('\n') + start = list(takewhile(lambda l: not l.startswith('#'), lines)) + end = lines[len(start):] + with open(args.changelog, 'w') as f: + if start: + # appent empty line + if start[-1] != '': + start.append('') + else: + # append 2 empty lines + start = 2 * [''] + f.write('\n'.join(start)) + f.write('\n') + f.write(output) + f.write('\n'.join(end)) + else: + print(output, end='') diff --git a/contrib/test_mklog.py b/contrib/test_mklog.py index 344b7a2..7e95ec1 100755 --- a/contrib/test_mklog.py +++ b/contrib/test_mklog.py @@ -399,6 +399,44 @@ gcc/ChangeLog: ''' +PATCH9 = '''\ +diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md +index 2a260c1cfbd..7f03fc491c3 100644 +--- a/gcc/config/i386/sse.md ++++ b/gcc/config/i386/sse.md +@@ -17611,6 +17611,23 @@ (define_insn "avx2_<code>v16qiv16hi2<mask_name>" + (set_attr "prefix" "maybe_evex") + (set_attr "mode" "OI")]) + ++(define_insn_and_split "*avx2_zero_extendv16qiv16hi2_1" ++ [(set (match_operand:V32QI 0 "register_operand" "=v") ++ (vec_select:V32QI ++ (vec_concat:V64QI ++ (match_operand:V32QI 1 "nonimmediate_operand" "vm") ++ (match_operand:V32QI 2 "const0_operand" "C")) ++ (match_parallel 3 "pmovzx_parallel" ++ [(match_operand 4 "const_int_operand" "n")])))] ++ "TARGET_AVX2" ++ "#" ++ "&& reload_completed" ++ [(set (match_dup 0) (zero_extend:V16HI (match_dup 1)))] ++{ ++ operands[0] = lowpart_subreg (V16HImode, operands[0], V32QImode); ++ operands[1] = lowpart_subreg (V16QImode, operands[1], V32QImode); ++}) ++ + (define_expand "<insn>v16qiv16hi2" + [(set (match_operand:V16HI 0 "register_operand") + (any_extend:V16HI +''' + +EXPECTED9 = '''\ +gcc/ChangeLog: + + * config/i386/sse.md (*avx2_zero_extendv16qiv16hi2_1): + +''' + class TestMklog(unittest.TestCase): def test_macro_definition(self): changelog = generate_changelog(PATCH1) @@ -437,3 +475,7 @@ class TestMklog(unittest.TestCase): def test_renaming(self): changelog = generate_changelog(PATCH8) assert changelog == EXPECTED8 + + def test_define_macro_parsing(self): + changelog = generate_changelog(PATCH9) + assert changelog == EXPECTED9 diff --git a/contrib/update-copyright.py b/contrib/update-copyright.py index 12ce4c0..5603b8e 100755 --- a/contrib/update-copyright.py +++ b/contrib/update-copyright.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # # Copyright (C) 2013-2020 Free Software Foundation, Inc. # @@ -64,7 +64,10 @@ class GenericFilter: def __init__ (self): self.skip_files = set() self.skip_dirs = set() - self.skip_extensions = set() + self.skip_extensions = set([ + '.png', + '.pyc', + ]) self.fossilised_files = set() self.own_files = set() @@ -307,7 +310,7 @@ class Copyright: # If it looks like the copyright is incomplete, add the next line. while not self.is_complete (match): try: - next_line = file.next() + next_line = file.readline() except StopIteration: break @@ -381,6 +384,15 @@ class Copyright: return (line != orig_line, line, next_line) + def guess_encoding (self, pathname): + for encoding in ('utf8', 'iso8859'): + try: + open(pathname, 'r', encoding=encoding).read() + return encoding + except UnicodeDecodeError: + pass + return None + def process_file (self, dir, filename, filter): pathname = os.path.join (dir, filename) if filename.endswith ('.tmp'): @@ -395,7 +407,8 @@ class Copyright: changed = False line_filter = filter.get_line_filter (dir, filename) mode = None - with open (pathname, 'r') as file: + encoding = self.guess_encoding(pathname) + with open (pathname, 'r', encoding=encoding) as file: prev = None mode = os.fstat (file.fileno()).st_mode for line in file: @@ -421,7 +434,7 @@ class Copyright: # If something changed, write the new file out. if changed and self.errors.ok(): tmp_pathname = pathname + '.tmp' - with open (tmp_pathname, 'w') as file: + with open (tmp_pathname, 'w', encoding=encoding) as file: for line in lines: file.write (line) os.fchmod (file.fileno(), mode) @@ -432,7 +445,7 @@ class Copyright: def process_tree (self, tree, filter): for (dir, subdirs, filenames) in os.walk (tree): # Don't recurse through directories that should be skipped. - for i in xrange (len (subdirs) - 1, -1, -1): + for i in range (len (subdirs) - 1, -1, -1): if filter.skip_dir (dir, subdirs[i]): del subdirs[i] @@ -594,7 +607,7 @@ class TestsuiteFilter (GenericFilter): if filename == 'README' and os.path.basename (dir) == 'params': return True if filename == 'pdt_5.f03' and os.path.basename (dir) == 'gfortran.dg': - return True + return True return GenericFilter.skip_file (self, dir, filename) class LibCppFilter (GenericFilter): @@ -683,6 +696,7 @@ class GCCCopyright (Copyright): self.add_external_author ('ARM') self.add_external_author ('AdaCore') + self.add_external_author ('Advanced Micro Devices Inc.') self.add_external_author ('Ami Tavory and Vladimir Dreizin, IBM-HRL.') self.add_external_author ('Cavium Networks.') self.add_external_author ('Faraday Technology Corp.') @@ -710,6 +724,7 @@ class GCCCopyright (Copyright): self.add_external_author ('The Go Authors. All rights reserved.') self.add_external_author ('The Go Authors.') self.add_external_author ('The Regents of the University of California.') + self.add_external_author ('Ulf Adams') self.add_external_author ('Unicode, Inc.') self.add_external_author ('University of Toronto.') self.add_external_author ('Yoshinori Sato') |