Author: Eugene Zelenko
Date: 2020-02-20T17:31:08Z
New Revision: db8911aad726d050fb36f17f2978bd35f69165cc

URL: 
https://github.com/llvm/llvm-project/commit/db8911aad726d050fb36f17f2978bd35f69165cc
DIFF: 
https://github.com/llvm/llvm-project/commit/db8911aad726d050fb36f17f2978bd35f69165cc.diff

LOG: [clang-tidy] rename_check.py: maintain alphabetical order in Renamed 
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

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/add_new_check.py
    clang-tools-extra/clang-tidy/rename_check.py
    clang-tools-extra/docs/ReleaseNotes.rst

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/add_new_check.py 
b/clang-tools-extra/clang-tidy/add_new_check.py
index 1ef7165a12c9..22aadd612d70 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -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:
@@ -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:

diff  --git a/clang-tools-extra/clang-tidy/rename_check.py 
b/clang-tools-extra/clang-tidy/rename_check.py
index 2dde9734ed54..528c2a19a2b7 100755
--- a/clang-tools-extra/clang-tidy/rename_check.py
+++ b/clang-tools-extra/clang-tidy/rename_check.py
@@ -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
 

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index dd30f66778a3..0350962c5c86 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -128,7 +128,6 @@ Changes in existing checks
 Renamed checks
 ^^^^^^^^^^^^^^
 
-
 Improvements to include-fixer
 -----------------------------
 


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to