| 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: "", \ |
| 5 |
// RUN: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes: "", \ |
| 6 |
// RUN: bugprone-easily-swappable-parameters.QualifiersMix: 0, \ |
| 7 |
// RUN: bugprone-easily-swappable-parameters.ModelImplicitConversions: 0, \ |
| 8 |
// RUN: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether: 1, \ |
| 9 |
// RUN: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold: 0 \ |
| 10 |
// RUN: }}' -- -Wno-strict-prototypes -x c |
| 11 |
|
| 12 |
int myprint(); |
| 13 |
int add(int X, int Y); |
| 14 |
|
| 15 |
void notRelated(int A, int B) {} |
| 16 |
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: 2 adjacent parameters of 'notRelated' of similar type ('int') |
| 17 |
// CHECK-MESSAGES: :[[@LINE-2]]:21: note: the first parameter in the range is 'A' |
| 18 |
// CHECK-MESSAGES: :[[@LINE-3]]:28: note: the last parameter in the range is 'B' |
| 19 |
|
| 20 |
int addedTogether(int A, int B) { return add(A, B); } // NO-WARN: Passed to same function. |
| 21 |
|
| 22 |
void passedToSameKNRFunction(int A, int B) { |
| 23 |
myprint("foo", A); |
| 24 |
myprint("bar", B); |
| 25 |
} |
| 26 |
// CHECK-MESSAGES: :[[@LINE-4]]:30: warning: 2 adjacent parameters of 'passedToSameKNRFunction' of similar type ('int') |
| 27 |
// CHECK-MESSAGES: :[[@LINE-5]]:34: note: the first parameter in the range is 'A' |
| 28 |
// CHECK-MESSAGES: :[[@LINE-6]]:41: note: the last parameter in the range is 'B' |
| 29 |
// This is actually a false positive: the "passed to same function" heuristic |
| 30 |
// can't map the parameter index 1 to A and B because myprint() has no |
| 31 |
// parameters. |