[PATCH] D53194: [clang-tidy] Fix check_clang_tidy.py trivially passing default CHECK
Zinovy Nis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 12 06:37:53 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344343: [clang-tidy] Fix check_clang_tidy.py trivially passing default CHECK (authored by zinovy.nis, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D53194?vs=169379&id=169388#toc
Repository:
rL LLVM
https://reviews.llvm.org/D53194
Files:
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
Index: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
@@ -51,7 +51,7 @@
parser.add_argument('check_name')
parser.add_argument('temp_file_name')
parser.add_argument('-check-suffix', '-check-suffixes',
- default=[], type=csv,
+ default=[''], type=csv,
help="comma-separated list of FileCheck suffixes")
args, extra_args = parser.parse_known_args()
@@ -96,41 +96,37 @@
has_check_messages = False
has_check_notes = False
- if any(args.check_suffix):
- for check in args.check_suffix:
- if not re.match('^[A-Z0-9\-]+$', check):
- sys.exit('Only A..Z, 0..9 and "-" are ' +
- 'allowed in check suffixes list, but "%s" was given' % (check))
-
- file_check_suffix = '-' + check
- check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
- check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
- check_notes_prefix = 'CHECK-NOTES' + 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
-
- 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))
-
- 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
-
- check_fixes_prefixes.append(check_fixes_prefix)
- check_messages_prefixes.append(check_messages_prefix)
- check_notes_prefixes.append(check_notes_prefix)
- else:
- check_fixes_prefixes = ['CHECK-FIXES']
- check_messages_prefixes = ['CHECK-MESSAGES']
- check_notes_prefixes = ['CHECK-NOTES']
+ for check in args.check_suffix:
+ if check and not re.match('^[A-Z0-9\-]+$', check):
+ sys.exit('Only A..Z, 0..9 and "-" are ' +
+ 'allowed in check suffixes list, but "%s" was given' % (check))
+
+ file_check_suffix = ('-' + check) if check 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
+
+ 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
+
+ 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))
+
+ 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
+
+ check_fixes_prefixes.append(check_fixes_prefix)
+ check_messages_prefixes.append(check_messages_prefix)
+ check_notes_prefixes.append(check_notes_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
# themselves. We need to keep the comments to preserve line numbers while
# avoiding empty lines which could potentially trigger formatting-related
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53194.169388.patch
Type: text/x-patch
Size: 3899 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181012/e38f5f6c/attachment.bin>
More information about the cfe-commits
mailing list