https://github.com/duddel updated https://github.com/llvm/llvm-project/pull/82416
>From a3596bf357ef991abcaef04f8811958c0984d9f6 Mon Sep 17 00:00:00 2001 From: duddel <dud...@users.noreply.github.com> Date: Tue, 20 Feb 2024 21:11:26 +0100 Subject: [PATCH 1/3] add -source-ignore option to run-clang-tidy.py --- .../clang-tidy/tool/run-clang-tidy.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 70f8cbcdcb2f11..ba4314dfb50aa1 100755 --- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py @@ -300,6 +300,12 @@ def main(): "the main file of each translation unit are always " "displayed.", ) + parser.add_argument( + "-source-ignore", + default=None, + help="Regular expression matching the names of the " + "source files from compilation database to ignore.", + ) parser.add_argument( "-line-filter", default=None, @@ -462,6 +468,15 @@ def main(): [make_absolute(entry["file"], entry["directory"]) for entry in database] ) + # Remove source file to be ignored from database. + if args.source_ignore: + try: + source_ignore_re = re.compile(args.source_ignore) + except: + print("Error: unable to compile regex from arg -source-ignore.", file=sys.stderr) + sys.exit(1) + files = {f for f in files if not source_ignore_re.match(f)} + max_task = args.j if max_task == 0: max_task = multiprocessing.cpu_count() >From 6c8cf48bd8ad36ec0e5740eb105742df3f2b60a6 Mon Sep 17 00:00:00 2001 From: duddel <dud...@users.noreply.github.com> Date: Tue, 20 Feb 2024 21:42:03 +0100 Subject: [PATCH 2/3] Apply suggested python code formatting --- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 ba4314dfb50aa1..66465ba78289d9 100755 --- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py @@ -473,7 +473,10 @@ def main(): try: source_ignore_re = re.compile(args.source_ignore) except: - print("Error: unable to compile regex from arg -source-ignore.", file=sys.stderr) + print( + "Error: unable to compile regex from arg -source-ignore.", + file=sys.stderr, + ) sys.exit(1) files = {f for f in files if not source_ignore_re.match(f)} >From 7e53d55063aedfb3507f45a13cd8f44a7d339e5f Mon Sep 17 00:00:00 2001 From: duddel <dud...@users.noreply.github.com> Date: Wed, 21 Feb 2024 17:27:53 +0100 Subject: [PATCH 3/3] change -source-ignore to -source-filter option in run-clang-tidy.py --- .../clang-tidy/tool/run-clang-tidy.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 66465ba78289d9..584ef41f19c4b9 100755 --- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py @@ -301,10 +301,11 @@ def main(): "displayed.", ) parser.add_argument( - "-source-ignore", + "-source-filter", default=None, help="Regular expression matching the names of the " - "source files from compilation database to ignore.", + "source files from compilation database to output " + "diagnostics from.", ) parser.add_argument( "-line-filter", @@ -468,17 +469,17 @@ def main(): [make_absolute(entry["file"], entry["directory"]) for entry in database] ) - # Remove source file to be ignored from database. - if args.source_ignore: + # Filter source files from compilation database. + if args.source_filter: try: - source_ignore_re = re.compile(args.source_ignore) + source_filter_re = re.compile(args.source_filter) except: print( - "Error: unable to compile regex from arg -source-ignore.", + "Error: unable to compile regex from arg -source-filter.", file=sys.stderr, ) sys.exit(1) - files = {f for f in files if not source_ignore_re.match(f)} + files = {f for f in files if source_filter_re.match(f)} max_task = args.j if max_task == 0: _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits