1 | // Remove UNSUPPORTED for powerpc64le when the problem introduced by |
2 | // r288563 is resolved. |
3 | // UNSUPPORTED: target=powerpc64le{{.*}} |
4 | // RUN: %check_clang_tidy -std=c++20 %s readability-identifier-naming %t -- \ |
5 | // RUN: -config='{CheckOptions: { \ |
6 | // RUN: readability-identifier-naming.AbstractClassCase: CamelCase, \ |
7 | // RUN: readability-identifier-naming.AbstractClassPrefix: 'A', \ |
8 | // RUN: readability-identifier-naming.ClassCase: CamelCase, \ |
9 | // RUN: readability-identifier-naming.ClassPrefix: 'C', \ |
10 | // RUN: readability-identifier-naming.ClassConstantCase: CamelCase, \ |
11 | // RUN: readability-identifier-naming.ClassConstantPrefix: 'k', \ |
12 | // RUN: readability-identifier-naming.ClassMemberCase: CamelCase, \ |
13 | // RUN: readability-identifier-naming.ClassMethodCase: camelBack, \ |
14 | // RUN: readability-identifier-naming.ConceptCase: CamelCase, \ |
15 | // RUN: readability-identifier-naming.ConstantCase: UPPER_CASE, \ |
16 | // RUN: readability-identifier-naming.ConstantSuffix: '_CST', \ |
17 | // RUN: readability-identifier-naming.ConstexprFunctionCase: lower_case, \ |
18 | // RUN: readability-identifier-naming.ConstexprMethodCase: lower_case, \ |
19 | // RUN: readability-identifier-naming.ConstexprVariableCase: lower_case, \ |
20 | // RUN: readability-identifier-naming.EnumCase: CamelCase, \ |
21 | // RUN: readability-identifier-naming.EnumPrefix: 'E', \ |
22 | // RUN: readability-identifier-naming.ScopedEnumConstantCase: CamelCase, \ |
23 | // RUN: readability-identifier-naming.EnumConstantCase: UPPER_CASE, \ |
24 | // RUN: readability-identifier-naming.FunctionCase: camelBack, \ |
25 | // RUN: readability-identifier-naming.GlobalConstantCase: UPPER_CASE, \ |
26 | // RUN: readability-identifier-naming.GlobalFunctionCase: CamelCase, \ |
27 | // RUN: readability-identifier-naming.GlobalVariableCase: lower_case, \ |
28 | // RUN: readability-identifier-naming.GlobalVariablePrefix: 'g_', \ |
29 | // RUN: readability-identifier-naming.InlineNamespaceCase: lower_case, \ |
30 | // RUN: readability-identifier-naming.LocalConstantCase: CamelCase, \ |
31 | // RUN: readability-identifier-naming.LocalConstantPrefix: 'k', \ |
32 | // RUN: readability-identifier-naming.LocalVariableCase: lower_case, \ |
33 | // RUN: readability-identifier-naming.MemberCase: CamelCase, \ |
34 | // RUN: readability-identifier-naming.MemberPrefix: 'm_', \ |
35 | // RUN: readability-identifier-naming.ConstantMemberCase: lower_case, \ |
36 | // RUN: readability-identifier-naming.PrivateMemberPrefix: '__', \ |
37 | // RUN: readability-identifier-naming.ProtectedMemberPrefix: '_', \ |
38 | // RUN: readability-identifier-naming.PublicMemberCase: lower_case, \ |
39 | // RUN: readability-identifier-naming.MethodCase: camelBack, \ |
40 | // RUN: readability-identifier-naming.PrivateMethodPrefix: '__', \ |
41 | // RUN: readability-identifier-naming.ProtectedMethodPrefix: '_', \ |
42 | // RUN: readability-identifier-naming.NamespaceCase: lower_case, \ |
43 | // RUN: readability-identifier-naming.ParameterCase: camelBack, \ |
44 | // RUN: readability-identifier-naming.ParameterPrefix: 'a_', \ |
45 | // RUN: readability-identifier-naming.ConstantParameterCase: camelBack, \ |
46 | // RUN: readability-identifier-naming.ConstantParameterPrefix: 'i_', \ |
47 | // RUN: readability-identifier-naming.ParameterPackCase: camelBack, \ |
48 | // RUN: readability-identifier-naming.PureFunctionCase: lower_case, \ |
49 | // RUN: readability-identifier-naming.PureMethodCase: camelBack, \ |
50 | // RUN: readability-identifier-naming.StaticConstantCase: UPPER_CASE, \ |
51 | // RUN: readability-identifier-naming.StaticVariableCase: camelBack, \ |
52 | // RUN: readability-identifier-naming.StaticVariablePrefix: 's_', \ |
53 | // RUN: readability-identifier-naming.StructCase: Leading_upper_snake_case, \ |
54 | // RUN: readability-identifier-naming.TemplateParameterCase: UPPER_CASE, \ |
55 | // RUN: readability-identifier-naming.TemplateTemplateParameterCase: CamelCase, \ |
56 | // RUN: readability-identifier-naming.TemplateUsingCase: lower_case, \ |
57 | // RUN: readability-identifier-naming.TemplateUsingPrefix: 'u_', \ |
58 | // RUN: readability-identifier-naming.TypeTemplateParameterCase: camelBack, \ |
59 | // RUN: readability-identifier-naming.TypeTemplateParameterSuffix: '_t', \ |
60 | // RUN: readability-identifier-naming.TypedefCase: lower_case, \ |
61 | // RUN: readability-identifier-naming.TypedefSuffix: '_t', \ |
62 | // RUN: readability-identifier-naming.UnionCase: CamelCase, \ |
63 | // RUN: readability-identifier-naming.UnionPrefix: 'U', \ |
64 | // RUN: readability-identifier-naming.UsingCase: lower_case, \ |
65 | // RUN: readability-identifier-naming.ValueTemplateParameterCase: camelBack, \ |
66 | // RUN: readability-identifier-naming.VariableCase: lower_case, \ |
67 | // RUN: readability-identifier-naming.VirtualMethodCase: Camel_Snake_Case, \ |
68 | // RUN: readability-identifier-naming.VirtualMethodPrefix: 'v_', \ |
69 | // RUN: readability-identifier-naming.MacroDefinitionCase: UPPER_CASE, \ |
70 | // RUN: readability-identifier-naming.TypeAliasCase: camel_Snake_Back, \ |
71 | // RUN: readability-identifier-naming.TypeAliasSuffix: '_t', \ |
72 | // RUN: readability-identifier-naming.IgnoreFailedSplit: false, \ |
73 | // RUN: readability-identifier-naming.GlobalPointerCase: CamelCase, \ |
74 | // RUN: readability-identifier-naming.GlobalPointerSuffix: '_Ptr', \ |
75 | // RUN: readability-identifier-naming.GlobalConstantPointerCase: UPPER_CASE, \ |
76 | // RUN: readability-identifier-naming.GlobalConstantPointerSuffix: '_Ptr', \ |
77 | // RUN: readability-identifier-naming.PointerParameterCase: lower_case, \ |
78 | // RUN: readability-identifier-naming.PointerParameterPrefix: 'p_', \ |
79 | // RUN: readability-identifier-naming.ConstantPointerParameterCase: CamelCase, \ |
80 | // RUN: readability-identifier-naming.ConstantPointerParameterPrefix: 'cp_', \ |
81 | // RUN: readability-identifier-naming.LocalPointerCase: CamelCase, \ |
82 | // RUN: readability-identifier-naming.LocalPointerPrefix: 'l_', \ |
83 | // RUN: readability-identifier-naming.LocalConstantPointerCase: CamelCase, \ |
84 | // RUN: readability-identifier-naming.LocalConstantPointerPrefix: 'lc_', \ |
85 | // RUN: }}' -- -fno-delayed-template-parsing -Dbad_macro \ |
86 | // RUN: -I%S/Inputs/identifier-naming \ |
87 | // RUN: -isystem %S/Inputs/identifier-naming/system |
88 | |
89 | // clang-format off |
90 | |
91 | #include <system-header.h> |
92 | #include <coroutines.h> |
93 | #include "user-header.h" |
94 | // NO warnings or fixes expected from declarations within header files without |
95 | // the -header-filter= option |
96 | |
97 | namespace FOO_NS { |
98 | // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for namespace 'FOO_NS' [readability-identifier-naming] |
99 | // CHECK-FIXES: {{^}}namespace foo_ns {{{$}} |
100 | inline namespace InlineNamespace { |
101 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for inline namespace 'InlineNamespace' |
102 | // CHECK-FIXES: {{^}}inline namespace inline_namespace {{{$}} |
103 | |
104 | SYSTEM_NS::structure g_s1; |
105 | // NO warnings or fixes expected as SYSTEM_NS and structure are declared in a header file |
106 | |
107 | USER_NS::object g_s2; |
108 | // NO warnings or fixes expected as USER_NS and object are declared in a header file |
109 | |
110 | SYSTEM_MACRO(var1); |
111 | // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global variable 'var1' [readability-identifier-naming] |
112 | // CHECK-FIXES: {{^}}SYSTEM_MACRO(g_var1); |
113 | |
114 | USER_MACRO(var2); |
115 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'var2' [readability-identifier-naming] |
116 | // CHECK-FIXES: {{^}}USER_MACRO(g_var2); |
117 | |
118 | #define BLA int FOO_bar |
119 | BLA; |
120 | // NO warnings or fixes expected as FOO_bar is from macro expansion |
121 | |
122 | int global0; |
123 | #define USE_NUMBERED_GLOBAL(number) auto use_global##number = global##number |
124 | USE_NUMBERED_GLOBAL(0); |
125 | // NO warnings or fixes expected as global0 is pieced together in a macro |
126 | // expansion. |
127 | |
128 | int global1; |
129 | #define USE_NUMBERED_BAL(prefix, number) \ |
130 | auto use_##prefix##bal##number = prefix##bal##number |
131 | USE_NUMBERED_BAL(glo, 1); |
132 | // NO warnings or fixes expected as global1 is pieced together in a macro |
133 | // expansion. |
134 | |
135 | int global2; |
136 | #define USE_RECONSTRUCTED(glo, bal) auto use_##glo##bal = glo##bal |
137 | USE_RECONSTRUCTED(glo, bal2); |
138 | // NO warnings or fixes expected as global2 is pieced together in a macro |
139 | // expansion. |
140 | |
141 | int global; |
142 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'global' |
143 | // CHECK-FIXES: {{^}}int g_global;{{$}} |
144 | #define USE_IN_MACRO(m) auto use_##m = m |
145 | USE_IN_MACRO(global); |
146 | |
147 | int global3; |
148 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'global3' |
149 | // CHECK-FIXES: {{^}}int g_global3;{{$}} |
150 | #define ADD_TO_SELF(m) (m) + (m) |
151 | int g_twice_global3 = ADD_TO_SELF(global3); |
152 | // CHECK-FIXES: {{^}}int g_twice_global3 = ADD_TO_SELF(g_global3);{{$}} |
153 | |
154 | int g_Global4; |
155 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'g_Global4' |
156 | // CHECK-FIXES: {{^}}int g_global4;{{$}} |
157 | |
158 | enum my_enumeration { |
159 | // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for enum 'my_enumeration' |
160 | // CHECK-FIXES: {{^}}enum EMyEnumeration {{{$}} |
161 | MyConstant = 1, |
162 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for enum constant 'MyConstant' |
163 | // CHECK-FIXES: {{^}} MY_CONSTANT = 1,{{$}} |
164 | your_CONST = 1, |
165 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for enum constant 'your_CONST' |
166 | // CHECK-FIXES: {{^}} YOUR_CONST = 1,{{$}} |
167 | THIS_ConstValue = 1, |
168 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for enum constant 'THIS_ConstValue' |
169 | // CHECK-FIXES: {{^}} THIS_CONST_VALUE = 1,{{$}} |
170 | }; |
171 | |
172 | enum class EMyEnumeration { |
173 | myConstant = 1, |
174 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for scoped enum constant 'myConstant' |
175 | // CHECK-FIXES: {{^}} MyConstant = 1,{{$}} |
176 | your_CONST = 1, |
177 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for scoped enum constant 'your_CONST' |
178 | // CHECK-FIXES: {{^}} YourConst = 1,{{$}} |
179 | THIS_ConstValue = 1, |
180 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for scoped enum constant 'THIS_ConstValue' |
181 | // CHECK-FIXES: {{^}} ThisConstValue = 1,{{$}} |
182 | }; |
183 | |
184 | constexpr int ConstExpr_variable = MyConstant; |
185 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for constexpr variable 'ConstExpr_variable' |
186 | // CHECK-FIXES: {{^}}constexpr int const_expr_variable = MY_CONSTANT;{{$}} |
187 | |
188 | class my_class { |
189 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_class' |
190 | // CHECK-FIXES: {{^}}class CMyClass {{{$}} |
191 | public: |
192 | my_class(); |
193 | // CHECK-FIXES: {{^}} CMyClass();{{$}} |
194 | |
195 | my_class(void*) : my_class() {} |
196 | // CHECK-FIXES: {{^}} CMyClass(void*) : CMyClass() {}{{$}} |
197 | |
198 | ~ |
199 | my_class(); |
200 | // (space in destructor token test, we could check trigraph but they will be deprecated) |
201 | // CHECK-FIXES: {{^}} ~{{$}} |
202 | // CHECK-FIXES: {{^}} CMyClass();{{$}} |
203 | |
204 | private: |
205 | const int MEMBER_one_1 = ConstExpr_variable; |
206 | // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for constant member 'MEMBER_one_1' |
207 | // CHECK-FIXES: {{^}} const int member_one_1 = const_expr_variable;{{$}} |
208 | int member2 = 2; |
209 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member 'member2' |
210 | // CHECK-FIXES: {{^}} int __member2 = 2;{{$}} |
211 | int = 42; |
212 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member '_memberWithExtraUnderscores_' |
213 | // CHECK-FIXES: {{^}} int __memberWithExtraUnderscores = 42;{{$}} |
214 | |
215 | private: |
216 | int private_member = 3; |
217 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for private member 'private_member' |
218 | // CHECK-FIXES: {{^}} int __private_member = 3;{{$}} |
219 | |
220 | protected: |
221 | int ProtMember; |
222 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for protected member 'ProtMember' |
223 | // CHECK-FIXES: {{^}} int _ProtMember;{{$}} |
224 | |
225 | public: |
226 | int PubMem; |
227 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for public member 'PubMem' |
228 | // CHECK-FIXES: {{^}} int pub_mem;{{$}} |
229 | |
230 | static const int classConstant; |
231 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for class constant 'classConstant' |
232 | // CHECK-FIXES: {{^}} static const int kClassConstant;{{$}} |
233 | static int ClassMember_2; |
234 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for class member 'ClassMember_2' |
235 | // CHECK-FIXES: {{^}} static int ClassMember2;{{$}} |
236 | }; |
237 | class my_class; |
238 | // No warning needed here as this is tied to the previous declaration. |
239 | // Just make sure the fix is applied. |
240 | // CHECK-FIXES: {{^}}class CMyClass;{{$}} |
241 | |
242 | class my_forward_declared_class; // No warning should be triggered. |
243 | |
244 | const int my_class::classConstant = 4; |
245 | // CHECK-FIXES: {{^}}const int CMyClass::kClassConstant = 4;{{$}} |
246 | |
247 | int my_class::ClassMember_2 = 5; |
248 | // CHECK-FIXES: {{^}}int CMyClass::ClassMember2 = 5;{{$}} |
249 | |
250 | class my_derived_class : public virtual my_class {}; |
251 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_derived_class' |
252 | // CHECK-FIXES: {{^}}class CMyDerivedClass : public virtual CMyClass {};{{$}} |
253 | |
254 | class CMyWellNamedClass {}; |
255 | // No warning expected as this class is well named. |
256 | |
257 | template<typename t_t> |
258 | concept MyConcept = requires (t_t a_t) { {a_t++}; }; |
259 | // No warning expected as this concept is well named. |
260 | |
261 | template<typename t_t> |
262 | concept my_concept_2 = requires (t_t a_t) { {a_t++}; }; |
263 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for concept 'my_concept_2' |
264 | // CHECK-FIXES: {{^}}concept MyConcept2 = requires (t_t a_t) { {a_t++}; };{{$}} |
265 | |
266 | template <typename t_t> |
267 | class CMyWellNamedClass2 : public my_class { |
268 | // CHECK-FIXES: {{^}}class CMyWellNamedClass2 : public CMyClass {{{$}} |
269 | t_t my_Bad_Member; |
270 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member 'my_Bad_Member' |
271 | // CHECK-FIXES: {{^}} t_t __my_Bad_Member;{{$}} |
272 | int my_Other_Bad_Member = 42; |
273 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member 'my_Other_Bad_Member' |
274 | // CHECK-FIXES: {{^}} int __my_Other_Bad_Member = 42;{{$}} |
275 | public: |
276 | CMyWellNamedClass2() = default; |
277 | CMyWellNamedClass2(CMyWellNamedClass2 const&) = default; |
278 | CMyWellNamedClass2(CMyWellNamedClass2 &&) = default; |
279 | CMyWellNamedClass2(t_t a_v, void *p_p) : my_class(p_p), my_Bad_Member(a_v) {} |
280 | // CHECK-FIXES: {{^}} CMyWellNamedClass2(t_t a_v, void *p_p) : CMyClass(p_p), __my_Bad_Member(a_v) {}{{$}} |
281 | |
282 | CMyWellNamedClass2(t_t a_v) : my_class(), my_Bad_Member(a_v), my_Other_Bad_Member(11) {} |
283 | // CHECK-FIXES: {{^}} CMyWellNamedClass2(t_t a_v) : CMyClass(), __my_Bad_Member(a_v), __my_Other_Bad_Member(11) {}{{$}} |
284 | }; |
285 | void InstantiateClassMethods() { |
286 | // Ensure we trigger the instantiation of each constructor |
287 | CMyWellNamedClass2<int> x; |
288 | CMyWellNamedClass2<int> x2 = x; |
289 | CMyWellNamedClass2<int> x3 = static_cast<CMyWellNamedClass2<int>&&>(x2); |
290 | CMyWellNamedClass2<int> x4(42); |
291 | CMyWellNamedClass2<int> x5(42, nullptr); |
292 | } |
293 | |
294 | class AOverridden { |
295 | public: |
296 | virtual ~AOverridden() = default; |
297 | virtual void BadBaseMethod() = 0; |
298 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for virtual method 'BadBaseMethod' |
299 | // CHECK-FIXES: {{^}} virtual void v_Bad_Base_Method() = 0; |
300 | |
301 | virtual void BadBaseMethodNoAttr() = 0; |
302 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for virtual method 'BadBaseMethodNoAttr' |
303 | // CHECK-FIXES: {{^}} virtual void v_Bad_Base_Method_No_Attr() = 0; |
304 | }; |
305 | |
306 | class COverriding : public AOverridden { |
307 | public: |
308 | // Overriding a badly-named base isn't a new violation. |
309 | void BadBaseMethod() override {} |
310 | // CHECK-FIXES: {{^}} void v_Bad_Base_Method() override {} |
311 | |
312 | void BadBaseMethodNoAttr() /* override */ {} |
313 | // CHECK-FIXES: {{^}} void v_Bad_Base_Method_No_Attr() /* override */ {} |
314 | |
315 | void foo() { |
316 | BadBaseMethod(); |
317 | // CHECK-FIXES: {{^}} v_Bad_Base_Method(); |
318 | this->BadBaseMethod(); |
319 | // CHECK-FIXES: {{^}} this->v_Bad_Base_Method(); |
320 | AOverridden::BadBaseMethod(); |
321 | // CHECK-FIXES: {{^}} AOverridden::v_Bad_Base_Method(); |
322 | COverriding::BadBaseMethod(); |
323 | // CHECK-FIXES: {{^}} COverriding::v_Bad_Base_Method(); |
324 | |
325 | BadBaseMethodNoAttr(); |
326 | // CHECK-FIXES: {{^}} v_Bad_Base_Method_No_Attr(); |
327 | this->BadBaseMethodNoAttr(); |
328 | // CHECK-FIXES: {{^}} this->v_Bad_Base_Method_No_Attr(); |
329 | AOverridden::BadBaseMethodNoAttr(); |
330 | // CHECK-FIXES: {{^}} AOverridden::v_Bad_Base_Method_No_Attr(); |
331 | COverriding::BadBaseMethodNoAttr(); |
332 | // CHECK-FIXES: {{^}} COverriding::v_Bad_Base_Method_No_Attr(); |
333 | } |
334 | }; |
335 | |
336 | // Same test as above, now with a dependent base class. |
337 | template<typename some_t> |
338 | class ATOverridden { |
339 | public: |
340 | virtual void BadBaseMethod() = 0; |
341 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for virtual method 'BadBaseMethod' |
342 | // CHECK-FIXES: {{^}} virtual void v_Bad_Base_Method() = 0; |
343 | |
344 | virtual void BadBaseMethodNoAttr() = 0; |
345 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for virtual method 'BadBaseMethodNoAttr' |
346 | // CHECK-FIXES: {{^}} virtual void v_Bad_Base_Method_No_Attr() = 0; |
347 | }; |
348 | |
349 | template<typename some_t> |
350 | class CTOverriding : public ATOverridden<some_t> { |
351 | // Overriding a badly-named base isn't a new violation. |
352 | // FIXME: The fixes from the base class should be propagated to the derived class here |
353 | // (note that there could be specializations of the template base class, though) |
354 | void BadBaseMethod() override {} |
355 | |
356 | // Without the "override" attribute, and due to the dependent base class, it is not |
357 | // known whether this method overrides anything, so we get the warning here. |
358 | virtual void BadBaseMethodNoAttr() {}; |
359 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for virtual method 'BadBaseMethodNoAttr' |
360 | // CHECK-FIXES: {{^}} virtual void v_Bad_Base_Method_No_Attr() {}; |
361 | }; |
362 | |
363 | template<typename some_t> |
364 | void VirtualCall(AOverridden &a_vItem, ATOverridden<some_t> &a_vTitem) { |
365 | a_vItem.BadBaseMethod(); |
366 | // CHECK-FIXES: {{^}} a_vItem.v_Bad_Base_Method(); |
367 | |
368 | // FIXME: The fixes from ATOverridden should be propagated to the following call |
369 | a_vTitem.BadBaseMethod(); |
370 | } |
371 | |
372 | // Same test as above, now with a dependent base class that is instantiated below. |
373 | template<typename some_t> |
374 | class ATIOverridden { |
375 | public: |
376 | virtual void BadBaseMethod() = 0; |
377 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for virtual method 'BadBaseMethod' |
378 | // CHECK-FIXES: {{^}} virtual void v_Bad_Base_Method() = 0; |
379 | }; |
380 | |
381 | template<typename some_t> |
382 | class CTIOverriding : public ATIOverridden<some_t> { |
383 | public: |
384 | // Overriding a badly-named base isn't a new violation. |
385 | void BadBaseMethod() override {} |
386 | // CHECK-FIXES: {{^}} void v_Bad_Base_Method() override {} |
387 | }; |
388 | |
389 | template class CTIOverriding<int>; |
390 | |
391 | void VirtualCallI(ATIOverridden<int>& a_vItem, CTIOverriding<int>& a_vCitem) { |
392 | a_vItem.BadBaseMethod(); |
393 | // CHECK-FIXES: {{^}} a_vItem.v_Bad_Base_Method(); |
394 | |
395 | a_vCitem.BadBaseMethod(); |
396 | // CHECK-FIXES: {{^}} a_vCitem.v_Bad_Base_Method(); |
397 | } |
398 | |
399 | template <typename derived_t> |
400 | class CRTPBase { |
401 | public: |
402 | void BadBaseMethod(int) {} |
403 | // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for method 'BadBaseMethod' |
404 | }; |
405 | |
406 | class CRTPDerived : CRTPBase<CRTPDerived> { |
407 | public: |
408 | // Hiding a badly-named base isn't a new violation. |
409 | double BadBaseMethod(double) { return 0; } |
410 | }; |
411 | |
412 | template<typename T> |
413 | // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for type template parameter 'T' |
414 | // CHECK-FIXES: {{^}}template<typename t_t>{{$}} |
415 | class my_templated_class : CMyWellNamedClass {}; |
416 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_templated_class' |
417 | // CHECK-FIXES: {{^}}class CMyTemplatedClass : CMyWellNamedClass {};{{$}} |
418 | |
419 | template<typename T> |
420 | // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for type template parameter 'T' |
421 | // CHECK-FIXES: {{^}}template<typename t_t>{{$}} |
422 | class my_other_templated_class : my_templated_class< my_class>, private my_derived_class {}; |
423 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_other_templated_class' |
424 | // CHECK-FIXES: {{^}}class CMyOtherTemplatedClass : CMyTemplatedClass< CMyClass>, private CMyDerivedClass {};{{$}} |
425 | |
426 | template<typename t_t> |
427 | using mysuper_tpl_t = my_other_templated_class <:: FOO_NS ::my_class>; |
428 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 'mysuper_tpl_t' |
429 | // CHECK-FIXES: {{^}}using mysuper_Tpl_t = CMyOtherTemplatedClass <:: foo_ns ::CMyClass>;{{$}} |
430 | |
431 | const int global_Constant = 6; |
432 | // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global constant 'global_Constant' |
433 | // CHECK-FIXES: {{^}}const int GLOBAL_CONSTANT = 6;{{$}} |
434 | int Global_variable = 7; |
435 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'Global_variable' |
436 | // CHECK-FIXES: {{^}}int g_global_variable = 7;{{$}} |
437 | |
438 | void global_function(int PARAMETER_1, int const CONST_parameter) { |
439 | // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global function 'global_function' |
440 | // CHECK-MESSAGES: :[[@LINE-2]]:26: warning: invalid case style for parameter 'PARAMETER_1' |
441 | // CHECK-MESSAGES: :[[@LINE-3]]:49: warning: invalid case style for constant parameter 'CONST_parameter' |
442 | // CHECK-FIXES: {{^}}void GlobalFunction(int a_parameter1, int const i_constParameter) {{{$}} |
443 | static const int THIS_static_ConsTant = 4; |
444 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for static constant 'THIS_static_ConsTant' |
445 | // CHECK-FIXES: {{^}} static const int THIS_STATIC_CONS_TANT = 4;{{$}} |
446 | static int THIS_static_variable; |
447 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for static variable 'THIS_static_variable' |
448 | // CHECK-FIXES: {{^}} static int s_thisStaticVariable;{{$}} |
449 | int const local_Constant = 3; |
450 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for local constant 'local_Constant' |
451 | // CHECK-FIXES: {{^}} int const kLocalConstant = 3;{{$}} |
452 | int LOCAL_VARIABLE; |
453 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for local variable 'LOCAL_VARIABLE' |
454 | // CHECK-FIXES: {{^}} int local_variable;{{$}} |
455 | |
456 | int LOCAL_Array__[] = {0, 1, 2}; |
457 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for local variable 'LOCAL_Array__' |
458 | // CHECK-FIXES: {{^}} int local_array[] = {0, 1, 2};{{$}} |
459 | |
460 | for (auto _ : LOCAL_Array__) { |
461 | } |
462 | } |
463 | |
464 | template<typename ... TYPE_parameters> |
465 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: invalid case style for type template parameter 'TYPE_parameters' |
466 | // CHECK-FIXES: {{^}}template<typename ... typeParameters_t>{{$}} |
467 | void Global_Fun(TYPE_parameters... PARAMETER_PACK) { |
468 | // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global function 'Global_Fun' |
469 | // CHECK-MESSAGES: :[[@LINE-2]]:36: warning: invalid case style for parameter pack 'PARAMETER_PACK' |
470 | // CHECK-FIXES: {{^}}void GlobalFun(typeParameters_t... parameterPack) {{{$}} |
471 | global_function(PARAMETER_1: 1, CONST_parameter: 2); |
472 | // CHECK-FIXES: {{^}} GlobalFunction(1, 2);{{$}} |
473 | FOO_bar = Global_variable; |
474 | // CHECK-FIXES: {{^}} FOO_bar = g_global_variable;{{$}} |
475 | // NO fix expected for FOO_bar declared in macro expansion |
476 | } |
477 | |
478 | template<template<typename> class TPL_parameter, int COUNT_params, typename ... TYPE_parameters> |
479 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: invalid case style for template template parameter 'TPL_parameter' |
480 | // CHECK-MESSAGES: :[[@LINE-2]]:54: warning: invalid case style for value template parameter 'COUNT_params' |
481 | // CHECK-MESSAGES: :[[@LINE-3]]:81: warning: invalid case style for type template parameter 'TYPE_parameters' |
482 | // CHECK-FIXES: {{^}}template<template<typename> class TplParameter, int countParams, typename ... typeParameters_t>{{$}} |
483 | class test_CLASS { |
484 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'test_CLASS' |
485 | // CHECK-FIXES: {{^}}class CTestClass {{{$}} |
486 | }; |
487 | |
488 | class abstract_class { |
489 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for abstract class 'abstract_class' |
490 | // CHECK-FIXES: {{^}}class AAbstractClass {{{$}} |
491 | virtual ~abstract_class() = 0; |
492 | // CHECK-FIXES: {{^}} virtual ~AAbstractClass() = 0;{{$}} |
493 | virtual void VIRTUAL_METHOD(); |
494 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for virtual method 'VIRTUAL_METHOD' |
495 | // CHECK-FIXES: {{^}} virtual void v_Virtual_Method();{{$}} |
496 | void non_Virtual_METHOD() {} |
497 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for private method 'non_Virtual_METHOD' |
498 | // CHECK-FIXES: {{^}} void __non_Virtual_METHOD() {}{{$}} |
499 | |
500 | public: |
501 | static void CLASS_METHOD() {} |
502 | // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for class method 'CLASS_METHOD' |
503 | // CHECK-FIXES: {{^}} static void classMethod() {}{{$}} |
504 | |
505 | constexpr int CST_expr_Method() { return 2; } |
506 | // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for constexpr method 'CST_expr_Method' |
507 | // CHECK-FIXES: {{^}} constexpr int cst_expr_method() { return 2; }{{$}} |
508 | |
509 | private: |
510 | void PRIVate_Method(); |
511 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for private method 'PRIVate_Method' |
512 | // CHECK-FIXES: {{^}} void __PRIVate_Method();{{$}} |
513 | protected: |
514 | void protected_Method(); |
515 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for protected method 'protected_Method' |
516 | // CHECK-FIXES: {{^}} void _protected_Method();{{$}} |
517 | public: |
518 | void public_Method(); |
519 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for method 'public_Method' |
520 | // CHECK-FIXES: {{^}} void publicMethod();{{$}} |
521 | }; |
522 | |
523 | constexpr int CE_function() { return 3; } |
524 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for constexpr function 'CE_function' |
525 | // CHECK-FIXES: {{^}}constexpr int ce_function() { return 3; }{{$}} |
526 | |
527 | struct THIS___Structure { |
528 | // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for struct 'THIS___Structure' |
529 | // CHECK-FIXES: {{^}}struct This_structure {{{$}} |
530 | THIS___Structure(); |
531 | // CHECK-FIXES: {{^}} This_structure();{{$}} |
532 | |
533 | union __MyUnion_is_wonderful__ {}; |
534 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for union '__MyUnion_is_wonderful__' |
535 | // CHECK-FIXES: {{^}} union UMyUnionIsWonderful {};{{$}} |
536 | }; |
537 | |
538 | typedef THIS___Structure struct_type; |
539 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for typedef 'struct_type' |
540 | // CHECK-FIXES: {{^}}typedef This_structure struct_type_t;{{$}} |
541 | |
542 | struct_type GlobalTypedefTestFunction(struct_type a_argument1) { |
543 | // CHECK-FIXES: {{^}}struct_type_t GlobalTypedefTestFunction(struct_type_t a_argument1) { |
544 | struct_type typedef_test_1; |
545 | // CHECK-FIXES: {{^}} struct_type_t typedef_test_1; |
546 | } |
547 | |
548 | using my_struct_type = THIS___Structure; |
549 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 'my_struct_type' |
550 | // CHECK-FIXES: {{^}}using my_Struct_Type_t = This_structure;{{$}} |
551 | |
552 | template<typename t_t> |
553 | using SomeOtherTemplate = my_other_templated_class <:: FOO_NS ::my_class>; |
554 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 'SomeOtherTemplate' |
555 | // CHECK-FIXES: {{^}}using some_Other_Template_t = CMyOtherTemplatedClass <:: foo_ns ::CMyClass>;{{$}} |
556 | |
557 | static void static_Function() { |
558 | // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for function 'static_Function' |
559 | // CHECK-FIXES: {{^}}static void staticFunction() {{{$}} |
560 | |
561 | ::FOO_NS::InlineNamespace::abstract_class::CLASS_METHOD(); |
562 | // CHECK-FIXES: {{^}} ::foo_ns::inline_namespace::AAbstractClass::classMethod();{{$}} |
563 | ::FOO_NS::InlineNamespace::static_Function(); |
564 | // CHECK-FIXES: {{^}} ::foo_ns::inline_namespace::staticFunction();{{$}} |
565 | |
566 | using ::FOO_NS::InlineNamespace::CE_function; |
567 | // CHECK-FIXES: {{^}} using ::foo_ns::inline_namespace::ce_function;{{$}} |
568 | |
569 | unsigned MY_LOCAL_array[] = {1,2,3}; |
570 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for local variable 'MY_LOCAL_array' |
571 | // CHECK-FIXES: {{^}} unsigned my_local_array[] = {1,2,3};{{$}} |
572 | |
573 | unsigned const MyConstLocal_array[] = {1,2,3}; |
574 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for local constant 'MyConstLocal_array' |
575 | // CHECK-FIXES: {{^}} unsigned const kMyConstLocalArray[] = {1,2,3};{{$}} |
576 | |
577 | static unsigned MY_STATIC_array[] = {1,2,3}; |
578 | // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for static variable 'MY_STATIC_array' |
579 | // CHECK-FIXES: {{^}} static unsigned s_myStaticArray[] = {1,2,3};{{$}} |
580 | |
581 | static unsigned const MyConstStatic_array[] = {1,2,3}; |
582 | // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: invalid case style for static constant 'MyConstStatic_array' |
583 | // CHECK-FIXES: {{^}} static unsigned const MY_CONST_STATIC_ARRAY[] = {1,2,3};{{$}} |
584 | |
585 | char MY_LOCAL_string[] = "123" ; |
586 | // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'MY_LOCAL_string' |
587 | // CHECK-FIXES: {{^}} char my_local_string[] = "123";{{$}} |
588 | |
589 | char const MyConstLocal_string[] = "123" ; |
590 | // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for local constant 'MyConstLocal_string' |
591 | // CHECK-FIXES: {{^}} char const kMyConstLocalString[] = "123";{{$}} |
592 | |
593 | static char MY_STATIC_string[] = "123" ; |
594 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for static variable 'MY_STATIC_string' |
595 | // CHECK-FIXES: {{^}} static char s_myStaticString[] = "123";{{$}} |
596 | |
597 | static char const MyConstStatic_string[] = "123" ; |
598 | // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for static constant 'MyConstStatic_string' |
599 | // CHECK-FIXES: {{^}} static char const MY_CONST_STATIC_STRING[] = "123";{{$}} |
600 | } |
601 | |
602 | #define MY_TEST_Macro(X) X() |
603 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for macro definition 'MY_TEST_Macro' |
604 | // CHECK-FIXES: {{^}}#define MY_TEST_MACRO(X) X() |
605 | |
606 | void MY_TEST_Macro(function) {} |
607 | // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for global function 'function' [readability-identifier-naming] |
608 | // CHECK-FIXES: {{^}}void MY_TEST_MACRO(Function) {} |
609 | |
610 | #define MY_CAT_IMPL(l, r) l ## r |
611 | #define MY_CAT(l, r) MY_CAT_IMPL(l, r) |
612 | #define MY_MACRO2(foo) int MY_CAT(awesome_, MY_CAT(foo, __COUNTER__)) = 0 |
613 | #define MY_MACRO3(foo) int MY_CAT(awesome_, foo) = 0 |
614 | MY_MACRO2(myglob); |
615 | MY_MACRO3(myglob); |
616 | // No suggestions should occur even though the resulting decl of awesome_myglob# |
617 | // or awesome_myglob are not entirely within a macro argument. |
618 | |
619 | } // namespace InlineNamespace |
620 | } // namespace FOO_NS |
621 | |
622 | template <typename t_t> struct a { |
623 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: invalid case style for struct 'a' |
624 | // CHECK-FIXES: {{^}}template <typename t_t> struct A {{{$}} |
625 | typename t_t::template b<> c; |
626 | |
627 | char const MY_ConstMember_string[4] = "123" ; |
628 | // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for constant member 'MY_ConstMember_string' |
629 | // CHECK-FIXES: {{^}} char const my_const_member_string[4] = "123";{{$}} |
630 | |
631 | static char const MyConstClass_string[]; |
632 | // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for class constant 'MyConstClass_string' |
633 | // CHECK-FIXES: {{^}} static char const kMyConstClassString[];{{$}} |
634 | }; |
635 | |
636 | template<typename t_t> |
637 | char const a<t_t>::MyConstClass_string[] = "123" ; |
638 | // CHECK-FIXES: {{^}}char const A<t_t>::kMyConstClassString[] = "123";{{$}} |
639 | |
640 | template <template <typename> class A> struct b { A<int> c; }; |
641 | // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: invalid case style for struct 'b' |
642 | // CHECK-FIXES:template <template <typename> class A> struct B { A<int> c; };{{$}} |
643 | |
644 | unsigned MY_GLOBAL_array[] = {1,2,3}; |
645 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'MY_GLOBAL_array' |
646 | // CHECK-FIXES: {{^}}unsigned g_my_global_array[] = {1,2,3};{{$}} |
647 | |
648 | unsigned const MyConstGlobal_array[] = {1,2,3}; |
649 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global constant 'MyConstGlobal_array' |
650 | // CHECK-FIXES: {{^}}unsigned const MY_CONST_GLOBAL_ARRAY[] = {1,2,3};{{$}} |
651 | |
652 | int * MyGlobal_Ptr;// -> ok |
653 | int * my_second_global_Ptr; |
654 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global pointer 'my_second_global_Ptr' |
655 | // CHECK-FIXES: {{^}}int * MySecondGlobal_Ptr;{{$}} |
656 | int * const MyConstantGlobalPointer = nullptr; |
657 | // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global constant pointer 'MyConstantGlobalPointer' |
658 | // CHECK-FIXES: {{^}}int * const MY_CONSTANT_GLOBAL_POINTER_Ptr = nullptr;{{$}} |
659 | |
660 | void MyPoiterFunction(int * p_normal_pointer, int * const constant_ptr){ |
661 | // CHECK-MESSAGES: :[[@LINE-1]]:59: warning: invalid case style for constant pointer parameter 'constant_ptr' |
662 | // CHECK-FIXES: {{^}}void MyPoiterFunction(int * p_normal_pointer, int * const cp_ConstantPtr){{{$}} |
663 | int * l_PointerA; |
664 | int * const pointer_b = nullptr; |
665 | // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for local constant pointer 'pointer_b' |
666 | // CHECK-FIXES: {{^}} int * const lc_PointerB = nullptr;{{$}} |
667 | } |
668 | |
669 | using namespace FOO_NS; |
670 | // CHECK-FIXES: {{^}}using namespace foo_ns; |
671 | |
672 | using namespace FOO_NS::InlineNamespace; |
673 | // CHECK-FIXES: {{^}}using namespace foo_ns::inline_namespace; |
674 | |
675 | void QualifiedTypeLocTest(THIS___Structure); |
676 | // CHECK-FIXES: {{^}}void QualifiedTypeLocTest(This_structure);{{$}} |
677 | void QualifiedTypeLocTest(THIS___Structure &); |
678 | // CHECK-FIXES: {{^}}void QualifiedTypeLocTest(This_structure &);{{$}} |
679 | void QualifiedTypeLocTest(THIS___Structure &&); |
680 | // CHECK-FIXES: {{^}}void QualifiedTypeLocTest(This_structure &&);{{$}} |
681 | void QualifiedTypeLocTest(const THIS___Structure); |
682 | // CHECK-FIXES: {{^}}void QualifiedTypeLocTest(const This_structure);{{$}} |
683 | void QualifiedTypeLocTest(const THIS___Structure &); |
684 | // CHECK-FIXES: {{^}}void QualifiedTypeLocTest(const This_structure &);{{$}} |
685 | void QualifiedTypeLocTest(volatile THIS___Structure &); |
686 | // CHECK-FIXES: {{^}}void QualifiedTypeLocTest(volatile This_structure &);{{$}} |
687 | |
688 | namespace redecls { |
689 | // We only want the warning to show up once here for the first decl. |
690 | // CHECK-MESSAGES: :[[@LINE+1]]:6: warning: invalid case style for global function 'badNamedFunction' |
691 | void badNamedFunction(); |
692 | void badNamedFunction(); |
693 | void badNamedFunction(){} |
694 | // CHECK-FIXES: {{^}}void BadNamedFunction(); |
695 | // CHECK-FIXES-NEXT: {{^}}void BadNamedFunction(); |
696 | // CHECK-FIXES-NEXT: {{^}}void BadNamedFunction(){} |
697 | void ReferenceBadNamedFunction() { |
698 | auto l_Ptr = badNamedFunction; |
699 | // CHECK-FIXES: {{^}} auto l_Ptr = BadNamedFunction; |
700 | l_Ptr(); |
701 | badNamedFunction(); |
702 | // CHECK-FIXES: {{^}} BadNamedFunction(); |
703 | } |
704 | |
705 | } // namespace redecls |
706 | |
707 | namespace scratchspace { |
708 | #define DUP(Tok) Tok |
709 | #define M1(Tok) DUP(badName##Tok()) |
710 | |
711 | // We don't want a warning here as the call to this in Foo is in a scratch |
712 | // buffer so its fix-it wouldn't be applied, resulting in invalid code. |
713 | void badNameWarn(); |
714 | |
715 | void Foo() { |
716 | M1(Warn); |
717 | } |
718 | |
719 | #undef M1 |
720 | #undef DUP |
721 | } // namespace scratchspace |
722 | |
723 | template<typename type_t> |
724 | auto GetRes(type_t& Param) -> decltype(Param.res()); |
725 | // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for parameter 'Param' |
726 | // CHECK-FIXES: auto GetRes(type_t& a_param) -> decltype(a_param.res()); |
727 | |
728 | // Check implicit declarations in coroutines |
729 | |
730 | struct async_obj { |
731 | // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for struct 'async_obj' |
732 | // CHECK-FIXES: {{^}}struct Async_obj {{{$}} |
733 | public: |
734 | never_suspend operator co_await() const noexcept; |
735 | }; |
736 | |
737 | task ImplicitDeclTest(async_obj &a_object) { |
738 | co_await a_object; // CHECK-MESSAGES-NOT: warning: invalid case style for local variable |
739 | } |
740 | |
741 | // Test scenario when canonical declaration will be a forward declaration |
742 | struct ForwardDeclStruct; |
743 | // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for struct 'ForwardDeclStruct' [readability-identifier-naming] |
744 | // CHECK-FIXES: {{^}}struct Forward_decl_struct; |
745 | // CHECK-FIXES: {{^}}struct Forward_decl_struct { |
746 | struct ForwardDeclStruct { |
747 | }; |
748 | |
749 | struct forward_declared_as_struct; |
750 | // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for class 'forward_declared_as_struct' [readability-identifier-naming] |
751 | // CHECK-FIXES: {{^}}struct CForwardDeclaredAsStruct; |
752 | // CHECK-FIXES: {{^}}class CForwardDeclaredAsStruct { |
753 | class forward_declared_as_struct { |
754 | }; |
755 | |
756 | namespace pr55156 { |
757 | |
758 | template<typename> struct Wrap; |
759 | |
760 | typedef enum { |
761 | VALUE0, |
762 | VALUE1, |
763 | } ValueType; |
764 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: invalid case style for typedef 'ValueType' [readability-identifier-naming] |
765 | // CHECK-FIXES: {{^}}} value_type_t; |
766 | |
767 | typedef ValueType (*MyFunPtr)(const ValueType&, Wrap<ValueType>*); |
768 | // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for typedef 'MyFunPtr' [readability-identifier-naming] |
769 | // CHECK-FIXES: {{^}}typedef value_type_t (*my_fun_ptr_t)(const value_type_t&, Wrap<value_type_t>*); |
770 | |
771 | #define STATIC_MACRO static |
772 | STATIC_MACRO void someFunc(ValueType a_v1, const ValueType& a_v2) {} |
773 | // CHECK-FIXES: {{^}}STATIC_MACRO void someFunc(value_type_t a_v1, const value_type_t& a_v2) {} |
774 | STATIC_MACRO void someFunc(const ValueType** p_a_v1, ValueType (*p_a_v2)()) {} |
775 | // CHECK-FIXES: {{^}}STATIC_MACRO void someFunc(const value_type_t** p_a_v1, value_type_t (*p_a_v2)()) {} |
776 | STATIC_MACRO ValueType someFunc() {} |
777 | // CHECK-FIXES: {{^}}STATIC_MACRO value_type_t someFunc() {} |
778 | STATIC_MACRO void someFunc(MyFunPtr, const MyFunPtr****) {} |
779 | // CHECK-FIXES: {{^}}STATIC_MACRO void someFunc(my_fun_ptr_t, const my_fun_ptr_t****) {} |
780 | #undef STATIC_MACRO |
781 | } |
782 | |
783 | struct Some_struct { |
784 | int SomeMember; |
785 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for public member 'SomeMember' [readability-identifier-naming] |
786 | // CHECK-FIXES: {{^}} int some_member; |
787 | }; |
788 | Some_struct g_s1{ .SomeMember = 1 }; |
789 | // CHECK-FIXES: {{^}}Some_struct g_s1{ .some_member = 1 }; |
790 | Some_struct g_s2{.SomeMember=1}; |
791 | // CHECK-FIXES: {{^}}Some_struct g_s2{.some_member=1}; |
792 | |