https://github.com/vbvictor updated 
https://github.com/llvm/llvm-project/pull/154416

>From 0f0db33a875736a5a0527695316c6820a65ad529 Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2...@gmail.com>
Date: Fri, 29 Aug 2025 17:32:50 +0300
Subject: [PATCH 1/2] [clang-tidy] Add new -hide-progress option to
 tidy-scripts for suppressing progress information

---
 .../clang-tidy/tool/clang-tidy-diff.py        | 11 +++++--
 .../clang-tidy/tool/run-clang-tidy.py         | 29 ++++++++++++-------
 clang-tools-extra/docs/ReleaseNotes.rst       |  4 +++
 .../hide-progress-flag-scripts.cpp            | 24 +++++++++++++++
 4 files changed, 55 insertions(+), 13 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/infrastructure/hide-progress-flag-scripts.cpp

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index d7899e0a18d0c..b4b4648e765cf 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -258,6 +258,11 @@ def main():
         help="Upgrades clang-tidy warnings to errors. Same format as 
'-checks'.",
         default="",
     )
+    parser.add_argument(
+        "-hide-progress",
+        action="store_true",
+        help="Hide progress",
+    )
 
     clang_tidy_args = []
     argv = sys.argv[1:]
@@ -312,7 +317,8 @@ def main():
     if max_task_count == 0:
         max_task_count = multiprocessing.cpu_count()
     max_task_count = min(len(lines_by_file), max_task_count)
-    print(f"Running clang-tidy in {max_task_count} threads...")
+    if not args.hide_progress:
+        print(f"Running clang-tidy in {max_task_count} threads...")
 
     combine_fixes = False
     export_fixes_dir = None
@@ -408,7 +414,8 @@ def main():
         return_code = 1
 
     if combine_fixes:
-        print("Writing fixes to " + args.export_fixes + " ...")
+        if not args.hide_progress:
+            print(f"Writing fixes to {args.export_fixes} ...")
         try:
             merge_replacement_files(export_fixes_dir, args.export_fixes)
         except:
diff --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py 
b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
index 670e0a2c7678a..a722e20a81c68 100755
--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -576,6 +576,11 @@ async def main() -> None:
         action="store_true",
         help="Enable per-check timing profiles, and print a report",
     )
+    parser.add_argument(
+        "-hide-progress",
+        action="store_true",
+        help="Hide progress",
+    )
     args = parser.parse_args()
 
     db_path = "compile_commands.json"
@@ -681,13 +686,11 @@ async def main() -> None:
     file_name_re = re.compile("|".join(args.files))
     files = {f for f in files if file_name_re.search(f)}
 
-    print(
-        f"Running clang-tidy in {max_task} threads for",
-        len(files),
-        "files out of",
-        number_files_in_database,
-        "in compilation database ...",
-    )
+    if not args.hide_progress:
+        print(
+            f"Running clang-tidy in {max_task} threads for {len(files)} files "
+            f"out of {number_files_in_database} in compilation database ..."
+        )
 
     returncode = 0
     semaphore = asyncio.Semaphore(max_task)
@@ -716,13 +719,15 @@ async def main() -> None:
                     result.stderr += f"{result.filename}: terminated by signal 
{-result.returncode}\n"
             progress = f"[{i + 1: >{len(f'{len(files)}')}}/{len(files)}]"
             runtime = f"[{result.elapsed:.1f}s]"
-            print(f"{progress}{runtime} {' '.join(result.invocation)}")
+            if not args.hide_progress:
+                print(f"{progress}{runtime} {' '.join(result.invocation)}")
             if result.stdout:
                 print(result.stdout, end=("" if result.stderr else "\n"))
             if result.stderr:
                 print(result.stderr)
     except asyncio.CancelledError:
-        print("\nCtrl-C detected, goodbye.")
+        if not args.hide_progress:
+            print("\nCtrl-C detected, goodbye.")
         for task in tasks:
             task.cancel()
         if delete_fixes_dir:
