1 | // RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \ |
2 | // RUN: -config='{CheckOptions: { \ |
3 | // RUN: bugprone-easily-swappable-parameters.MinimumLength: 2, \ |
4 | // RUN: bugprone-easily-swappable-parameters.IgnoredParameterNames: "\"\";Foo;Bar", \ |
5 | // RUN: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes: "T", \ |
6 | // RUN: bugprone-easily-swappable-parameters.QualifiersMix: 0, \ |
7 | // RUN: bugprone-easily-swappable-parameters.ModelImplicitConversions: 0, \ |
8 | // RUN: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether: 0, \ |
9 | // RUN: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold: 0 \ |
10 | // RUN: }}' -- |
11 | |
12 | void ignoredUnnamed(int I, int, int) {} // NO-WARN: No >= 2 length of non-unnamed. |
13 | |
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 | |
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 | |
24 | void ignoredParameterBoth(int Foo, int Bar) {} // NO-WARN. |
25 | |
26 | struct S {}; |
27 | struct T {}; |
28 | struct MyT {}; |
29 | |
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 | |
35 | void ignoredTypeExact(T T1, T T2) {} // NO-WARN. |
36 | |
37 | void ignoredTypeSuffix(MyT M1, MyT M2) {} // NO-WARN. |
38 | |