aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2020-12-01 19:50:56 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2020-12-01 20:10:19 +0300
commitae7ec47fc655537ce82c0bfee0b587921663eaff (patch)
treebb55d54b4fa12bd63f50ba2feba5cce3cc5d0f88
parentclang/darwin: Use response files with ld64.lld.darwinnew (diff)
downloadllvm-project-ae7ec47fc655537ce82c0bfee0b587921663eaff.tar.gz
llvm-project-ae7ec47fc655537ce82c0bfee0b587921663eaff.tar.bz2
llvm-project-ae7ec47fc655537ce82c0bfee0b587921663eaff.zip
[NFC][clang-tidy] Port rename_check.py to Python3
-rwxr-xr-xclang-tools-extra/clang-tidy/rename_check.py31
1 files changed, 15 insertions, 16 deletions
diff --git a/clang-tools-extra/clang-tidy/rename_check.py b/clang-tools-extra/clang-tidy/rename_check.py
index 4d5311c9a293..2410041fd5d2 100755
--- a/clang-tools-extra/clang-tidy/rename_check.py
+++ b/clang-tools-extra/clang-tidy/rename_check.py
@@ -120,16 +120,15 @@ def adapt_cmake(module_path, check_name_camel):
if (not file_added) and (cpp_line or cpp_found):
cpp_found = True
if (line.strip() > cpp_file) or (not cpp_line):
- f.write(' ' + cpp_file + '\n')
+ f.write((' ' + cpp_file + '\n').encode())
file_added = True
- f.write(line)
+ f.write(line.encode())
return True
# Modifies the module to include the new check.
def adapt_module(module_path, module, check_name, check_name_camel):
- modulecpp = filter(lambda p: p.lower() == module.lower() + 'tidymodule.cpp',
- os.listdir(module_path))[0]
+ modulecpp = next(filter(lambda p: p.lower() == module.lower() + 'tidymodule.cpp', os.listdir(module_path)))
filename = os.path.join(module_path, modulecpp)
with open(filename, 'r') as f:
lines = f.readlines()
@@ -149,21 +148,21 @@ def adapt_module(module_path, module, check_name, check_name_camel):
header_found = True
if match.group(1) > check_name_camel:
header_added = True
- f.write('#include "' + check_name_camel + '.h"\n')
+ f.write(('#include "' + check_name_camel + '.h"\n').encode())
elif header_found:
header_added = True
- f.write('#include "' + check_name_camel + '.h"\n')
+ f.write(('#include "' + check_name_camel + '.h"\n').encode())
if not check_added:
if line.strip() == '}':
check_added = True
- f.write(check_decl)
+ f.write(check_decl.encode())
else:
match = re.search('registerCheck<(.*)>', line)
if match and match.group(1) > check_name_camel:
check_added = True
- f.write(check_decl)
- f.write(line)
+ f.write(check_decl.encode())
+ f.write(line.encode())
# Adds a release notes entry.
@@ -198,22 +197,22 @@ def add_release_notes(clang_tidy_path, old_check_name, new_check_name):
if match:
header_found = True
- f.write(line)
+ f.write(line.encode())
continue
if line.startswith('^^^^'):
- f.write(line)
+ f.write(line.encode())
continue
if header_found and add_note_here:
if not line.startswith('^^^^'):
- f.write("""- The '%s' check was renamed to :doc:`%s
+ f.write(("""- The '%s' check was renamed to :doc:`%s
<clang-tidy/checks/%s>`
-""" % (old_check_name, new_check_name, new_check_name))
+""" % (old_check_name, new_check_name, new_check_name)).encode())
note_added = True
- f.write(line)
+ f.write(line.encode())
def main():
parser = argparse.ArgumentParser(description='Rename clang-tidy check.')
@@ -259,9 +258,9 @@ def main():
(check_name_camel, cmake_lists))
return 1
- modulecpp = filter(
+ modulecpp = next(filter(
lambda p: p.lower() == old_module.lower() + 'tidymodule.cpp',
- os.listdir(old_module_path))[0]
+ os.listdir(old_module_path)))
deleteMatchingLines(os.path.join(old_module_path, modulecpp),
'\\b' + check_name_camel + '|\\b' + args.old_check_name)