2018-01-06 07:22:10 +08:00
/ / RUN : % check_clang_tidy % s readability - inconsistent - declaration - parameter - name % t - - \
2021-05-05 01:17:55 +08:00
// RUN: -config="{CheckOptions: [{key: readability-inconsistent-declaration-parameter-name.IgnoreMacros, value: false}]}"
2018-01-06 07:22:10 +08:00
# define MACRO() \
2018-11-16 22:57:51 +08:00
void f ( int x )
2018-01-06 07:22:10 +08:00
2018-11-16 22:57:51 +08:00
struct S1 {
2018-01-06 07:22:10 +08:00
MACRO ( ) ;
2018-11-16 22:57:51 +08:00
// CHECK-NOTES: :[[@LINE-1]]:3: warning: function 'S1::f' has a definition with different parameter names
// CHECK-NOTES: :[[@LINE-5]]:8: note: expanded from macro 'MACRO'
// CHECK-NOTES: :[[@LINE+4]]:10: note: the definition seen here
// CHECK-NOTES: :[[@LINE-4]]:3: note: differing parameters are named here: ('x'), in definition: ('y')
// CHECK-NOTES: :[[@LINE-8]]:8: note: expanded from macro 'MACRO'
2018-01-06 07:22:10 +08:00
} ;
2018-11-16 22:57:51 +08:00
void S1 : : f ( int y ) { }
2018-01-06 07:22:10 +08:00
2018-11-16 22:57:51 +08:00
struct S2 {
int g ( ) const ;
void set_g ( int g ) ;
// CHECK-NOTES: :[[@LINE-1]]:8: warning: function 'S2::set_g' has a definition with different parameter names
// CHECK-NOTES: :[[@LINE+14]]:1: note: the definition seen here
// CHECK-NOTES: :[[@LINE+9]]:12: note: expanded from macro 'DEFINITION'
// This one is unfortunate, but the location this points to is in a scratch
// space, so it's not helpful to the user.
// CHECK-NOTES: {{^}}note: expanded from here{{$}}
// CHECK-NOTES: :[[@LINE-7]]:8: note: differing parameters are named here: ('g'), in definition: ('w')
} ;
# define DEFINITION(name, parameter) \
int S2 : : name ( ) const { return 0 ; } \
void S2 : : set_ # # name ( int parameter ) { \
( void ) parameter ; \
}
DEFINITION ( g , w )
2018-01-06 07:22:10 +08:00
//////////////////////////////////////////////////////
# define DECLARE_FUNCTION_WITH_PARAM_NAME(function_name, param_name) \
void function_name ( int param_name )
2018-11-16 22:57:51 +08:00
// CHECK-NOTES: :[[@LINE+1]]:34: warning: function 'macroFunction' has 1 other declaration with different parameter names [readability-inconsistent-declaration-parameter-name]
2018-01-06 07:22:10 +08:00
DECLARE_FUNCTION_WITH_PARAM_NAME ( macroFunction , a ) ;
2018-11-16 22:57:51 +08:00
// CHECK-NOTES: :[[@LINE+2]]:34: note: the 1st inconsistent declaration seen here
// CHECK-NOTES: :[[@LINE+1]]:34: note: differing parameters are named here: ('b'), in the other declaration: ('a')
2018-01-06 07:22:10 +08:00
DECLARE_FUNCTION_WITH_PARAM_NAME ( macroFunction , b ) ;