@@ -742,7 +747,8 @@ async def main() -> None:
             print("No profiling data found.")
 
     if combine_fixes:
-        print(f"Writing fixes to {args.export_fixes} ...")
+        if not args.hide_progress:
+            print(f"Writing fixes to {args.export_fixes} ...")
         try:
             assert export_fixes_dir
             merge_replacement_files(export_fixes_dir, args.export_fixes)
@@ -752,7 +758,8 @@ async def main() -> None:
             returncode = 1
 
     if args.fix:
-        print("Applying fixes ...")
+        if not args.hide_progress:
+            print("Applying fixes ...")
         try:
             assert export_fixes_dir
             apply_fixes(args, clang_apply_replacements_binary, 
export_fixes_dir)
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 1df8b98232147..deb6439985eee 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -135,6 +135,10 @@ Improvements to clang-tidy
   :program:`clang-tidy-20`. Users should use the check-specific options of the
   same name instead.
 
+- Improved :program:`run-clang-tidy.py` and :program:`clang-tidy-diff.py` 
+  scripts by adding the `-hide-progress` option to suppressing progress and
+  informational messages.
+
 New checks
 ^^^^^^^^^^
 
diff --git 
a/clang-tools-extra/test/clang-tidy/infrastructure/hide-progress-flag-scripts.cpp
 
b/clang-tools-extra/test/clang-tidy/infrastructure/hide-progress-flag-scripts.cpp
new file mode 100644
index 0000000000000..dbc24780ccbda
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/infrastructure/hide-progress-flag-scripts.cpp
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > 
%t/compile_commands.json
+// RUN: echo "Checks: '-*,readability-magic-numbers'" > %t/.clang-tidy
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: cd "%t"
+
+// RUN: %run_clang_tidy -quiet -hide-progress "test.cpp" 2>&1 | FileCheck %s 
--check-prefix=CHECK-RUN-QUIET
+// CHECK-RUN-QUIET-NOT: Running clang-tidy in {{[1-9][0-9]*}} threads for
+// CHECK-RUN-QUIET-NOT: {{[0-9]+}} warning{{s?}} generated
+// CHECK-RUN-QUIET-NOT: [1/1]
+// CHECK-RUN-QUIET: 42 is a magic number;
+
+// REQUIRES: shell
+// RUN: sed 's/42/99/' %s > %t-diff.cpp
+
+// RUN: not diff -U0 %s %t-diff.cpp | %clang_tidy_diff 
-checks=-*,readability-magic-numbers -quiet -hide-progress -- -std=c++11 2>&1 | 
FileCheck %s --check-prefix=CHECK-DIFF-QUIET
+// CHECK-DIFF-QUIET-NOT: Running clang-tidy in {{[1-9][0-9]*}} threads...
+// CHECK-DIFF-QUIET-NOT: {{[0-9]+}} warning{{s?}} generated
+// CHECK-DIFF-QUIET: 99 is a magic number;
+
+int main() {
+  int x = 42;
+}

>From 76dc88ad3f35b4edd38e14c5ef9daa6fa9e37cfd Mon Sep 17 00:00:00 2001
From: Baranov Victor <bar.victor.2...@gmail.com>
Date: Thu, 4 Sep 2025 11:19:36 +0300
Subject: [PATCH 2/2] Update clang-tools-extra/docs/ReleaseNotes.rst

Co-authored-by: Victor Chernyakin <chernyakin.victo...@outlook.com>
---
 clang-tools-extra/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index deb6439985eee..e8d61ed3e7890 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -136,7 +136,7 @@ Improvements to clang-tidy
   same name instead.
 
 - Improved :program:`run-clang-tidy.py` and :program:`clang-tidy-diff.py` 
-  scripts by adding the `-hide-progress` option to suppressing progress and
+  scripts by adding the `-hide-progress` option to suppress progress and
   informational messages.
 
 New checks

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to