Page MenuHomePhabricator

[clang-tidy] For `run-clang-tidy.py` escape the paths that are used for analysis.
AbandonedPublic

Authored by Abpostelnicu on Jun 16 2020, 2:22 AM.

Details

Summary

Some paths can have special chars like file++c.cpp in this case the regex will fail if we don't escape it.

Diff Detail

Event Timeline

Abpostelnicu created this revision.Jun 16 2020, 2:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2020, 2:22 AM
Abpostelnicu edited reviewers, added: JonasToth; removed: sylvestre.ledru.Jun 16 2020, 2:33 AM
This revision was not accepted when it landed; it landed in state Needs Review.Jun 16 2020, 2:43 AM
This revision was automatically updated to reflect the committed changes.
Abpostelnicu reopened this revision.Jun 16 2020, 2:45 AM
Eugene.Zelenko added a project: Restricted Project.
njames93 accepted this revision.Jun 27 2020, 3:04 AM

Looks good

This revision is now accepted and ready to land.Jun 27 2020, 3:04 AM
njames93 closed this revision.Jun 27 2020, 3:04 AM

Based on https://bugs.llvm.org/show_bug.cgi?id=46536 I've reverted this as it renders the core feature of the script as unusable (using .* to run over entire database)

njames93 reopened this revision.Jul 2 2020, 12:59 AM
This revision is now accepted and ready to land.Jul 2 2020, 12:59 AM
njames93 requested changes to this revision.Jul 2 2020, 12:59 AM
This revision now requires changes to proceed.Jul 2 2020, 12:59 AM
Abpostelnicu added a comment.EditedJul 2 2020, 2:36 AM

@njames93 wdyt if we add another parameter to distinguish if we want to use regex or not, and if not we escape the paths?
Also thank you so much for catching this up!

@njames93 wdyt if we add another parameter to distinguish if we want to use regex or not, and if not we escape the paths?
Also thank you so much for catching this up!

As the argument is documented as being a regex string, we shouldn't really try to escape it, and users should be expected escape any file names themselves before invoking the script.
If for whatever reason you want to use .c++ as your file extension. then you should pass r'*\.c\+\+' to the script.

Can I ask what the specific use case you have that is causing the issue? Are you invoking run-clang-tidy from a script that generates the list of files to search for?

@njames93 wdyt if we add another parameter to distinguish if we want to use regex or not, and if not we escape the paths?
Also thank you so much for catching this up!

As the argument is documented as being a regex string, we shouldn't really try to escape it, and users should be expected escape any file names themselves before invoking the script.
If for whatever reason you want to use .c++ as your file extension. then you should pass r'*\.c\+\+' to the script.

Can I ask what the specific use case you have that is causing the issue? Are you invoking run-clang-tidy from a script that generates the list of files to search for?

Thank you for the detailed reply! we are using this script in automation and some files from our repo indeed need to be escaped. I think it makes sense what you are saying to give to the consumer the files already escaped. I'm going to close this issue.

Abpostelnicu abandoned this revision.Jul 2 2020, 5:04 AM