diff options
author | Zinovy Nis <zinovy.nis@gmail.com> | 2018-10-12 13:35:47 +0000 |
---|---|---|
committer | Zinovy Nis <zinovy.nis@gmail.com> | 2018-10-12 13:35:47 +0000 |
commit | 608dfb2bc7131f0aaca553acec60f13ab976495a (patch) | |
tree | 0d1c18d33ae72f6e4e36c8b410c4d7d2e714bae1 /clang-tools-extra/test/clang-tidy/check_clang_tidy.py | |
parent | fa91327b517ed296be7a0f6a4ed57da44907dd13 (diff) | |
download | bcm5719-llvm-608dfb2bc7131f0aaca553acec60f13ab976495a.tar.gz bcm5719-llvm-608dfb2bc7131f0aaca553acec60f13ab976495a.zip |
[clang-tidy] Fix check_clang_tidy.py trivially passing default CHECK
Differential Revision: https://reviews.llvm.org/D53194
llvm-svn: 344343
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/check_clang_tidy.py')
-rwxr-xr-x | clang-tools-extra/test/clang-tidy/check_clang_tidy.py | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py index 9d2b5f7899e..9768011a3ef 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -51,7 +51,7 @@ def main(): 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 @@ def main(): 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 |