| 1 |
// RUN: %check_clang_tidy %s readability-inconsistent-declaration-parameter-name %t -- \ |
| 2 |
// RUN: -config="{CheckOptions: {readability-inconsistent-declaration-parameter-name.IgnoreMacros: false}}" |
| 3 |
|
| 4 |
#define MACRO() \ |
| 5 |
void f(int x) |
| 6 |
|
| 7 |
struct S1 { |
| 8 |
MACRO(); |
| 9 |
// CHECK-NOTES: :[[@LINE-1]]:3: warning: function 'S1::f' has a definition with different parameter names |
| 10 |
// CHECK-NOTES: :[[@LINE-5]]:8: note: expanded from macro 'MACRO' |
| 11 |
// CHECK-NOTES: :[[@LINE+4]]:10: note: the definition seen here |
| 12 |
// CHECK-NOTES: :[[@LINE-4]]:3: note: differing parameters are named here: ('x'), in definition: ('y') |
| 13 |
// CHECK-NOTES: :[[@LINE-8]]:8: note: expanded from macro 'MACRO' |
| 14 |
}; |
| 15 |
void S1::f(int y) {} |
| 16 |
|
| 17 |
struct S2 { |
| 18 |
int g() const; |
| 19 |
void set_g(int g); |
| 20 |
// CHECK-NOTES: :[[@LINE-1]]:8: warning: function 'S2::set_g' has a definition with different parameter names |
| 21 |
// CHECK-NOTES: :[[@LINE+14]]:1: note: the definition seen here |
| 22 |
// CHECK-NOTES: :[[@LINE+9]]:12: note: expanded from macro 'DEFINITION' |
| 23 |
// This one is unfortunate, but the location this points to is in a scratch |
| 24 |
// space, so it's not helpful to the user. |
| 25 |
// CHECK-NOTES: {{^}}note: expanded from here{{$}} |
| 26 |
// CHECK-NOTES: :[[@LINE-7]]:8: note: differing parameters are named here: ('g'), in definition: ('w') |
| 27 |
}; |
| 28 |
|
| 29 |
#define DEFINITION(name, parameter) \ |
| 30 |
int S2::name() const { return 0; } \ |
| 31 |
void S2::set_##name(int parameter) { \ |
| 32 |
(void)parameter; \ |
| 33 |
} |
| 34 |
|
| 35 |
DEFINITION(g, w) |
| 36 |
|
| 37 |
////////////////////////////////////////////////////// |
| 38 |
|
| 39 |
#define DECLARE_FUNCTION_WITH_PARAM_NAME(function_name, param_name) \ |
| 40 |
void function_name(int param_name) |
| 41 |
|
| 42 |
// CHECK-NOTES: :[[@LINE+1]]:34: warning: function 'macroFunction' has 1 other declaration with different parameter names [readability-inconsistent-declaration-parameter-name] |
| 43 |
DECLARE_FUNCTION_WITH_PARAM_NAME(macroFunction, a); |
| 44 |
// CHECK-NOTES: :[[@LINE+2]]:34: note: the 1st inconsistent declaration seen here |
| 45 |
// CHECK-NOTES: :[[@LINE+1]]:34: note: differing parameters are named here: ('b'), in the other declaration: ('a') |
| 46 |
DECLARE_FUNCTION_WITH_PARAM_NAME(macroFunction, b); |