[PATCH] D66505: Make add_new_check.py's insertion of registerCheck<> match the sort order
Daniel Sanders via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 30 13:46:16 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370527: Make add_new_check.py's insertion of registerCheck<> match the sort order (authored by dsanders, committed by ).
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D66505?vs=218137&id=218163#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66505/new/
https://reviews.llvm.org/D66505
Files:
clang-tools-extra/trunk/clang-tidy/add_new_check.py
Index: clang-tools-extra/trunk/clang-tidy/add_new_check.py
===================================================================
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py
@@ -165,31 +165,50 @@
header_added = False
header_found = False
check_added = False
+ check_fq_name = module + '-' + check_name
check_decl = (' CheckFactories.registerCheck<' + check_name_camel +
- '>(\n "' + module + '-' + check_name + '");\n')
+ '>(\n "' + check_fq_name + '");\n')
- for line in lines:
- if not header_added:
- match = re.search('#include "(.*)"', line)
- if match:
- header_found = True
- if match.group(1) > check_name_camel:
+ lines = iter(lines)
+ try:
+ while True:
+ line = lines.next()
+ if not header_added:
+ match = re.search('#include "(.*)"', line)
+ if match:
+ header_found = True
+ if match.group(1) > check_name_camel:
+ header_added = True
+ f.write('#include "' + check_name_camel + '.h"\n')
+ elif header_found:
header_added = True
f.write('#include "' + check_name_camel + '.h"\n')
- elif header_found:
- header_added = True
- f.write('#include "' + check_name_camel + '.h"\n')
-
- if not check_added:
- if line.strip() == '}':
- check_added = True
- f.write(check_decl)
- else:
- match = re.search('registerCheck<(.*)>', line)
- if match and match.group(1) > check_name_camel:
+
+ if not check_added:
+ if line.strip() == '}':
check_added = True
f.write(check_decl)
- f.write(line)
+ else:
+ match = re.search('registerCheck<(.*)> *\( *(?:"([^"]*)")?', line)
+ prev_line = None
+ if match:
+ current_check_name = match.group(2)
+ if current_check_name is None:
+ # If we didn't find the check name on this line, look on the
+ # next one.
+ prev_line = line
+ line = lines.next()
+ match = re.search(' *"([^"]*)"', line)
+ if match:
+ current_check_name = match.group(1)
+ if current_check_name > check_fq_name:
+ check_added = True
+ f.write(check_decl)
+ if prev_line:
+ f.write(prev_line)
+ f.write(line)
+ except StopIteration:
+ pass
# Adds a release notes entry.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66505.218163.patch
Type: text/x-patch
Size: 2682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190830/c60eb306/attachment-0001.bin>
More information about the cfe-commits
mailing list