1// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
2// RUN: --config-file=%S/Inputs/identifier-naming/hungarian-notation3/.clang-tidy -- -I %S
3
4#include "identifier-naming-standard-types.h"
5
6// clang-format off
7//===----------------------------------------------------------------------===//
8// Cases to CheckOptions
9//===----------------------------------------------------------------------===//
10class C_MyClass1 {
11public:
12 static int ClassMemberCase;
13 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for class member 'ClassMemberCase' [readability-identifier-naming]
14 // CHECK-FIXES: {{^}} static int i_ClassMemberCase;
15
16 char const ConstantMemberCase = 0;
17 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for constant member 'ConstantMemberCase' [readability-identifier-naming]
18 // CHECK-FIXES: {{^}} char const c_ConstantMemberCase = 0;
19
20 void MyFunc1(const int ConstantParameterCase);
21 // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for constant parameter 'ConstantParameterCase' [readability-identifier-naming]
22 // CHECK-FIXES: {{^}} void MyFunc1(const int i_ConstantParameterCase);
23
24 void MyFunc2(const int* ConstantPointerParameterCase);
25 // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: invalid case style for pointer parameter 'ConstantPointerParameterCase' [readability-identifier-naming]
26 // CHECK-FIXES: {{^}} void MyFunc2(const int* pi_ConstantPointerParameterCase);
27
28 static constexpr int ConstexprVariableCase = 123;
29 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: invalid case style for constexpr variable 'ConstexprVariableCase' [readability-identifier-naming]
30 // CHECK-FIXES: {{^}} static constexpr int i_ConstexprVariableCase = 123;
31};
32
33const int GlobalConstantCase = 0;
34// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global constant 'GlobalConstantCase' [readability-identifier-naming]
35// CHECK-FIXES: {{^}}const int i_GlobalConstantCase = 0;
36
37const int* GlobalConstantPointerCase = nullptr;
38// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global pointer 'GlobalConstantPointerCase' [readability-identifier-naming]
39// CHECK-FIXES: {{^}}const int* pi_GlobalConstantPointerCase = nullptr;
40
41int* GlobalPointerCase = nullptr;
42// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global pointer 'GlobalPointerCase' [readability-identifier-naming]
43// CHECK-FIXES: {{^}}int* pi_GlobalPointerCase = nullptr;
44
45int GlobalVariableCase = 0;
46// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'GlobalVariableCase' [readability-identifier-naming]
47// CHECK-FIXES: {{^}}int i_GlobalVariableCase = 0;
48
49void Func1(){
50 int const LocalConstantCase = 3;
51 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for local constant 'LocalConstantCase' [readability-identifier-naming]
52 // CHECK-FIXES: {{^}} int const i_LocalConstantCase = 3;
53
54 unsigned const ConstantCase = 1;
55 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for local constant 'ConstantCase' [readability-identifier-naming]
56 // CHECK-FIXES: {{^}} unsigned const u_ConstantCase = 1;
57
58 int* const LocalConstantPointerCase = nullptr;
59 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for local constant pointer 'LocalConstantPointerCase' [readability-identifier-naming]
60 // CHECK-FIXES: {{^}} int* const pi_LocalConstantPointerCase = nullptr;
61
62 int *LocalPointerCase = nullptr;
63 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local pointer 'LocalPointerCase' [readability-identifier-naming]
64 // CHECK-FIXES: {{^}} int *pi_LocalPointerCase = nullptr;
65
66 int LocalVariableCase = 0;
67 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for local variable 'LocalVariableCase' [readability-identifier-naming]
68 // CHECK-FIXES: {{^}} int i_LocalVariableCase = 0;
69}
70
71class C_MyClass2 {
72 char MemberCase;
73 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for private member 'MemberCase' [readability-identifier-naming]
74 // CHECK-FIXES: {{^}} char c_MemberCase;
75
76 void Func1(int ParameterCase);
77 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'ParameterCase' [readability-identifier-naming]
78 // CHECK-FIXES: {{^}} void Func1(int i_ParameterCase);
79
80 void Func2(const int ParameterCase);
81 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: invalid case style for constant parameter 'ParameterCase' [readability-identifier-naming]
82 // CHECK-FIXES: {{^}} void Func2(const int i_ParameterCase);
83
84 void Func3(const int *PointerParameterCase);
85 // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: invalid case style for pointer parameter 'PointerParameterCase' [readability-identifier-naming]
86 // CHECK-FIXES: {{^}} void Func3(const int *pi_PointerParameterCase);
87};
88
89class C_MyClass3 {
90private:
91 char PrivateMemberCase;
92 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for private member 'PrivateMemberCase' [readability-identifier-naming]
93 // CHECK-FIXES: {{^}} char c_PrivateMemberCase;
94
95protected:
96 char ProtectedMemberCase;
97 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for protected member 'ProtectedMemberCase' [readability-identifier-naming]
98 // CHECK-FIXES: {{^}} char c_ProtectedMemberCase;
99
100public:
101 char PublicMemberCase;
102 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for public member 'PublicMemberCase' [readability-identifier-naming]
103 // CHECK-FIXES: {{^}} char c_PublicMemberCase;
104};
105
106static const int StaticConstantCase = 3;
107// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global constant 'StaticConstantCase' [readability-identifier-naming]
108// CHECK-FIXES: {{^}}static const int i_StaticConstantCase = 3;
109
110static int StaticVariableCase = 3;
111// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'StaticVariableCase' [readability-identifier-naming]
112// CHECK-FIXES: {{^}}static int i_StaticVariableCase = 3;
113
114struct MyStruct { int StructCase; };
115// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: invalid case style for public member 'StructCase' [readability-identifier-naming]
116// CHECK-FIXES: {{^}}struct MyStruct { int i_StructCase; };
117
118struct shouldBeCamelCaseStruct { int i_Field; };
119// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for struct 'shouldBeCamelCaseStruct' [readability-identifier-naming]
120// CHECK-FIXES: {{^}}struct ShouldBeCamelCaseStruct { int i_Field; };
121
122union MyUnion { int UnionCase; long l_UnionCase; };
123// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for union 'MyUnion' [readability-identifier-naming]
124// CHECK-MESSAGES: :[[@LINE-2]]:21: warning: invalid case style for public member 'UnionCase' [readability-identifier-naming]
125// CHECK-FIXES: {{^}}union myUnion { int i_UnionCase; long l_UnionCase; };
126
127//===----------------------------------------------------------------------===//
128// C string
129//===----------------------------------------------------------------------===//
130const char *NamePtr = "Name";
131// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global pointer 'NamePtr' [readability-identifier-naming]
132// CHECK-FIXES: {{^}}const char *sz_NamePtr = "Name";
133
134const char NameArray[] = "Name";
135// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global constant 'NameArray' [readability-identifier-naming]
136// CHECK-FIXES: {{^}}const char sz_NameArray[] = "Name";
137
138const char *NamePtrArray[] = {"AA", "BB"};
139// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'NamePtrArray' [readability-identifier-naming]
140// CHECK-FIXES: {{^}}const char *psz_NamePtrArray[] = {"AA", "BB"};
141
142const wchar_t *WideNamePtr = L"Name";
143// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global pointer 'WideNamePtr' [readability-identifier-naming]
144// CHECK-FIXES: {{^}}const wchar_t *wsz_WideNamePtr = L"Name";
145
146const wchar_t WideNameArray[] = L"Name";
147// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global constant 'WideNameArray' [readability-identifier-naming]
148// CHECK-FIXES: {{^}}const wchar_t wsz_WideNameArray[] = L"Name";
149
150const wchar_t *WideNamePtrArray[] = {L"AA", L"BB"};
151// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global variable 'WideNamePtrArray' [readability-identifier-naming]
152// CHECK-FIXES: {{^}}const wchar_t *pwsz_WideNamePtrArray[] = {L"AA", L"BB"};
153
154class C_MyClass4 {
155private:
156 char *Name = "Text";
157 // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for private member 'Name' [readability-identifier-naming]
158 // CHECK-FIXES: {{^}} char *sz_Name = "Text";
159
160 const char *ConstName = "Text";
161 // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for private member 'ConstName' [readability-identifier-naming]
162 // CHECK-FIXES: {{^}} const char *sz_ConstName = "Text";
163
164public:
165 const char* DuplicateString(const char* Input, size_t n_RequiredSize);
166 // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: invalid case style for pointer parameter 'Input' [readability-identifier-naming]
167 // CHECK-FIXES: {{^}} const char* DuplicateString(const char* sz_Input, size_t n_RequiredSize);
168
169 size_t UpdateText(const char* Buffer, size_t n_BufferSize);
170 // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: invalid case style for pointer parameter 'Buffer' [readability-identifier-naming]
171 // CHECK-FIXES: {{^}} size_t UpdateText(const char* sz_Buffer, size_t n_BufferSize);
172};
173
174
175//===----------------------------------------------------------------------===//
176// Microsoft Windows data types
177//===----------------------------------------------------------------------===//
178DWORD MsDword = 0;
179// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsDword' [readability-identifier-naming]
180// CHECK-FIXES: {{^}}DWORD dw_MsDword = 0;
181
182BYTE MsByte = 0;
183// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsByte' [readability-identifier-naming]
184// CHECK-FIXES: {{^}}BYTE by_MsByte = 0;
185
186WORD MsWord = 0;
187// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsWord' [readability-identifier-naming]
188// CHECK-FIXES: {{^}}WORD w_MsWord = 0;
189
190BOOL MsBool = 0;
191// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsBool' [readability-identifier-naming]
192// CHECK-FIXES: {{^}}BOOL b_MsBool = 0;
193
194BOOLEAN MsBoolean = 0;
195// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsBoolean' [readability-identifier-naming]
196// CHECK-FIXES: {{^}}BOOLEAN b_MsBoolean = 0;
197
198CHAR MsValueChar = 0;
199// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueChar' [readability-identifier-naming]
200// CHECK-FIXES: {{^}}CHAR c_MsValueChar = 0;
201
202UCHAR MsValueUchar = 0;
203// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueUchar' [readability-identifier-naming]
204// CHECK-FIXES: {{^}}UCHAR uc_MsValueUchar = 0;
205
206SHORT MsValueShort = 0;
207// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueShort' [readability-identifier-naming]
208// CHECK-FIXES: {{^}}SHORT s_MsValueShort = 0;
209
210USHORT MsValueUshort = 0;
211// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUshort' [readability-identifier-naming]
212// CHECK-FIXES: {{^}}USHORT us_MsValueUshort = 0;
213
214WORD MsValueWord = 0;
215// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueWord' [readability-identifier-naming]
216// CHECK-FIXES: {{^}}WORD w_MsValueWord = 0;
217
218DWORD MsValueDword = 0;
219// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueDword' [readability-identifier-naming]
220// CHECK-FIXES: {{^}}DWORD dw_MsValueDword = 0;
221
222DWORD32 MsValueDword32 = 0;
223// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueDword32' [readability-identifier-naming]
224// CHECK-FIXES: {{^}}DWORD32 dw32_MsValueDword32 = 0;
225
226DWORD64 MsValueDword64 = 0;
227// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueDword64' [readability-identifier-naming]
228// CHECK-FIXES: {{^}}DWORD64 dw64_MsValueDword64 = 0;
229
230LONG MsValueLong = 0;
231// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueLong' [readability-identifier-naming]
232// CHECK-FIXES: {{^}}LONG l_MsValueLong = 0;
233
234ULONG MsValueUlong = 0;
235// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueUlong' [readability-identifier-naming]
236// CHECK-FIXES: {{^}}ULONG ul_MsValueUlong = 0;
237
238ULONG32 MsValueUlong32 = 0;
239// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueUlong32' [readability-identifier-naming]
240// CHECK-FIXES: {{^}}ULONG32 ul32_MsValueUlong32 = 0;
241
242ULONG64 MsValueUlong64 = 0;
243// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueUlong64' [readability-identifier-naming]
244// CHECK-FIXES: {{^}}ULONG64 ul64_MsValueUlong64 = 0;
245
246ULONGLONG MsValueUlongLong = 0;
247// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'MsValueUlongLong' [readability-identifier-naming]
248// CHECK-FIXES: {{^}}ULONGLONG ull_MsValueUlongLong = 0;
249
250HANDLE MsValueHandle = 0;
251// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global pointer 'MsValueHandle' [readability-identifier-naming]
252// CHECK-FIXES: {{^}}HANDLE h_MsValueHandle = 0;
253
254INT MsValueInt = 0;
255// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'MsValueInt' [readability-identifier-naming]
256// CHECK-FIXES: {{^}}INT i_MsValueInt = 0;
257
258INT8 MsValueInt8 = 0;
259// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueInt8' [readability-identifier-naming]
260// CHECK-FIXES: {{^}}INT8 i8_MsValueInt8 = 0;
261
262INT16 MsValueInt16 = 0;
263// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueInt16' [readability-identifier-naming]
264// CHECK-FIXES: {{^}}INT16 i16_MsValueInt16 = 0;
265
266INT32 MsValueInt32 = 0;
267// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueInt32' [readability-identifier-naming]
268// CHECK-FIXES: {{^}}INT32 i32_MsValueInt32 = 0;
269
270INT64 MsValueINt64 = 0;
271// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueINt64' [readability-identifier-naming]
272// CHECK-FIXES: {{^}}INT64 i64_MsValueINt64 = 0;
273
274UINT MsValueUint = 0;
275// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueUint' [readability-identifier-naming]
276// CHECK-FIXES: {{^}}UINT ui_MsValueUint = 0;
277
278UINT8 MsValueUint8 = 0;
279// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueUint8' [readability-identifier-naming]
280// CHECK-FIXES: {{^}}UINT8 u8_MsValueUint8 = 0;
281
282UINT16 MsValueUint16 = 0;
283// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUint16' [readability-identifier-naming]
284// CHECK-FIXES: {{^}}UINT16 u16_MsValueUint16 = 0;
285
286UINT32 MsValueUint32 = 0;
287// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUint32' [readability-identifier-naming]
288// CHECK-FIXES: {{^}}UINT32 u32_MsValueUint32 = 0;
289
290UINT64 MsValueUint64 = 0;
291// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUint64' [readability-identifier-naming]
292// CHECK-FIXES: {{^}}UINT64 u64_MsValueUint64 = 0;
293
294PVOID MsValuePvoid = NULL;
295// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global pointer 'MsValuePvoid' [readability-identifier-naming]
296// CHECK-FIXES: {{^}}PVOID p_MsValuePvoid = NULL;
297
298
299//===----------------------------------------------------------------------===//
300// Array
301//===----------------------------------------------------------------------===//
302unsigned GlobalUnsignedArray[] = {1, 2, 3};
303// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'GlobalUnsignedArray' [readability-identifier-naming]
304// CHECK-FIXES: {{^}}unsigned a_GlobalUnsignedArray[] = {1, 2, 3};
305
306int GlobalIntArray[] = {1, 2, 3};
307// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'GlobalIntArray' [readability-identifier-naming]
308// CHECK-FIXES: {{^}}int a_GlobalIntArray[] = {1, 2, 3};
309
310int DataInt[1] = {0};
311// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'DataInt' [readability-identifier-naming]
312// CHECK-FIXES: {{^}}int a_DataInt[1] = {0};
313
314int DataArray[2] = {0};
315// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'DataArray' [readability-identifier-naming]
316// CHECK-FIXES: {{^}}int a_DataArray[2] = {0};
317
318
319//===----------------------------------------------------------------------===//
320// Pointer
321//===----------------------------------------------------------------------===//
322int *DataIntPtr[1] = {0};
323// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'DataIntPtr' [readability-identifier-naming]
324// CHECK-FIXES: {{^}}int *pa_DataIntPtr[1] = {0};
325
326void *BufferPtr1;
327// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global pointer 'BufferPtr1' [readability-identifier-naming]
328// CHECK-FIXES: {{^}}void *p_BufferPtr1;
329
330void **BufferPtr2;
331// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global pointer 'BufferPtr2' [readability-identifier-naming]
332// CHECK-FIXES: {{^}}void **pp_BufferPtr2;
333
334void **pBufferPtr3;
335// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global pointer 'pBufferPtr3' [readability-identifier-naming]
336// CHECK-FIXES: {{^}}void **pp_BufferPtr3;
337
338int *pBufferPtr4;
339// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global pointer 'pBufferPtr4' [readability-identifier-naming]
340// CHECK-FIXES: {{^}}int *pi_BufferPtr4;
341
342typedef void (*FUNC_PTR_HELLO)();
343FUNC_PTR_HELLO Hello = NULL;
344// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global pointer 'Hello' [readability-identifier-naming]
345// CHECK-FIXES: {{^}}FUNC_PTR_HELLO fn_Hello = NULL;
346
347void *ValueVoidPtr = NULL;
348// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global pointer 'ValueVoidPtr' [readability-identifier-naming]
349// CHECK-FIXES: {{^}}void *p_ValueVoidPtr = NULL;
350
351ptrdiff_t PtrDiff = NULL;
352// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'PtrDiff' [readability-identifier-naming]
353// CHECK-FIXES: {{^}}ptrdiff_t p_PtrDiff = NULL;
354
355int8_t *ValueI8Ptr;
356// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global pointer 'ValueI8Ptr' [readability-identifier-naming]
357// CHECK-FIXES: {{^}}int8_t *pi8_ValueI8Ptr;
358
359uint8_t *ValueU8Ptr;
360// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global pointer 'ValueU8Ptr' [readability-identifier-naming]
361// CHECK-FIXES: {{^}}uint8_t *pu8_ValueU8Ptr;
362
363unsigned char *ValueUcPtr;
364// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global pointer 'ValueUcPtr' [readability-identifier-naming]
365// CHECK-FIXES: {{^}}unsigned char *puc_ValueUcPtr;
366
367unsigned char **ValueUcPtr2;
368// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for global pointer 'ValueUcPtr2' [readability-identifier-naming]
369// CHECK-FIXES: {{^}}unsigned char **ppuc_ValueUcPtr2;
370
371void MyFunc2(void* Val){}
372// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for pointer parameter 'Val' [readability-identifier-naming]
373// CHECK-FIXES: {{^}}void MyFunc2(void* p_Val){}
374
375
376//===----------------------------------------------------------------------===//
377// Reference
378//===----------------------------------------------------------------------===//
379int i_ValueIndex = 1;
380int &RefValueIndex = i_ValueIndex;
381// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'RefValueIndex' [readability-identifier-naming]
382// CHECK-FIXES: {{^}}int &i_RefValueIndex = i_ValueIndex;
383
384const int &ConstRefValue = i_ValueIndex;
385// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'ConstRefValue' [readability-identifier-naming]
386// CHECK-FIXES: {{^}}const int &i_ConstRefValue = i_ValueIndex;
387
388long long ll_ValueLongLong = 2;
389long long &RefValueLongLong = ll_ValueLongLong;
390// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'RefValueLongLong' [readability-identifier-naming]
391// CHECK-FIXES: {{^}}long long &ll_RefValueLongLong = ll_ValueLongLong;
392
393
394//===----------------------------------------------------------------------===//
395// Various types
396//===----------------------------------------------------------------------===//
397int8_t ValueI8;
398// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueI8' [readability-identifier-naming]
399// CHECK-FIXES: {{^}}int8_t i8_ValueI8;
400
401int16_t ValueI16 = 0;
402// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI16' [readability-identifier-naming]
403// CHECK-FIXES: {{^}}int16_t i16_ValueI16 = 0;
404
405int32_t ValueI32 = 0;
406// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI32' [readability-identifier-naming]
407// CHECK-FIXES: {{^}}int32_t i32_ValueI32 = 0;
408
409int64_t ValueI64 = 0;
410// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI64' [readability-identifier-naming]
411// CHECK-FIXES: {{^}}int64_t i64_ValueI64 = 0;
412
413uint8_t ValueU8 = 0;
414// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueU8' [readability-identifier-naming]
415// CHECK-FIXES: {{^}}uint8_t u8_ValueU8 = 0;
416
417uint16_t ValueU16 = 0;
418// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU16' [readability-identifier-naming]
419// CHECK-FIXES: {{^}}uint16_t u16_ValueU16 = 0;
420
421uint32_t ValueU32 = 0;
422// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU32' [readability-identifier-naming]
423// CHECK-FIXES: {{^}}uint32_t u32_ValueU32 = 0;
424
425uint64_t ValueU64 = 0;
426// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU64' [readability-identifier-naming]
427// CHECK-FIXES: {{^}}uint64_t u64_ValueU64 = 0;
428
429float ValueFloat = 0;
430// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'ValueFloat' [readability-identifier-naming]
431// CHECK-FIXES: {{^}}float f_ValueFloat = 0;
432
433double ValueDouble = 0;
434// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueDouble' [readability-identifier-naming]
435// CHECK-FIXES: {{^}}double d_ValueDouble = 0;
436
437char ValueChar = 'c';
438// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueChar' [readability-identifier-naming]
439// CHECK-FIXES: {{^}}char c_ValueChar = 'c';
440
441bool ValueBool = true;
442// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueBool' [readability-identifier-naming]
443// CHECK-FIXES: {{^}}bool b_ValueBool = true;
444
445int ValueInt = 0;
446// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'ValueInt' [readability-identifier-naming]
447// CHECK-FIXES: {{^}}int i_ValueInt = 0;
448
449size_t ValueSize = 0;
450// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueSize' [readability-identifier-naming]
451// CHECK-FIXES: {{^}}size_t n_ValueSize = 0;
452
453wchar_t ValueWchar = 'w';
454// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueWchar' [readability-identifier-naming]
455// CHECK-FIXES: {{^}}wchar_t wc_ValueWchar = 'w';
456
457short ValueShort = 0;
458// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'ValueShort' [readability-identifier-naming]
459// CHECK-FIXES: {{^}}short s_ValueShort = 0;
460
461unsigned ValueUnsigned = 0;
462// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueUnsigned' [readability-identifier-naming]
463// CHECK-FIXES: {{^}}unsigned u_ValueUnsigned = 0;
464
465signed ValueSigned = 0;
466// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueSigned' [readability-identifier-naming]
467// CHECK-FIXES: {{^}}signed s_ValueSigned = 0;
468
469long ValueLong = 0;
470// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueLong' [readability-identifier-naming]
471// CHECK-FIXES: {{^}}long l_ValueLong = 0;
472
473long long ValueLongLong = 0;
474// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'ValueLongLong' [readability-identifier-naming]
475// CHECK-FIXES: {{^}}long long ll_ValueLongLong = 0;
476
477long long int ValueLongLongInt = 0;
478// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'ValueLongLongInt' [readability-identifier-naming]
479// CHECK-FIXES: {{^}}long long int lli_ValueLongLongInt = 0;
480
481long double ValueLongDouble = 0;
482// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'ValueLongDouble' [readability-identifier-naming]
483// CHECK-FIXES: {{^}}long double ld_ValueLongDouble = 0;
484
485signed int ValueSignedInt = 0;
486// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'ValueSignedInt' [readability-identifier-naming]
487// CHECK-FIXES: {{^}}signed int si_ValueSignedInt = 0;
488
489signed short ValueSignedShort = 0;
490// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global variable 'ValueSignedShort' [readability-identifier-naming]
491// CHECK-FIXES: {{^}}signed short ss_ValueSignedShort = 0;
492
493signed short int ValueSignedShortInt = 0;
494// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global variable 'ValueSignedShortInt' [readability-identifier-naming]
495// CHECK-FIXES: {{^}}signed short int ssi_ValueSignedShortInt = 0;
496
497signed long long ValueSignedLongLong = 0;
498// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global variable 'ValueSignedLongLong' [readability-identifier-naming]
499// CHECK-FIXES: {{^}}signed long long sll_ValueSignedLongLong = 0;
500
501signed long int ValueSignedLongInt = 0;
502// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for global variable 'ValueSignedLongInt' [readability-identifier-naming]
503// CHECK-FIXES: {{^}}signed long int sli_ValueSignedLongInt = 0;
504
505signed long ValueSignedLong = 0;
506// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'ValueSignedLong' [readability-identifier-naming]
507// CHECK-FIXES: {{^}}signed long sl_ValueSignedLong = 0;
508
509unsigned long long int ValueUnsignedLongLongInt = 0;
510// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: invalid case style for global variable 'ValueUnsignedLongLongInt' [readability-identifier-naming]
511// CHECK-FIXES: {{^}}unsigned long long int ulli_ValueUnsignedLongLongInt = 0;
512
513unsigned long long ValueUnsignedLongLong = 0;
514// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for global variable 'ValueUnsignedLongLong' [readability-identifier-naming]
515// CHECK-FIXES: {{^}}unsigned long long ull_ValueUnsignedLongLong = 0;
516
517unsigned long int ValueUnsignedLongInt = 0;
518// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for global variable 'ValueUnsignedLongInt' [readability-identifier-naming]
519// CHECK-FIXES: {{^}}unsigned long int uli_ValueUnsignedLongInt = 0;
520
521unsigned long ValueUnsignedLong = 0;
522// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'ValueUnsignedLong' [readability-identifier-naming]
523// CHECK-FIXES: {{^}}unsigned long ul_ValueUnsignedLong = 0;
524
525unsigned short int ValueUnsignedShortInt = 0;
526// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for global variable 'ValueUnsignedShortInt' [readability-identifier-naming]
527// CHECK-FIXES: {{^}}unsigned short int usi_ValueUnsignedShortInt = 0;
528
529unsigned short ValueUnsignedShort = 0;
530// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global variable 'ValueUnsignedShort' [readability-identifier-naming]
531// CHECK-FIXES: {{^}}unsigned short us_ValueUnsignedShort = 0;
532
533unsigned int ValueUnsignedInt = 0;
534// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global variable 'ValueUnsignedInt' [readability-identifier-naming]
535// CHECK-FIXES: {{^}}unsigned int ui_ValueUnsignedInt = 0;
536
537unsigned char ValueUnsignedChar = 0;
538// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'ValueUnsignedChar' [readability-identifier-naming]
539// CHECK-FIXES: {{^}}unsigned char uc_ValueUnsignedChar = 0;
540
541long int ValueLongInt = 0;
542// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueLongInt' [readability-identifier-naming]
543// CHECK-FIXES: {{^}}long int li_ValueLongInt = 0;
544
545
546//===----------------------------------------------------------------------===//
547// Specifier, Qualifier, Other keywords
548//===----------------------------------------------------------------------===//
549volatile int VolatileInt = 0;
550// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global variable 'VolatileInt' [readability-identifier-naming]
551// CHECK-FIXES: {{^}}volatile int i_VolatileInt = 0;
552
553thread_local int ThreadLocalValueInt = 0;
554// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global variable 'ThreadLocalValueInt' [readability-identifier-naming]
555// CHECK-FIXES: {{^}}thread_local int i_ThreadLocalValueInt = 0;
556
557extern int ExternValueInt;
558// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'ExternValueInt' [readability-identifier-naming]
559// CHECK-FIXES: {{^}}extern int i_ExternValueInt;
560
561struct DataBuffer {
562 mutable size_t Size;
563};
564// CHECK-MESSAGES: :[[@LINE-2]]:20: warning: invalid case style for public member 'Size' [readability-identifier-naming]
565// CHECK-FIXES: {{^}} mutable size_t n_Size;
566
567static constexpr int const &ConstExprInt = 42;
568// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: invalid case style for constexpr variable 'ConstExprInt' [readability-identifier-naming]
569// CHECK-FIXES: {{^}}static constexpr int const &i_ConstExprInt = 42;
570
571
572//===----------------------------------------------------------------------===//
573// Redefined types
574//===----------------------------------------------------------------------===//
575typedef int INDEX;
576INDEX iIndex = 0;
577// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'iIndex' [readability-identifier-naming]
578// CHECK-FIXES: {{^}}INDEX Index = 0;
579
580
581//===----------------------------------------------------------------------===//
582// Class
583//===----------------------------------------------------------------------===//
584class ClassCase { int Func(); };
585// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'ClassCase' [readability-identifier-naming]
586// CHECK-FIXES: {{^}}class C_ClassCase { int Func(); };
587
588class AbstractClassCase { virtual int Func() = 0; };
589// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for abstract class 'AbstractClassCase' [readability-identifier-naming]
590// CHECK-FIXES: {{^}}class I_AbstractClassCase { virtual int Func() = 0; };
591
592class AbstractClassCase1 { virtual int Func1() = 0; int Func2(); };
593// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for abstract class 'AbstractClassCase1' [readability-identifier-naming]
594// CHECK-FIXES: {{^}}class I_AbstractClassCase1 { virtual int Func1() = 0; int Func2(); };
595
596class ClassConstantCase { public: static const int i_ConstantCase; };
597// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'ClassConstantCase' [readability-identifier-naming]
598// CHECK-FIXES: {{^}}class C_ClassConstantCase { public: static const int i_ConstantCase; };
599
600//===----------------------------------------------------------------------===//
601// Other Cases
602//===----------------------------------------------------------------------===//
603int lower_case = 0;
604// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'lower_case' [readability-identifier-naming]
605// CHECK-FIXES: {{^}}int i_LowerCase = 0;
606
607int lower_case1 = 0;
608// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'lower_case1' [readability-identifier-naming]
609// CHECK-FIXES: {{^}}int i_LowerCase1 = 0;
610
611int lower_case_2 = 0;
612// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'lower_case_2' [readability-identifier-naming]
613// CHECK-FIXES: {{^}}int i_LowerCase2 = 0;
614
615int UPPER_CASE = 0;
616// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'UPPER_CASE' [readability-identifier-naming]
617// CHECK-FIXES: {{^}}int i_UpperCase = 0;
618
619int UPPER_CASE_1 = 0;
620// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'UPPER_CASE_1' [readability-identifier-naming]
621// CHECK-FIXES: {{^}}int i_UpperCase1 = 0;
622
623int camelBack = 0;
624// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camelBack' [readability-identifier-naming]
625// CHECK-FIXES: {{^}}int i_CamelBack = 0;
626
627int camelBack_1 = 0;
628// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camelBack_1' [readability-identifier-naming]
629// CHECK-FIXES: {{^}}int i_CamelBack1 = 0;
630
631int camelBack2 = 0;
632// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camelBack2' [readability-identifier-naming]
633// CHECK-FIXES: {{^}}int i_CamelBack2 = 0;
634
635int CamelCase = 0;
636// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'CamelCase' [readability-identifier-naming]
637// CHECK-FIXES: {{^}}int i_CamelCase = 0;
638
639int CamelCase_1 = 0;
640// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'CamelCase_1' [readability-identifier-naming]
641// CHECK-FIXES: {{^}}int i_CamelCase1 = 0;
642
643int CamelCase2 = 0;
644// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'CamelCase2' [readability-identifier-naming]
645// CHECK-FIXES: {{^}}int i_CamelCase2 = 0;
646
647int camel_Snake_Back = 0;
648// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camel_Snake_Back' [readability-identifier-naming]
649// CHECK-FIXES: {{^}}int i_CamelSnakeBack = 0;
650
651int camel_Snake_Back_1 = 0;
652// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camel_Snake_Back_1' [readability-identifier-naming]
653// CHECK-FIXES: {{^}}int i_CamelSnakeBack1 = 0;
654
655int Camel_Snake_Case = 0;
656// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'Camel_Snake_Case' [readability-identifier-naming]
657// CHECK-FIXES: {{^}}int i_CamelSnakeCase = 0;
658
659int Camel_Snake_Case_1 = 0;
660// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'Camel_Snake_Case_1' [readability-identifier-naming]
661// CHECK-FIXES: {{^}}int i_CamelSnakeCase1 = 0;
662
663//===----------------------------------------------------------------------===//
664// Enum
665//===----------------------------------------------------------------------===//
666enum REV_TYPE { RevValid };
667// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for enum constant 'RevValid' [readability-identifier-naming]
668// CHECK-FIXES: {{^}}enum REV_TYPE { rt_RevValid };
669
670enum EnumConstantCase { OneByte, TwoByte };
671// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: invalid case style for enum constant 'OneByte' [readability-identifier-naming]
672// CHECK-MESSAGES: :[[@LINE-2]]:34: warning: invalid case style for enum constant 'TwoByte' [readability-identifier-naming]
673// CHECK-FIXES: {{^}}enum EnumConstantCase { ecc_OneByte, ecc_TwoByte };
674
675enum class ScopedEnumConstantCase { Case1 };
676// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: invalid case style for scoped enum constant 'Case1' [readability-identifier-naming]
677// CHECK-FIXES: {{^}}enum class ScopedEnumConstantCase { secc_Case1 };
678// clang-format on
679

source code of clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-lower-case-prefix.cpp