1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
// RUN: %check_clang_tidy -std=c++20 %s readability-identifier-naming %t -- \
// RUN: -config='{CheckOptions: { \
// RUN: readability-identifier-naming.CheckAnonFieldInParent: true, \
// RUN: readability-identifier-naming.ClassConstantCase: CamelCase, \
// RUN: readability-identifier-naming.ClassConstantPrefix: 'k', \
// RUN: readability-identifier-naming.ClassMemberCase: CamelCase, \
// RUN: readability-identifier-naming.ConstantCase: UPPER_CASE, \
// RUN: readability-identifier-naming.ConstantSuffix: '_CST', \
// RUN: readability-identifier-naming.ConstexprVariableCase: lower_case, \
// RUN: readability-identifier-naming.GlobalConstantCase: UPPER_CASE, \
// RUN: readability-identifier-naming.GlobalVariableCase: lower_case, \
// RUN: readability-identifier-naming.GlobalVariablePrefix: 'g_', \
// RUN: readability-identifier-naming.LocalConstantCase: CamelCase, \
// RUN: readability-identifier-naming.LocalConstantPrefix: 'k', \
// RUN: readability-identifier-naming.LocalVariableCase: lower_case, \
// RUN: readability-identifier-naming.MemberCase: CamelCase, \
// RUN: readability-identifier-naming.MemberPrefix: 'm_', \
// RUN: readability-identifier-naming.ConstantMemberCase: lower_case, \
// RUN: readability-identifier-naming.PrivateMemberPrefix: '__', \
// RUN: readability-identifier-naming.ProtectedMemberPrefix: '_', \
// RUN: readability-identifier-naming.PublicMemberCase: lower_case, \
// RUN: readability-identifier-naming.StaticConstantCase: UPPER_CASE, \
// RUN: readability-identifier-naming.StaticVariableCase: camelBack, \
// RUN: readability-identifier-naming.StaticVariablePrefix: 's_', \
// RUN: readability-identifier-naming.VariableCase: lower_case, \
// RUN: readability-identifier-naming.GlobalPointerCase: CamelCase, \
// RUN: readability-identifier-naming.GlobalPointerSuffix: '_Ptr', \
// RUN: readability-identifier-naming.GlobalConstantPointerCase: UPPER_CASE, \
// RUN: readability-identifier-naming.GlobalConstantPointerSuffix: '_Ptr', \
// RUN: readability-identifier-naming.LocalPointerCase: CamelCase, \
// RUN: readability-identifier-naming.LocalPointerPrefix: 'l_', \
// RUN: readability-identifier-naming.LocalConstantPointerCase: CamelCase, \
// RUN: readability-identifier-naming.LocalConstantPointerPrefix: 'lc_', \
// RUN: }}'
static union {
int global;
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'global'
// CHECK-FIXES: {{^}} int g_global;{{$}}
const int global_const;
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global constant 'global_const'
// CHECK-FIXES: {{^}} const int GLOBAL_CONST;{{$}}
int *global_ptr;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global pointer 'global_ptr'
// CHECK-FIXES: {{^}} int *GlobalPtr_Ptr;{{$}}
int *const global_const_ptr;
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global constant pointer 'global_const_ptr'
// CHECK-FIXES: {{^}} int *const GLOBAL_CONST_PTR_Ptr;{{$}}
};
namespace ns {
static union {
int ns_global;
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'ns_global'
// CHECK-FIXES: {{^}} int g_ns_global;{{$}}
const int ns_global_const;
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global constant 'ns_global_const'
// CHECK-FIXES: {{^}} const int NS_GLOBAL_CONST;{{$}}
int *ns_global_ptr;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global pointer 'ns_global_ptr'
// CHECK-FIXES: {{^}} int *NsGlobalPtr_Ptr;{{$}}
int *const ns_global_const_ptr;
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global constant pointer 'ns_global_const_ptr'
// CHECK-FIXES: {{^}} int *const NS_GLOBAL_CONST_PTR_Ptr;{{$}}
};
namespace {
union {
int anon_ns_global;
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'anon_ns_global'
// CHECK-FIXES: {{^}} int g_anon_ns_global;{{$}}
const int anon_ns_global_const;
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global constant 'anon_ns_global_const'
// CHECK-FIXES: {{^}} const int ANON_NS_GLOBAL_CONST;{{$}}
int *anon_ns_global_ptr;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global pointer 'anon_ns_global_ptr'
// CHECK-FIXES: {{^}} int *AnonNsGlobalPtr_Ptr;{{$}}
int *const anon_ns_global_const_ptr;
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global constant pointer 'anon_ns_global_const_ptr'
// CHECK-FIXES: {{^}} int *const ANON_NS_GLOBAL_CONST_PTR_Ptr;{{$}}
};
}
}
class Foo {
public:
union {
int PubMember;
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for public member 'PubMember'
// CHECK-FIXES: {{^}} int pub_member;{{$}}
const int PubConstMember;
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for constant member 'PubConstMember'
// CHECK-FIXES: {{^}} const int pub_const_member;{{$}}
int *PubPtrMember;
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for public member 'PubPtrMember'
// CHECK-FIXES: {{^}} int *pub_ptr_member;{{$}}
int *const PubConstPtrMember;
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for constant member 'PubConstPtrMember'
// CHECK-FIXES: {{^}} int *const pub_const_ptr_member;{{$}}
};
protected:
union {
int prot_member;
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for protected member 'prot_member'
// CHECK-FIXES: {{^}} int _prot_member;{{$}}
const int prot_const_member;
int *prot_ptr_member;
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for protected member 'prot_ptr_member'
// CHECK-FIXES: {{^}} int *_prot_ptr_member;{{$}}
int *const prot_const_ptr_member;
};
private:
union {
int pri_member;
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for private member 'pri_member'
// CHECK-FIXES: {{^}} int __pri_member;{{$}}
const int pri_const_member;
int *pri_ptr_member;
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for private member 'pri_ptr_member'
// CHECK-FIXES: {{^}} int *__pri_ptr_member;{{$}}
int *const pri_const_ptr_member;
};
};
void test() {
union {
int local;
const int local_const;
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for local constant 'local_const'
// CHECK-FIXES: {{^}} const int kLocalConst;{{$}}
int *local_ptr;
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for local pointer 'local_ptr'
// CHECK-FIXES: {{^}} int *l_LocalPtr;{{$}}
int *const local_const_ptr;
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for local constant pointer 'local_const_ptr'
// CHECK-FIXES: {{^}} int *const lc_LocalConstPtr;{{$}}
};
static union {
int local_static;
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for static variable 'local_static'
// CHECK-FIXES: {{^}} int s_localStatic;{{$}}
const int local_static_const;
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for static constant 'local_static_const'
// CHECK-FIXES: {{^}} const int LOCAL_STATIC_CONST;{{$}}
int *local_static_ptr;
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for static variable 'local_static_ptr'
// CHECK-FIXES: {{^}} int *s_localStaticPtr;{{$}}
int *const local_static_const_ptr;
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for static constant 'local_static_const_ptr'
// CHECK-FIXES: {{^}} int *const LOCAL_STATIC_CONST_PTR;{{$}}
};
}
|