xref: /llvm-project/clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions-custom.c (revision 0b8866d15ac5806a980d2ff2ea63240d8acfa778)
1*0b8866d1SDiscookie // RUN: %check_clang_tidy -check-suffix=NON-STRICT-REGEX %s bugprone-unsafe-functions %t --\
2*0b8866d1SDiscookie // RUN:   -config="{CheckOptions: {bugprone-unsafe-functions.CustomFunctions: '::name_match,replacement,is a qualname match;^::prefix_match,,is matched on qualname prefix'}}"
3*0b8866d1SDiscookie // RUN: %check_clang_tidy -check-suffix=STRICT-REGEX     %s bugprone-unsafe-functions %t --\
4*0b8866d1SDiscookie // RUN:   -config="{CheckOptions: {bugprone-unsafe-functions.CustomFunctions: '^name_match$,replacement,is matched on function name only;^::prefix_match$,,is a full qualname match'}}"
5*0b8866d1SDiscookie 
6*0b8866d1SDiscookie void name_match();
7*0b8866d1SDiscookie void prefix_match();
8*0b8866d1SDiscookie 
9*0b8866d1SDiscookie void name_match_regex();
10*0b8866d1SDiscookie void prefix_match_regex();
11*0b8866d1SDiscookie 
12*0b8866d1SDiscookie void f1() {
13*0b8866d1SDiscookie   name_match();
14*0b8866d1SDiscookie   // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'name_match' is a qualname match; 'replacement' should be used instead
15*0b8866d1SDiscookie   // CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:3: warning: function 'name_match' is matched on function name only; 'replacement' should be used instead
16*0b8866d1SDiscookie   prefix_match();
17*0b8866d1SDiscookie   // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'prefix_match' is matched on qualname prefix; it should not be used
18*0b8866d1SDiscookie   // CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:3: warning: function 'prefix_match' is a full qualname match; it should not be used
19*0b8866d1SDiscookie 
20*0b8866d1SDiscookie   name_match_regex();
21*0b8866d1SDiscookie   // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'name_match_regex' is a qualname match; 'replacement' should be used instead
22*0b8866d1SDiscookie   // no-warning STRICT-REGEX
23*0b8866d1SDiscookie 
24*0b8866d1SDiscookie   prefix_match_regex();
25*0b8866d1SDiscookie   // CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'prefix_match_regex' is matched on qualname prefix; it should not be used
26*0b8866d1SDiscookie   // no-warning STRICT-REGEX
27*0b8866d1SDiscookie }
28