From b90fdb7c117fab83a8a2d1c95ed468c47e480f89 Mon Sep 17 00:00:00 2001 From: Nathan James Date: Wed, 24 Feb 2021 15:22:53 +0000 Subject: [PATCH] [clang-tidy][test] Allow specifying potentially unused suffixes If a check-suffix is only required for a CHECK-FIXES or CHECK-MESSAGES. check_clang_tidy will pass the prefixes CHECK-FIXES<...> and CHECK-MESSAGES<...> to FileCheck. This will result in a FileCheck failing because of an unused prefix. This addresses the problem by not passing unused prefixes. Its also possible to fix this be passing `--allow-unused-prefixes` flag to FileCheck, but seeing as we have already done the legwork in the script to see its unused, this fix seems the better way to go. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D97322 --- clang-tools-extra/test/clang-tidy/check_clang_tidy.py | 9 ++++++--- .../test/clang-tidy/checkers/modernize-loop-convert-reverse.cpp | 7 ------- 2 files changed, 6 insertions(+), 10 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 0031d9b..5ebe3a1 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -119,9 +119,12 @@ def run_test_once(args, extra_args): 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) + if has_check_fix: + check_fixes_prefixes.append(check_fixes_prefix) + if has_check_message: + check_messages_prefixes.append(check_messages_prefix) + if has_check_note: + 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 diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-reverse.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-reverse.cpp index c82c291..63da130 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-reverse.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-reverse.cpp @@ -30,13 +30,6 @@ // RUN: | FileCheck %s -check-prefix=CHECK-HEADER-NO-FUNC \ // RUN: -implicit-check-not="{{warning|error}}:" -/// Suppress FileCheck --allow-unused-prefixes=false diagnostics. -// CHECK-MESSAGES-RANGES: {{^}} -// CHECK-MESSAGES-CUSTOM: {{^}} -// CHECK-MESSAGES-CUSTOM-SYS: {{^}} -// CHECK-MESSAGES-CUSTOM-NO-SYS: {{^}} -// CHECK-MESSAGES-CUSTOM-NO-HEADER: {{^}} - // CHECK-HEADER-NO-FUNC: warning: modernize-loop-convert: 'MakeReverseRangeHeader' is set but 'MakeReverseRangeFunction' is not, disabling reverse loop transformation // Make sure appropiate headers are included -- 2.7.4