https://github.com/vbvictor updated https://github.com/llvm/llvm-project/pull/165472
>From 5340574a9ac6335e2effc15e73f122018ffc58a2 Mon Sep 17 00:00:00 2001 From: Victor Baranov <[email protected]> Date: Tue, 28 Oct 2025 22:33:53 +0300 Subject: [PATCH 1/2] [GitHub][CI] Add running of dump_ast_matchers.py to premerge workflow --- llvm/utils/git/code-format-helper.py | 65 +++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py index 406a72817acb8..6de7d21ab68a6 100755 --- a/llvm/utils/git/code-format-helper.py +++ b/llvm/utils/git/code-format-helper.py @@ -466,7 +466,70 @@ def format_run(self, changed_files: List[str], args: FormatArgs) -> Optional[str return report -ALL_FORMATTERS = (DarkerFormatHelper(), ClangFormatHelper(), UndefGetFormatHelper()) +class DumpASTMatchersHelper(FormatHelper): + name = "dump_ast_matchers" + friendly_name = "AST matchers documentation" + + output_html = "clang/docs/LibASTMatchersReference.html" + script_dir = "clang/docs/tools" + script_name = "dump_ast_matchers.py" + + @property + def instructions(self) -> str: + return f"cd {self.script_dir} && python {self.script_name}" + + def should_run(self, changed_files: List[str]) -> List[str]: + for file in changed_files: + if file == "clang/include/clang/ASTMatchers/ASTMatchers.h": + return True + return False + + def has_tool(self) -> bool: + if not os.path.exists(os.path.join(self.script_dir, self.script_name)): + return False + return True + + def format_run(self, changed_files: List[str], args: FormatArgs) -> Optional[str]: + if not self.should_run(changed_files): + return None + + if args.verbose: + print(f"Running: {self.instructions}") + + # Run the 'dump_ast_matchers.py' from its directory as specified in the script doc + proc = subprocess.run( + ["python", self.script_name], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding="utf-8", + cwd=self.script_dir, + ) + + if proc.returncode != 0: + return f"Execution of 'dump_ast_matchers.py' failed:\n{proc.stderr}\n{proc.stdout}" + + # Check if 'LibASTMatchersReference.html' file was modified + cmd = ["git", "diff", "--exit-code", self.output_html] + proc = subprocess.run( + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8" + ) + + # 'LibASTMatchersReference.html' was modified - count as failure + if proc.returncode != 0: + if args.verbose: + print(f"error: {self.name} exited with code {proc.returncode}") + print(proc.stdout.decode("utf-8")) + return proc.stdout.decode("utf-8") + else: + return None + + +ALL_FORMATTERS = ( + DarkerFormatHelper(), + ClangFormatHelper(), + UndefGetFormatHelper(), + DumpASTMatchersHelper(), +) def hook_main(): >From 1e19a19d600a6238e53b19a5cc75c81e7232b93e Mon Sep 17 00:00:00 2001 From: Victor Baranov <[email protected]> Date: Tue, 28 Oct 2025 23:25:38 +0300 Subject: [PATCH 2/2] add change to matchers --- clang/include/clang/ASTMatchers/ASTMatchers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index 98e62de2a9bfb..cc72613db4d15 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -1390,7 +1390,7 @@ extern const internal::VariadicDynCastAllOfMatcher<Expr, RequiresExpr> /// Matches concept requirement body declaration. /// -/// Example matches '{ *p; }' +/// Example matches '{ * p; }' /// \code /// template<typename T> /// concept dereferencable = requires(T p) { *p; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
