aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra
diff options
context:
space:
mode:
authorAlexander Scholz <duddel@users.noreply.github.com>2024-02-25 17:42:57 +0100
committerGitHub <noreply@github.com>2024-02-25 17:42:57 +0100
commit8dfc023e80c35aded33b3e5e4739d3a487b95a7a (patch)
tree517322de29f8fda5af022e73cd48af67e67caa7f /clang-tools-extra
parent411c5dde59fa4c427941143ca0ec8cd8fdaee407 (diff)
downloadllvm-8dfc023e80c35aded33b3e5e4739d3a487b95a7a.zip
llvm-8dfc023e80c35aded33b3e5e4739d3a487b95a7a.tar.gz
llvm-8dfc023e80c35aded33b3e5e4739d3a487b95a7a.tar.bz2
[run-clang-tidy.py] Add option to ignore source files from compilation database (#82416)
I added the option -source-filter to the `run-clang-tidy.py` script in the clang-tools-extra. This option allows for handing over a regex, to filter out source files from the compilation database (not run `clang-tidy` on them).
Diffstat (limited to 'clang-tools-extra')
-rwxr-xr-xclang-tools-extra/clang-tidy/tool/run-clang-tidy.py20
-rw-r--r--clang-tools-extra/docs/ReleaseNotes.rst4
2 files changed, 24 insertions, 0 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 70f8cbc..1bd4a5b 100755
--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -301,6 +301,13 @@ def main():
"displayed.",
)
parser.add_argument(
+ "-source-filter",
+ default=None,
+ help="Regular expression matching the names of the "
+ "source files from compilation database to output "
+ "diagnostics from.",
+ )
+ parser.add_argument(
"-line-filter",
default=None,
help="List of files with line ranges to filter the warnings.",
@@ -462,6 +469,19 @@ def main():
[make_absolute(entry["file"], entry["directory"]) for entry in database]
)
+ # Filter source files from compilation database.
+ if args.source_filter:
+ try:
+ source_filter_re = re.compile(args.source_filter)
+ except:
+ print(
+ "Error: unable to compile regex from arg -source-filter:",
+ file=sys.stderr,
+ )
+ traceback.print_exc()
+ sys.exit(1)
+ files = {f for f in files if source_filter_re.match(f)}
+
max_task = args.j
if max_task == 0:
max_task = multiprocessing.cpu_count()
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index a0b9fcf..6fd01ed 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -97,6 +97,10 @@ The improvements are...
Improvements to clang-tidy
--------------------------
+- Improved :program:`run-clang-tidy.py` script. Added argument `-source-filter`
+ to filter source files from the compilation database, via a RegEx. In a
+ similar fashion to what `-header-filter` does for header files.
+
New checks
^^^^^^^^^^