[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 7 06:32:55 PDT 2018


lebedev.ri updated this revision to Diff 154490.
lebedev.ri added a comment.

Rebased, just to control bitrot, no changes.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D36892

Files:
  test/clang-tidy/check_clang_tidy.py


Index: test/clang-tidy/check_clang_tidy.py
===================================================================
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -78,6 +78,7 @@
   file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else ''
   check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
   check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
+  check_notes_prefix = 'CHECK-NOTES' + file_check_suffix
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
@@ -91,9 +92,10 @@
 
   has_check_fixes = check_fixes_prefix in input_text
   has_check_messages = check_messages_prefix in input_text
+  has_check_notes = check_notes_prefix in input_text
 
   if not has_check_fixes and not has_check_messages:
-    sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, check_messages_prefix) )
+    sys.exit('None of %s, %s or %s found in the input' % (check_fixes_prefix, check_messages_prefix, check_notes_prefix) )
 
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
   # themselves.  We need to keep the comments to preserve line numbers while
@@ -156,5 +158,18 @@
       print('FileCheck failed:\n' + e.output.decode())
       raise
 
+  if has_check_notes:
+    messages_file = temp_file_name + '.msg'
+    write_file(messages_file, clang_tidy_output)
+    try:
+      subprocess.check_output(
+          ['FileCheck', '-input-file=' + messages_file, input_file_name,
+           '-check-prefix=' + check_notes_prefix,
+           '-implicit-check-not={{note|warning|error}}:'],
+          stderr=subprocess.STDOUT)
+    except subprocess.CalledProcessError as e:
+      print('FileCheck failed:\n' + e.output.decode())
+      raise
+
 if __name__ == '__main__':
   main()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36892.154490.patch
Type: text/x-patch
Size: 1837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180707/877b8404/attachment.bin>


More information about the cfe-commits mailing list