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/4] [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/4] 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; }

>From def77bbffa063b15ec9e6f4ca174fe2bfb81f2f8 Mon Sep 17 00:00:00 2001
From: Victor Baranov <[email protected]>
Date: Tue, 28 Oct 2025 23:37:28 +0300
Subject: [PATCH 3/4] tmp1

---
 llvm/utils/git/code-format-helper.py | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/llvm/utils/git/code-format-helper.py 
b/llvm/utils/git/code-format-helper.py
index 6de7d21ab68a6..6be2fb260e20c 100755
--- a/llvm/utils/git/code-format-helper.py
+++ b/llvm/utils/git/code-format-helper.py
@@ -476,7 +476,7 @@ class DumpASTMatchersHelper(FormatHelper):
 
     @property
     def instructions(self) -> str:
-        return f"cd {self.script_dir} && python {self.script_name}"
+        return f"cd {self.script_dir} && python3 {self.script_name}"
 
     def should_run(self, changed_files: List[str]) -> List[str]:
         for file in changed_files:
@@ -493,12 +493,17 @@ def format_run(self, changed_files: List[str], args: 
FormatArgs) -> Optional[str
         if not self.should_run(changed_files):
             return None
 
+        # Verify the input file exists
+        matchers_header = "clang/include/clang/ASTMatchers/ASTMatchers.h"
+        if not os.path.exists(matchers_header):
+            return f"Input file not found: {matchers_header}"
+
         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],
+            ["python3", self.script_name],
             stdout=subprocess.PIPE,
             stderr=subprocess.PIPE,
             encoding="utf-8",
@@ -506,7 +511,14 @@ def format_run(self, changed_files: List[str], args: 
FormatArgs) -> Optional[str
         )
 
         if proc.returncode != 0:
-            return f"Execution of 'dump_ast_matchers.py' 
failed:\n{proc.stderr}\n{proc.stdout}"
+            error_msg = f"Execution of 'dump_ast_matchers.py' failed with exit 
code {proc.returncode}"
+            if proc.stderr:
+                error_msg += f"\nSTDERR:\n{proc.stderr}"
+            if proc.stdout:
+                error_msg += f"\nSTDOUT:\n{proc.stdout}"
+            if args.verbose:
+                print(error_msg)
+            return error_msg
 
         # Check if 'LibASTMatchersReference.html' file was modified
         cmd = ["git", "diff", "--exit-code", self.output_html]
@@ -518,8 +530,8 @@ def format_run(self, changed_files: List[str], args: 
FormatArgs) -> Optional[str
         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")
+                print(proc.stdout)
+            return proc.stdout
         else:
             return None
 

>From 4b503d56adfc1cb88585f808a0bf877bb0ea7b68 Mon Sep 17 00:00:00 2001
From: Victor Baranov <[email protected]>
Date: Tue, 28 Oct 2025 23:38:57 +0300
Subject: [PATCH 4/4] add debug logs

---
 llvm/utils/git/code-format-helper.py | 39 ++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/llvm/utils/git/code-format-helper.py 
b/llvm/utils/git/code-format-helper.py
index 6be2fb260e20c..0fb78cf3da5bb 100755
--- a/llvm/utils/git/code-format-helper.py
+++ b/llvm/utils/git/code-format-helper.py
@@ -493,8 +493,25 @@ def format_run(self, changed_files: List[str], args: 
FormatArgs) -> Optional[str
         if not self.should_run(changed_files):
             return None
 
+        # Debug logging
+        if args.verbose:
+            print(f"=== Debug: DumpASTMatchersHelper ===")
+            print(f"Current working directory: {os.getcwd()}")
+            print(f"Script directory: {self.script_dir}")
+            print(f"Script name: {self.script_name}")
+            print(f"Script full path: {os.path.join(self.script_dir, 
self.script_name)}")
+            print(f"Script exists: 
{os.path.exists(os.path.join(self.script_dir, self.script_name))}")
+            print(f"Output HTML path: {self.output_html}")
+            print(f"Output HTML exists: {os.path.exists(self.output_html)}")
+
         # Verify the input file exists
         matchers_header = "clang/include/clang/ASTMatchers/ASTMatchers.h"
+        if args.verbose:
+            print(f"Input header path: {matchers_header}")
+            print(f"Input header exists: {os.path.exists(matchers_header)}")
+            if os.path.exists(matchers_header):
+                print(f"Input header absolute path: 
{os.path.abspath(matchers_header)}")
+
         if not os.path.exists(matchers_header):
             return f"Input file not found: {matchers_header}"
 
@@ -510,6 +527,13 @@ def format_run(self, changed_files: List[str], args: 
FormatArgs) -> Optional[str
             cwd=self.script_dir,
         )
 
+        if args.verbose:
+            print(f"Script exit code: {proc.returncode}")
+            if proc.stdout:
+                print(f"Script STDOUT (first 500 chars): {proc.stdout[:500]}")
+            if proc.stderr:
+                print(f"Script STDERR (first 500 chars): {proc.stderr[:500]}")
+
         if proc.returncode != 0:
             error_msg = f"Execution of 'dump_ast_matchers.py' failed with exit 
code {proc.returncode}"
             if proc.stderr:
@@ -522,15 +546,26 @@ def format_run(self, changed_files: List[str], args: 
FormatArgs) -> Optional[str
 
         # Check if 'LibASTMatchersReference.html' file was modified
         cmd = ["git", "diff", "--exit-code", self.output_html]
+        if args.verbose:
+            print(f"Checking if output HTML was modified: {' '.join(cmd)}")
+
         proc = subprocess.run(
             cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, 
encoding="utf-8"
         )
 
+        if args.verbose:
+            print(f"Git diff exit code: {proc.returncode}")
+            if proc.returncode != 0:
+                print(f"Output HTML was modified (diff length: 
{len(proc.stdout)} chars)")
+            else:
+                print(f"Output HTML was NOT modified - check passed!")
+
         # '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)
+                print(f"error: {self.name} detected that {self.output_html} 
was modified")
+                print(f"This means the developer needs to run the script 
locally")
+                print(f"Diff preview (first 500 chars):\n{proc.stdout[:500]}")
             return proc.stdout
         else:
             return None

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to