Skip to content

Commit

Permalink
[clang-tidy] Improve rename_check.py
Browse files Browse the repository at this point in the history
rename_check.py now find and renames the test file. rename_check.py
also will now use 'git mv', so the developer no longer has to manually
add the file after running the script.

Reviewed By: carlosgalvezp

Differential Revision: https://reviews.llvm.org/D141463
  • Loading branch information
ccotter authored and carlosgalvezp committed Jan 23, 2023
1 parent 4718da5 commit 7718422
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions clang-tools-extra/clang-tidy/rename_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,9 @@ def deleteMatchingLines(fileName, pattern):


def getListOfFiles(clang_tidy_path):
files = glob.glob(os.path.join(clang_tidy_path, '*'))
for dirname in files:
if os.path.isdir(dirname):
files += glob.glob(os.path.join(dirname, '*'))
files = glob.glob(os.path.join(clang_tidy_path, '**'), recursive=True)
files += glob.glob(os.path.join(clang_tidy_path, '..', 'test',
'clang-tidy', '*'))
'clang-tidy', 'checkers', '**'), recursive=True)
files += glob.glob(os.path.join(clang_tidy_path, '..', 'docs',
'clang-tidy', 'checks', '*'))
return [filename for filename in files if os.path.isfile(filename)]
Expand Down Expand Up @@ -273,10 +270,12 @@ def main():
deleteMatchingLines(os.path.join(old_module_path, modulecpp),
'\\b' + check_name_camel + '|\\b' + args.old_check_name)

old_check_filename = '-'.join(args.old_check_name.split('-')[1:])
new_check_filename = '-'.join(args.new_check_name.split('-')[1:])

for filename in getListOfFiles(clang_tidy_path):
originalName = filename
filename = fileRename(filename, args.old_check_name,
args.new_check_name)
filename = fileRename(filename, old_check_filename, new_check_filename)
filename = fileRename(filename, check_name_camel, new_check_name_camel)
replaceInFile(filename, generateCommentLineHeader(originalName),
generateCommentLineHeader(filename))
Expand Down

0 comments on commit 7718422

Please sign in to comment.