This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Improved renamer check logic
Needs ReviewPublic

Authored by njames93 on Feb 25 2020, 12:08 PM.

Details

Summary

Factored out some similar code in add_new_check.py and rename_check.py.
Made rename_check.py less error prone by targetting string replacements
Haven't linted the code as that is a can of worms given the 100+ different style options currently used in the python files

Diff Detail

Event Timeline

njames93 created this revision.Feb 25 2020, 12:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2020, 12:08 PM
njames93 updated this revision to Diff 246534.Feb 25 2020, 12:11 PM
  • Remove unnecessary debug print

It'll be reasonable to have script to create check alias, but this could be made in separate patch.

clang-tools-extra/clang-tidy/add_new_check.py
18

It's better to use import utils.modify_check. See Flake8.

153

Double line spacing may be intentional. For example, Flake8 enforces such rules.

clang-tools-extra/clang-tidy/rename_check.py
15

It's better to use import utils.modify_check. See Flake8.

111

It's better to open files with with operator. Same in other places.

njames93 updated this revision to Diff 246610.Feb 25 2020, 5:45 PM
  • Linted entire checks and moved more code into common module

It'll be reasonable to find out what are naming conventions for Python in LLVM.

Feel free to apply this and see how it works. Tested with checks that have alias variants which seem to respond well. Renaming a check then renaming it back reverts the state to how it was before apart from release notes and maybe some non standard comments

It'll be reasonable to find out what are naming conventions for Python in LLVM.

I just stuck to the trusty old c++ naming conventions. Having a look I see most of it is using lower_case for all identifiers but then in there are always failures in the files along with that

njames93 updated this revision to Diff 246614.Feb 25 2020, 6:11 PM
  • Fix typo
Harbormaster completed remote builds in B47266: Diff 246614.
njames93 updated this revision to Diff 246650.Feb 26 2020, 1:50 AM
  • Changed naming to what appears to be llvm python style
njames93 updated this revision to Diff 246653.Feb 26 2020, 2:21 AM
  • Moved shared code into init