1 // RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
2 // RUN:   -config='{CheckOptions: [ \
3 // RUN:     {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
4 // RUN:     {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
5 // RUN:     {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
6 // RUN:     {key: bugprone-easily-swappable-parameters.QualifiersMix, value: 0}, \
7 // RUN:     {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0}, \
8 // RUN:     {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 0}, \
9 // RUN:     {key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold, value: 1} \
10 // RUN:  ]}' --
11 
12 namespace std {
13 struct string {};
14 } // namespace std
15 class Matrix {};
16 
test1(int Foo,int Bar)17 void test1(int Foo, int Bar) {}
18 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 2 adjacent parameters of 'test1' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
19 // CHECK-MESSAGES: :[[@LINE-2]]:16: note: the first parameter in the range is 'Foo'
20 // CHECK-MESSAGES: :[[@LINE-3]]:25: note: the last parameter in the range is 'Bar'
21 
test2(int A,int B)22 void test2(int A, int B) {}
23 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 2 adjacent parameters of 'test2' of similar type ('int')
24 // CHECK-MESSAGES: :[[@LINE-2]]:16: note: the first parameter in the range is 'A'
25 // CHECK-MESSAGES: :[[@LINE-3]]:23: note: the last parameter in the range is 'B'
26 
test3(int Val1,int Val2)27 void test3(int Val1, int Val2) {} // NO-WARN.
28 
test4(int ValA,int Valb)29 void test4(int ValA, int Valb) {} // NO-WARN.
30 
test5(int Val1,int ValZ)31 void test5(int Val1, int ValZ) {} // NO-WARN.
32 
test6(int PValue,int QValue)33 void test6(int PValue, int QValue) {} // NO-WARN.
34 
test7(std::string Astr,std::string Bstr)35 void test7(std::string Astr, std::string Bstr) {} // NO-WARN.
36 
test8(int Aladdin,int Alabaster)37 void test8(int Aladdin, int Alabaster) {}
38 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 2 adjacent parameters of 'test8' of similar type ('int')
39 // CHECK-MESSAGES: :[[@LINE-2]]:16: note: the first parameter in the range is 'Aladdin'
40 // CHECK-MESSAGES: :[[@LINE-3]]:29: note: the last parameter in the range is 'Alabaster'
41 
test9(Matrix Qmat,Matrix Rmat,Matrix Tmat)42 void test9(Matrix Qmat, Matrix Rmat, Matrix Tmat) {} // NO-WARN.
43 
test10(int Something,int Other,int Foo,int Bar1,int Bar2,int Baz,int Qux)44 void test10(int Something, int Other, int Foo, int Bar1, int Bar2, int Baz, int Qux) {}
45 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 4 adjacent parameters of 'test10' of similar type ('int') are
46 // CHECK-MESSAGES: :[[@LINE-2]]:17: note: the first parameter in the range is 'Something'
47 // CHECK-MESSAGES: :[[@LINE-3]]:52: note: the last parameter in the range is 'Bar1'
48 //
49 // CHECK-MESSAGES: :[[@LINE-5]]:58: warning: 3 adjacent parameters of 'test10' of similar type ('int') are
50 // CHECK-MESSAGES: :[[@LINE-6]]:62: note: the first parameter in the range is 'Bar2'
51 // CHECK-MESSAGES: :[[@LINE-7]]:81: note: the last parameter in the range is 'Qux'
52 
test11(int Foobar,int Foo)53 void test11(int Foobar, int Foo) {}
54 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 2 adjacent parameters of 'test11' of similar type ('int')
55 // CHECK-MESSAGES: :[[@LINE-2]]:17: note: the first parameter in the range is 'Foobar'
56 // CHECK-MESSAGES: :[[@LINE-3]]:29: note: the last parameter in the range is 'Foo'
57