[clang-tidy] RFC: Need feedback on enhancing run-clang-tidy.py to accept and pass @response_files on to clang-tidy

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[clang-tidy] RFC: Need feedback on enhancing run-clang-tidy.py to accept and pass @response_files on to clang-tidy

Nathan Ridge via cfe-dev
I'd like to drive run-clang-tidy.py from a git custom command, e.g.:

  $ git clang-tidy <commit> [-fix-errors] [etc...]

And pass the all the files in the diff, with headers going in '-header-filter='.  This works great for small diffs -- I'm using `git diff -name-only` under the hood to get the list of files -- but large diffs will inevitably generate extremely long command lines.

Since clang-tidy can read @response-files, I figure I could just create my super long command line and pass it through, which would require a small change to run-clang-tidy.py.  run-clang-tidy.py could then create individual @respone-files for each clang-tidy instance as needed -- in case the number of headers is large.  To work, each instance would need the complete list of headers in the diff.

But, before I go off and start hacking it up, I just wanted to see if anyone had a better idea.  I guess I'll have the pass the file name to python as just a regular option, since the @file notation doesn't seem to be present, but I'm no python expert.

Btw, I have a working prototype, loosely based on git-clang-format, which can call either clang-tidy directly in a loop, or pass the entire list to run-clang-tidy.py which can do it in parallel.

thanks...
don

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: [clang-tidy] RFC: Need feedback on enhancing run-clang-tidy.py to accept and pass @response_files on to clang-tidy

Nathan Ridge via cfe-dev
Btw, the motivation for this custom command is to make it easy to apply a set of clang-tidy checks to just the files in your change set, and no others.

Obviously, checks that change symbol names wouldn't be appropriate for targeted sets like this, so I'm mainly looking to apply the current llvm* ones to start with.  And since it accepts a checks= argument and respects the .clang-tidy file, I'm hoping it will be generally useful.

On Thu, Jun 20, 2019 at 6:54 PM Don Hinton <[hidden email]> wrote:
I'd like to drive run-clang-tidy.py from a git custom command, e.g.:

  $ git clang-tidy <commit> [-fix-errors] [etc...]

And pass the all the files in the diff, with headers going in '-header-filter='.  This works great for small diffs -- I'm using `git diff -name-only` under the hood to get the list of files -- but large diffs will inevitably generate extremely long command lines.

Since clang-tidy can read @response-files, I figure I could just create my super long command line and pass it through, which would require a small change to run-clang-tidy.py.  run-clang-tidy.py could then create individual @respone-files for each clang-tidy instance as needed -- in case the number of headers is large.  To work, each instance would need the complete list of headers in the diff.

But, before I go off and start hacking it up, I just wanted to see if anyone had a better idea.  I guess I'll have the pass the file name to python as just a regular option, since the @file notation doesn't seem to be present, but I'm no python expert.

Btw, I have a working prototype, loosely based on git-clang-format, which can call either clang-tidy directly in a loop, or pass the entire list to run-clang-tidy.py which can do it in parallel.

thanks...
don

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: [clang-tidy] RFC: Need feedback on enhancing run-clang-tidy.py to accept and pass @response_files on to clang-tidy

Nathan Ridge via cfe-dev

Hey,

your task sounds like a "clang-tidy-diff.py" integration into git?

- https://github.com/llvm-mirror/clang-tools-extra/blob/master/clang-tidy/tool/clang-tidy-diff.py
- https://reviews.llvm.org/D57662 (parallelizing it was done as well).

Do you think that suits your needs?

Best Regards,
Jonas

Am 21.06.19 um 04:31 schrieb Don Hinton via cfe-dev:
Btw, the motivation for this custom command is to make it easy to apply a set of clang-tidy checks to just the files in your change set, and no others.

Obviously, checks that change symbol names wouldn't be appropriate for targeted sets like this, so I'm mainly looking to apply the current llvm* ones to start with.  And since it accepts a checks= argument and respects the .clang-tidy file, I'm hoping it will be generally useful.

On Thu, Jun 20, 2019 at 6:54 PM Don Hinton <[hidden email]> wrote:
I'd like to drive run-clang-tidy.py from a git custom command, e.g.:

  $ git clang-tidy <commit> [-fix-errors] [etc...]

