Skip to content

Commit

Permalink
[clang-tidy] rename_check.py: maintain alphabetical order in Renamed …
Browse files Browse the repository at this point in the history
…checks section

Summary:
Also use //check// in add_new_check.py for terminology consistency.

PS

My GitHub ID is [[ https://github.com/EugeneZelenko | EugeneZelenko ]], if it's necessary for attribution.

Reviewers: alexfh, hokein, aaron.ballman, njames93, MyDeveloperDay

Reviewed By: njames93

Subscribers: Andi, xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D73580
  • Loading branch information
EugeneZelenko authored and njames93 committed Feb 20, 2020
1 parent 092a57f commit db8911a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
10 changes: 5 additions & 5 deletions clang-tools-extra/clang-tidy/add_new_check.py
Expand Up @@ -221,7 +221,7 @@ def add_release_notes(module_path, module, check_name):

lineMatcher = re.compile('New checks')
nextSectionMatcher = re.compile('New check aliases')
checkerMatcher = re.compile('- New :doc:`(.*)')
checkMatcher = re.compile('- New :doc:`(.*)')

print('Updating %s...' % filename)
with open(filename, 'w') as f:
Expand All @@ -234,10 +234,10 @@ def add_release_notes(module_path, module, check_name):
if not note_added:
match = lineMatcher.match(line)
match_next = nextSectionMatcher.match(line)
match_checker = checkerMatcher.match(line)
if match_checker:
last_checker = match_checker.group(1)
if last_checker > check_name_dashes:
match_check = checkMatcher.match(line)
if match_check:
last_check = match_check.group(1)
if last_check > check_name_dashes:
add_note_here = True

if match_next:
Expand Down
32 changes: 28 additions & 4 deletions clang-tools-extra/clang-tidy/rename_check.py
Expand Up @@ -169,21 +169,45 @@ def add_release_notes(clang_tidy_path, old_check_name, new_check_name):
with open(filename, 'r') as f:
lines = f.readlines()

lineMatcher = re.compile('Renamed checks')
nextSectionMatcher = re.compile('Improvements to include-fixer')
checkMatcher = re.compile('- The \'(.*)')

print('Updating %s...' % filename)
with open(filename, 'wb') as f:
note_added = False
header_found = False
next_header_found = False
add_note_here = False

for line in lines:
if not note_added:
match = re.search('Renamed checks', line)
match = lineMatcher.match(line)
match_next = nextSectionMatcher.match(line)
match_check = checkMatcher.match(line)
if match_check:
last_check = match_check.group(1)
if last_check > old_check_name:
add_note_here = True

if match_next:
next_header_found = True
add_note_here = True

if match:
header_found = True
elif header_found:
f.write(line)
continue

if line.startswith('^^^^'):
f.write(line)
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))
note_added = True

Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/docs/ReleaseNotes.rst
Expand Up @@ -128,7 +128,6 @@ Changes in existing checks
Renamed checks
^^^^^^^^^^^^^^


Improvements to include-fixer
-----------------------------

Expand Down

0 comments on commit db8911a

Please sign in to comment.