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: "\"\";Foo;Bar"}, \
5 // RUN:     {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "T"}, \
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: 0} \
10 // RUN:  ]}' --
11 
ignoredUnnamed(int I,int,int)12 void ignoredUnnamed(int I, int, int) {} // NO-WARN: No >= 2 length of non-unnamed.
13 
nothingIgnored(int I,int J)14 void nothingIgnored(int I, int J) {}
15 // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 2 adjacent parameters of 'nothingIgnored' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
16 // CHECK-MESSAGES: :[[@LINE-2]]:25: note: the first parameter in the range is 'I'
17 // CHECK-MESSAGES: :[[@LINE-3]]:32: note: the last parameter in the range is 'J'
18 
ignoredParameter(int Foo,int I,int J)19 void ignoredParameter(int Foo, int I, int J) {}
20 // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: 2 adjacent parameters of 'ignoredParameter' of similar type ('int')
21 // CHECK-MESSAGES: :[[@LINE-2]]:36: note: the first parameter in the range is 'I'
22 // CHECK-MESSAGES: :[[@LINE-3]]:43: note: the last parameter in the range is 'J'
23 
ignoredParameterBoth(int Foo,int Bar)24 void ignoredParameterBoth(int Foo, int Bar) {} // NO-WARN.
25 
26 struct S {};
27 struct T {};
28 struct MyT {};
29 
notIgnoredType(S S1,S S2)30 void notIgnoredType(S S1, S S2) {}
31 // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 2 adjacent parameters of 'notIgnoredType' of similar type ('S')
32 // CHECK-MESSAGES: :[[@LINE-2]]:23: note: the first parameter in the range is 'S1'
33 // CHECK-MESSAGES: :[[@LINE-3]]:29: note: the last parameter in the range is 'S2'
34 
ignoredTypeExact(T T1,T T2)35 void ignoredTypeExact(T T1, T T2) {} // NO-WARN.
36 
ignoredTypeSuffix(MyT M1,MyT M2)37 void ignoredTypeSuffix(MyT M1, MyT M2) {} // NO-WARN.
38