And pass the all the files in the diff, with headers going in '-header-filter='.  This works great for small diffs -- I'm using `git diff -name-only` under the hood to get the list of files -- but large diffs will inevitably generate extremely long command lines.

Since clang-tidy can read @response-files, I figure I could just create my super long command line and pass it through, which would require a small change to run-clang-tidy.py.  run-clang-tidy.py could then create individual @respone-files for each clang-tidy instance as needed -- in case the number of headers is large.  To work, each instance would need the complete list of headers in the diff.

But, before I go off and start hacking it up, I just wanted to see if anyone had a better idea.  I guess I'll have the pass the file name to python as just a regular option, since the @file notation doesn't seem to be present, but I'm no python expert.

Btw, I have a working prototype, loosely based on git-clang-format, which can call either clang-tidy directly in a loop, or pass the entire list to run-clang-tidy.py which can do it in parallel.

thanks...
don

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: [clang-tidy] RFC: Need feedback on enhancing run-clang-tidy.py to accept and pass @response_files on to clang-tidy

Nathan Ridge via cfe-dev
Hi Jonas:

On Fri, Jun 21, 2019 at 2:07 AM Jonas Toth <[hidden email]> wrote:

Hey,

your task sounds like a "clang-tidy-diff.py" integration into git?

- https://github.com/llvm-mirror/clang-tools-extra/blob/master/clang-tidy/tool/clang-tidy-diff.py
- https://reviews.llvm.org/D57662 (parallelizing it was done as well).

Do you think that suits your needs?

Thanks for the pointer.  It's close, and I like that it runs with any diff, not just git.

However, it has a few issues:

 - doesn't run on headers, even if they are in the diff, unless your .clang-tidy file has "HeaderFilterRegex: '.*'" or something similar
 - missing option to run clang-format over changes lines
 - line filter means that it only runs on the changed lines

The line filter prevents parallel instances of clang-tidy from changing the same header multiple times, but limits its usefulness.

My goal is to run the checks over entire files in the change set, so leveraging run-clang-tidy.py seems like a better option.  Here's the workflow I had in mind:

 - Create a change set, e.g., via phab
 - commit and push the accepted change, then
 - run the llvm* checks over the files in the change set as a separate commit and push

Performing the last step in a server side hook, would be optimal.

This may or may not be a workflow that clang/llvm wants, but I still think it's valid.

thanks again for the pointer...
don

Best Regards,
Jonas

Am 21.06.19 um 04:31 schrieb Don Hinton via cfe-dev:
Btw, the motivation for this custom command is to make it easy to apply a set of clang-tidy checks to just the files in your change set, and no others.

Obviously, checks that change symbol names wouldn't be appropriate for targeted sets like this, so I'm mainly looking to apply the current llvm* ones to start with.  And since it accepts a checks= argument and respects the .clang-tidy file, I'm hoping it will be generally useful.

On Thu, Jun 20, 2019 at 6:54 PM Don Hinton <[hidden email]> wrote:
I'd like to drive run-clang-tidy.py from a git custom command, e.g.:

  $ git clang-tidy <commit> [-fix-errors] [etc...]

And pass the all the files in the diff, with headers going in '-header-filter='.  This works great for small diffs -- I'm using `git diff -name-only` under the hood to get the list of files -- but large diffs will inevitably generate extremely long command lines.

Since clang-tidy can read @response-files, I figure I could just create my super long command line and pass it through, which would require a small change to run-clang-tidy.py.  run-clang-tidy.py could then create individual @respone-files for each clang-tidy instance as needed -- in case the number of headers is large.  To work, each instance would need the complete list of headers in the diff.

But, before I go off and start hacking it up, I just wanted to see if anyone had a better idea.  I guess I'll have the pass the file name to python as just a regular option, since the @file notation doesn't seem to be present, but I'm no python expert.

Btw, I have a working prototype, loosely based on git-clang-format, which can call either clang-tidy directly in a loop, or pass the entire list to run-clang-tidy.py which can do it in parallel.

thanks...
don

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev