https://github.com/edunad created https://github.com/llvm/llvm-project/pull/89302
Similar to https://github.com/llvm/llvm-project/pull/82416, but it allows you to filter full directories without the need of a complex regex in `-source-filter` For example: ``` python run-clang-tidy.py -fix -p \"build\" -j 12 -directory-filter build -directory-filter bin -directory-filter tests ``` To filter out `bin`, `build` and `tests` folders >From 62e47d8b629bd7fff4e7dc9c4ec21bedab142832 Mon Sep 17 00:00:00 2001 From: FailCake <edu...@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:24:56 +0200 Subject: [PATCH] Adds -directory-filter option to run-clang-tidy.py --- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py | 11 ++++++++++- 1 file changed, 10 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 1bd4a5b283091c..4ef9b0a8ebf5e2 100755 --- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py @@ -307,6 +307,14 @@ def main(): "source files from compilation database to output " "diagnostics from.", ) + parser.add_argument( + "-directory-filter", + dest="directory_filter", + action="append", + default=[], + help="List of directories matching the names of the " + "compilation database to filter.", + ) parser.add_argument( "-line-filter", default=None, @@ -488,6 +496,7 @@ def main(): # Build up a big regexy filter from all command line arguments. file_name_re = re.compile("|".join(args.files)) + directory_filters_re = re.compile("|".join(args.directory_filters)) return_code = 0 try: @@ -514,7 +523,7 @@ def main(): # Fill the queue with files. for name in files: - if file_name_re.search(name): + if file_name_re.search(name) and not directory_filters_re.search(name): task_queue.put(name) # Wait for all threads to be done. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits