|
| 1 | +// This test fails on "x86_64-sie" buildbot and "x86_64-scei-ps4" target. |
| 2 | +// According to @dyung, something related to the kind of standard library |
| 3 | +// availability is causing the failure. Even though we explicitly define |
| 4 | +// the relevant macros the check is hunting for in the invocation, the real |
| 5 | +// parsing and preprocessor state will not have that case. |
| 6 | +// UNSUPPORTED: target={{.*-(ps4|ps5)}} |
| 7 | +// |
| 8 | +// RUN: %check_clang_tidy -check-suffix=NON-STRICT-REGEX %s bugprone-unsafe-functions %t --\ |
| 9 | +// RUN: -config="{CheckOptions: {bugprone-unsafe-functions.CustomNormalFunctions: '::non_annex_k_only,replacement;::both,replacement,is a normal function'}}"\ |
| 10 | +// RUN: -- -U__STDC_LIB_EXT1__ -U__STDC_WANT_LIB_EXT1__ |
| 11 | +// RUN: %check_clang_tidy -check-suffix=STRICT-REGEX %s bugprone-unsafe-functions %t --\ |
| 12 | +// RUN: -config="{CheckOptions: {bugprone-unsafe-functions.CustomNormalFunctions: '^non_annex_k_only$,replacement,is matched on function name only;^::both,replacement,is matched on qualname prefix'}}"\ |
| 13 | +// RUN: -- -U__STDC_LIB_EXT1__ -U__STDC_WANT_LIB_EXT1__ |
| 14 | +// RUN: %check_clang_tidy -check-suffix=WITH-ANNEX-K %s bugprone-unsafe-functions %t --\ |
| 15 | +// RUN: -config="{CheckOptions: {bugprone-unsafe-functions.CustomAnnexKFunctions: '::annex_k_only,replacement;::both,replacement,is an Annex K function'}}"\ |
| 16 | +// RUN: -- -D__STDC_LIB_EXT1__=1 -D__STDC_WANT_LIB_EXT1__=1 |
| 17 | + |
| 18 | +// TODO: How is "Annex K" available in C++ mode? |
| 19 | +// no-warning WITH-ANNEX-K |
| 20 | + |
| 21 | +void non_annex_k_only(); |
| 22 | +void annex_k_only(); |
| 23 | +void both(); |
| 24 | + |
| 25 | +namespace regex_test { |
| 26 | +void non_annex_k_only(); |
| 27 | +void both(); |
| 28 | +} |
| 29 | + |
| 30 | +void non_annex_k_only_regex(); |
| 31 | +void both_regex(); |
| 32 | + |
| 33 | +void f1() { |
| 34 | + non_annex_k_only(); |
| 35 | + // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'non_annex_k_only' is marked as unsafe; 'replacement' should be used instead |
| 36 | + // CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:3: warning: function 'non_annex_k_only' is matched on function name only; 'replacement' should be used instead |
| 37 | + annex_k_only(); |
| 38 | + // no-warning NON-STRICT-REGEX |
| 39 | + // no-warning STRICT-REGEX |
| 40 | + both(); |
| 41 | + // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'both' is a normal function; 'replacement' should be used instead |
| 42 | + // CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:3: warning: function 'both' is matched on qualname prefix; 'replacement' should be used instead |
| 43 | + |
| 44 | + ::non_annex_k_only(); |
| 45 | + // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'non_annex_k_only' is marked as unsafe; 'replacement' should be used instead |
| 46 | + // CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:3: warning: function 'non_annex_k_only' is matched on function name only; 'replacement' should be used instead |
| 47 | + regex_test::non_annex_k_only(); |
| 48 | + // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'non_annex_k_only' is marked as unsafe; 'replacement' should be used instead |
| 49 | + // CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:3: warning: function 'non_annex_k_only' is matched on function name only; 'replacement' should be used instead |
| 50 | + non_annex_k_only_regex(); |
| 51 | + // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'non_annex_k_only_regex' is marked as unsafe; 'replacement' should be used instead |
| 52 | + // no-warning STRICT-REGEX |
| 53 | + |
| 54 | + ::both(); |
| 55 | + // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'both' is a normal function; 'replacement' should be used instead |
| 56 | + // CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:3: warning: function 'both' is matched on qualname prefix; 'replacement' should be used instead |
| 57 | + regex_test::both(); |
| 58 | + // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'both' is a normal function; 'replacement' should be used instead |
| 59 | + // no-warning STRICT-REGEX |
| 60 | + both_regex(); |
| 61 | + // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'both_regex' is a normal function; 'replacement' should be used instead |
| 62 | + // CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:3: warning: function 'both_regex' is matched on qualname prefix; 'replacement' should be used instead |
| 63 | +} |
0 commit comments