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