[clang-tools-extra] r318971 - [clang-tidy] Actually fix header guard handling in scripts

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 25 00:49:05 PST 2017


Author: alexfh
Date: Sat Nov 25 00:49:04 2017
New Revision: 318971

URL: http://llvm.org/viewvc/llvm-project?rev=318971&view=rev
Log:
[clang-tidy] Actually fix header guard handling in scripts

Modified:
    clang-tools-extra/trunk/clang-tidy/add_new_check.py
    clang-tools-extra/trunk/clang-tidy/rename_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=318971&r1=318970&r2=318971&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Sat Nov 25 00:49:04 2017
@@ -51,7 +51,7 @@ def write_header(module_path, module, ch
   print('Creating %s...' % filename)
   with open(filename, 'wb') as f:
     header_guard = ('LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_' + module.upper() + '_'
-                    + check_name.upper().replace('-', '_') + '_H')
+                    + check_name_camel.upper() + '_H')
     f.write('//===--- ')
     f.write(os.path.basename(filename))
     f.write(' - clang-tidy')

Modified: clang-tools-extra/trunk/clang-tidy/rename_check.py
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/rename_check.py?rev=318971&r1=318970&r2=318971&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/rename_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/rename_check.py Sat Nov 25 00:49:04 2017
@@ -196,7 +196,9 @@ def main():
 
   clang_tidy_path = os.path.dirname(__file__)
 
-  header_guard_old = (old_module + '_' + check_name_camel).upper()
+  header_guard_variants = [
+      (old_module + '_' + new_check_name_camel).upper(),
+      args.old_check_name.replace('-', '_').upper()]
   header_guard_new = (new_module + '_' + new_check_name_camel).upper()
 
   old_module_path = os.path.join(clang_tidy_path, old_module)
@@ -225,7 +227,8 @@ def main():
                   generateCommentLineHeader(filename))
     replaceInFile(filename, generateCommentLineSource(originalName),
                   generateCommentLineSource(filename))
-    replaceInFile(filename, header_guard_old, header_guard_new)
+    for header_guard in header_guard_variants:
+      replaceInFile(filename, header_guard, header_guard_new)
 
     if args.new_check_name + '.rst' in filename:
       replaceInFile(




More information about the cfe-commits mailing list