hokein updated this revision to Diff 195385.
hokein added a comment.

cleanup


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60776/new/

https://reviews.llvm.org/D60776

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py
  clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp


Index: clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
@@ -80,6 +80,7 @@
 using n::A; // A
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'A' is unused
 // CHECK-FIXES: {{^}}// A
+// CHECK-FIX-DESCRIPTIONS: :[[@LINE-3]]:10: note: remove the using
 using n::B;
 using n::C;
 using n::D;
Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===================================================================
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -90,10 +90,12 @@
   check_fixes_prefixes = []
   check_messages_prefixes = []
   check_notes_prefixes = []
+  check_fix_descriptions_prefixes = []
 
   has_check_fixes = False
   has_check_messages = False
   has_check_notes = False
+  has_check_fix_descriptions = False
 
   for check in args.check_suffix:
     if check and not re.match('^[A-Z0-9\-]+$', check):
@@ -104,26 +106,33 @@
     check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
     check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
     check_notes_prefix = 'CHECK-NOTES' + file_check_suffix
+    check_fix_descriptions_prefix = 'CHECK-FIX-DESCRIPTIONS' + 
file_check_suffix
 
     has_check_fix = check_fixes_prefix in input_text
     has_check_message = check_messages_prefix in input_text
     has_check_note = check_notes_prefix in input_text
+    has_check_fix_description = check_fix_descriptions_prefix in input_text
 
     if has_check_note and has_check_message:
       sys.exit('Please use either %s or %s but not both' %
         (check_notes_prefix, check_messages_prefix))
 
-    if not has_check_fix and not has_check_message and not has_check_note:
-      sys.exit('%s, %s or %s not found in the input' %
-        (check_fixes_prefix, check_messages_prefix, check_notes_prefix))
+    if not has_check_fix and not has_check_message and not has_check_note and \
+      not has_check_fix_description:
+      sys.exit('%s, %s, %s or %s not found in the input' %
+        (check_fixes_prefix, check_messages_prefix, check_notes_prefix,
+          check_fix_descriptions_prefix))
 
     has_check_fixes = has_check_fixes or has_check_fix
     has_check_messages = has_check_messages or has_check_message
     has_check_notes = has_check_notes or has_check_note
+    has_check_fix_descriptions = has_check_fix_descriptions or \
+      has_check_fix_description
 
     check_fixes_prefixes.append(check_fixes_prefix)
     check_messages_prefixes.append(check_messages_prefix)
     check_notes_prefixes.append(check_notes_prefix)
+    check_fix_descriptions_prefixes.append(check_fix_descriptions_prefix)
 
   assert has_check_fixes or has_check_messages or has_check_notes
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
@@ -175,6 +184,18 @@
       print('FileCheck failed:\n' + e.output.decode())
       raise
 
+  if has_check_fix_descriptions:
+    try:
+      fix_descriptions_file = temp_file_name + '.fix-descriptions'
+      write_file(fix_descriptions_file, clang_tidy_output)
+      subprocess.check_output(
+          ['FileCheck', '-input-file=' + fix_descriptions_file, 
input_file_name,
+           '-check-prefixes=' + ','.join(check_fix_descriptions_prefixes)],
+          stderr=subprocess.STDOUT)
+    except subprocess.CalledProcessError as e:
+      print('FileCheck failed:\n' + e.output.decode())
+      raise
+
   if has_check_messages:
     messages_file = temp_file_name + '.msg'
     write_file(messages_file, clang_tidy_output)


Index: clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
@@ -80,6 +80,7 @@
 using n::A; // A
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'A' is unused
 // CHECK-FIXES: {{^}}// A
+// CHECK-FIX-DESCRIPTIONS: :[[@LINE-3]]:10: note: remove the using
 using n::B;
 using n::C;
 using n::D;
Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===================================================================
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -90,10 +90,12 @@
   check_fixes_prefixes = []
   check_messages_prefixes = []
   check_notes_prefixes = []
+  check_fix_descriptions_prefixes = []
 
   has_check_fixes = False
   has_check_messages = False
   has_check_notes = False
+  has_check_fix_descriptions = False
 
   for check in args.check_suffix:
     if check and not re.match('^[A-Z0-9\-]+$', check):
@@ -104,26 +106,33 @@
     check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
     check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
     check_notes_prefix = 'CHECK-NOTES' + file_check_suffix
+    check_fix_descriptions_prefix = 'CHECK-FIX-DESCRIPTIONS' + file_check_suffix
 
     has_check_fix = check_fixes_prefix in input_text
     has_check_message = check_messages_prefix in input_text
     has_check_note = check_notes_prefix in input_text
+    has_check_fix_description = check_fix_descriptions_prefix in input_text
 
     if has_check_note and has_check_message:
       sys.exit('Please use either %s or %s but not both' %
         (check_notes_prefix, check_messages_prefix))
 
-    if not has_check_fix and not has_check_message and not has_check_note:
-      sys.exit('%s, %s or %s not found in the input' %
-        (check_fixes_prefix, check_messages_prefix, check_notes_prefix))
+    if not has_check_fix and not has_check_message and not has_check_note and \
+      not has_check_fix_description:
+      sys.exit('%s, %s, %s or %s not found in the input' %
+        (check_fixes_prefix, check_messages_prefix, check_notes_prefix,
+          check_fix_descriptions_prefix))
 
     has_check_fixes = has_check_fixes or has_check_fix
     has_check_messages = has_check_messages or has_check_message
     has_check_notes = has_check_notes or has_check_note
+    has_check_fix_descriptions = has_check_fix_descriptions or \
+      has_check_fix_description
 
     check_fixes_prefixes.append(check_fixes_prefix)
     check_messages_prefixes.append(check_messages_prefix)
     check_notes_prefixes.append(check_notes_prefix)
+    check_fix_descriptions_prefixes.append(check_fix_descriptions_prefix)
 
   assert has_check_fixes or has_check_messages or has_check_notes
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
@@ -175,6 +184,18 @@
       print('FileCheck failed:\n' + e.output.decode())
       raise
 
+  if has_check_fix_descriptions:
+    try:
+      fix_descriptions_file = temp_file_name + '.fix-descriptions'
+      write_file(fix_descriptions_file, clang_tidy_output)
+      subprocess.check_output(
+          ['FileCheck', '-input-file=' + fix_descriptions_file, input_file_name,
+           '-check-prefixes=' + ','.join(check_fix_descriptions_prefixes)],
+          stderr=subprocess.STDOUT)
+    except subprocess.CalledProcessError as e:
+      print('FileCheck failed:\n' + e.output.decode())
+      raise
+
   if has_check_messages:
     messages_file = temp_file_name + '.msg'
     write_file(messages_file, clang_tidy_output)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to