diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml index 22357e5d99e4c7..663779909416da 100644 --- a/.github/workflows/pr-code-format.yml +++ b/.github/workflows/pr-code-format.yml @@ -80,7 +80,7 @@ jobs: # Create an empty comments file so the pr-write job doesn't fail. run: | echo "[]" > comments && - python ./code-format-tools/llvm/utils/git/code-format-helper.py \ + python ./llvm/utils/git/code-format-helper.py \ --write-comment-to-file \ --token ${{ secrets.GITHUB_TOKEN }} \ --issue-number $GITHUB_PR_NUMBER \ diff --git a/libcxx/include/vector b/libcxx/include/vector index aaf51d18fe30fb..8c492ce0ab34d7 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -739,7 +739,8 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { size_type __old_size = size(); __clear(); - __annotate_shrink(__old_size); + __annotate_shrink + (__old_size); } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz); diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py index f1207026704e88..72d414ddb07162 100755 --- a/llvm/utils/git/code-format-helper.py +++ b/llvm/utils/git/code-format-helper.py @@ -210,12 +210,23 @@ def format_run(self, changed_files: List[str], args: FormatArgs) -> Optional[str if not cpp_files: return None - cf_cmd = [self.clang_fmt_path, "--diff"] + cf_cmd = [self.clang_fmt_path, "--verbose", "--diff"] if args.start_rev and args.end_rev: cf_cmd.append(args.start_rev) cf_cmd.append(args.end_rev) + # Gather the extension of all modified files and pass them explicitly to git-clang-format. + # This prevents git-clang-format from applying its own filtering rules on top of ours. + extensions = set() + for file in cpp_files: + _, ext = os.path.splitext(file) + extensions.add( + ext.strip(".") + ) # Exclude periods since git-clang-format takes extensions without them + cf_cmd.append("--extensions") + cf_cmd.append("{}".format(",".join(extensions))) + cf_cmd.append("--") cf_cmd += cpp_files @@ -225,6 +236,9 @@ def format_run(self, changed_files: List[str], args: FormatArgs) -> Optional[str proc = subprocess.run(cf_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) sys.stdout.write(proc.stderr.decode("utf-8")) + print("LDIONNE: return code of cmd was {}".format(proc.returncode)) + print("LDIONNE: output of cmd was:\n{}".format(proc.stdout.decode("utf-8"))) + if proc.returncode != 0: # formatting needed, or the command otherwise failed if args.verbose: