Skip to content
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

Feature request: add a mechanism to filter in/out source files #64

Open
ghost opened this issue Apr 16, 2024 · 2 comments
Open

Feature request: add a mechanism to filter in/out source files #64

ghost opened this issue Apr 16, 2024 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 16, 2024

When integrating this tool off-the-shelf with our build system, it has a curious problem: it tries to run clang-tidy for each of the #include-d files from our system. We do have an exclude filter in the clang tidy config itself, but that applies after clang-tidy itself runs. As a result, clang-tidy runs tens of thousands of times (once for each #include), which breaks the system.

To get around this, I added a (admittedly hacky) company-specific inclusion logic (see this PR). It works, but it's not very elegant.

Could you consider adding some kind of mechanism for the user to specify inclusion/exclusion criteria for source files? I'm exploring how to configure an aspect; if I write a PR that adds some kind of clang_tidy_source_must_include_substring option, are you amenable to adding that to the repo?

@erenon
Copy link
Owner

erenon commented Apr 16, 2024

Hi, thanks for the report. Please share:

  • Your bazel_clang_tidy commit id (make sure you are using the latest)
  • Your .clang-tidy config
  • An example bazel target, that reproduces the issue.

@ghost
Copy link
Author

ghost commented Apr 17, 2024

Your bazel_clang_tidy commit id (make sure you are using the latest)

https://github.com/stevegrossmongodb/bazel_clang_tidy_fork/commit/343245bc6156d9dd61cd8583f9c70eb9b0c06f75

Your .clang-tidy config

https://pastebin.com/bfxCV114

An example bazel target, that reproduces the issue.

To reproduce:

  1. clone https://github.com/mongodb/mongo (master branch at revision e89e0a0631bbdacb74882d73bf6b2514fb5619cb)
  2. Apply these diffs: https://pastebin.com/sd6PnmMU
  3. Copy the .clang-tidy noted above to the root directory of the workspace
  4. Run: bazel build src/mongo/db/commands:fsync_locked_with_debug --aspects @bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect --output_groups=report --@bazel_clang_tidy//:clang_tidy_config=//:clang_tidy_config --config=local

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant