[clang-tools-extra] r348793 - [clang-tidy] insert release notes for new checkers alphabetically

Jonas Toth via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 10 11:41:53 PST 2018


Author: jonastoth
Date: Mon Dec 10 11:41:53 2018
New Revision: 348793

URL: http://llvm.org/viewvc/llvm-project?rev=348793&view=rev
Log:
[clang-tidy]  insert release notes for new checkers alphabetically

Summary:
Almost all code review comments on new checkers {D55433} {D48866} {D54349} seem to ask for the release notes to be added alphabetically, plus I've seen commits by @Eugene.Zelenko reordering the lists

Make add_new_check.py add those release notes alphabetically based on checker name

If include-fixer section is seen add it at the end

Minor change in the message format to prevent double newlines added before the checker.

Do the tools themselves have unit tests? (sorry new to this game)

- Tested adding new checker at the beginning
- Tested on adding new checker in the middle
- Tested on empty ReleasesNotes.rst (as we would see after RC)

Patch by MyDeveloperDay.

Reviewers: alexfh, JonasToth, curdeius, aaron.ballman, benhamilton, hokein

Reviewed By: JonasToth

Subscribers: cfe-commits, xazax.hun, Eugene.Zelenko

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55508

Modified:
    clang-tools-extra/trunk/clang-tidy/add_new_check.py

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=348793&r1=348792&r2=348793&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Mon Dec 10 11:41:53 2018
@@ -200,23 +200,47 @@ def add_release_notes(module_path, modul
   with open(filename, 'r') as f:
     lines = f.readlines()
 
+  lineMatcher = re.compile('Improvements to clang-tidy')
+  nextSectionMatcher = re.compile('Improvements to include-fixer')
+  checkerMatcher = re.compile('- New :doc:`(.*)')
+
   print('Updating %s...' % filename)
   with open(filename, 'w') 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('Improvements to clang-tidy', line)
+        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:
+            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("""
-- New :doc:`%s
+            f.write("""- New :doc:`%s
   <clang-tidy/checks/%s>` check.
 
   FIXME: add release notes.
+
 """ % (check_name_dashes, check_name_dashes))
             note_added = True
 




More information about the cfe-commits mailing list