[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
Fri Aug 18 13:27:23 PDT 2017
lebedev.ri created this revision.
lebedev.ri added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, JDevlieghere.
Currently, there is two configured prefixes: `CHECK-FIXES` and `CHECK-MESSAGES`
`CHECK-MESSAGES` checks that there are no test output lines with `warning:|error:`, which are not explicitly handled in lit tests.
However there does not seem to be a nice way to enforce for all the `note:` to be checked.
This was useful for me when developing https://reviews.llvm.org/D36836.
Repository:
rL LLVM
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
@@ -73,9 +73,11 @@
has_check_fixes = input_text.find('CHECK-FIXES') >= 0
has_check_messages = input_text.find('CHECK-MESSAGES') >= 0
+ has_check_notes = input_text.find('CHECK-NOTES') >= 0
- if not has_check_fixes and not has_check_messages:
- sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input')
+ if not has_check_fixes and not has_check_messages and not has_check_notes:
+ sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES '
+ 'nor CHECK-NOTES found in the input')
# Remove the contents of the CHECK lines to avoid CHECKs matching on
# themselves. We need to keep the comments to preserve line numbers while
@@ -136,5 +138,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',
+ '-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.111726.patch
Type: text/x-patch
Size: 1479 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170818/c23af784/attachment-0001.bin>
More information about the cfe-commits
mailing list