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

Add ability to pass in a clang-tidy config file to clang-tidy-diff #75721

Closed
wants to merge 3 commits into from

Conversation

cjappl
Copy link
Contributor

@cjappl cjappl commented Dec 16, 2023

I found this handy for situations where you want to pass in a config file and not rely on a default .clang-tidy file.

The new option is -config and will expect something that can be passed into the --config-file= parameter of clang-tidy

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 16, 2023

@llvm/pr-subscribers-clang-tidy

Author: Chris Apple (cjappl)

Changes

I found this handy for situations where you want to pass in a config file and not rely on a default .clang-tidy file.

The new option is -config and will expect something that can be passed into the --config-file= parameter of clang-tidy


Full diff: https://github.com/llvm/llvm-project/pull/75721.diff

1 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py (+8)
diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index 8817e2914f6e25..fdaf1a4330e060 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -223,6 +223,12 @@ def main():
         default=[],
         help="Load the specified plugin in clang-tidy.",
     )
+    parser.add_argument(
+        "-config",
+        dest="config",
+        default=None,
+        help="Specifies a clang-tidy config file"
+    )
 
     clang_tidy_args = []
     argv = sys.argv[1:]
@@ -309,6 +315,8 @@ def main():
 
     # Form the common args list.
     common_clang_tidy_args = []
+    if args.config is not None:
+        common_clang_tidy_args.append("--config-file=" + args.config)
     if args.fix:
         common_clang_tidy_args.append("-fix")
     if args.checks != "":

@cjappl
Copy link
Contributor Author

cjappl commented Dec 16, 2023

@njames93 friendly ping for a review on this PR. Thank you in advance!

Copy link

github-actions bot commented Dec 16, 2023

:white_check_mark: With the latest revision this PR passed the Python code formatter.

@cjappl
Copy link
Contributor Author

cjappl commented Dec 17, 2023

This is almost exactly the same as #75457 , just with the release notes. I'm going to close this for now and re-open it if that one gets stale.

@cjappl cjappl closed this Dec 17, 2023
@cjappl cjappl deleted the clang-tidy-diff-pass-config branch March 13, 2024 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants