Skip to content

[run-clang-tidy.py] Add -directory-filter option to run-clang-tidy.py #89302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ def main():
"source files from compilation database to output "
"diagnostics from.",
)
parser.add_argument(
"-directory-filter",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this basically work opposite to -source-filter, specially because it work on full path, not just on directory path.
Therefore I could filter out with this an file also, not only directory.

For me this option is just an negative source-filter, and as you can do negative regexp in python, i do not see a reason for it.

Specially that for what this option describes there is already this:

    parser.add_argument(
        "files", nargs="*", default=[".*"], help="files to be processed (regex on path)"
    )

dest="directory_filter",
action="append",
default=[],
help="List of directories matching the names of the "
"compilation database to filter.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter in, or filter out ?

Comment on lines +315 to +316
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use regexp instead of list of directories

)
parser.add_argument(
"-line-filter",
default=None,
Expand Down Expand Up @@ -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:
Expand All @@ -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):
Comment on lines -517 to +526
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be honest those lines should be handled like current filtering in line 491

task_queue.put(name)

# Wait for all threads to be done.
Expand Down