blob: 9c10d61f5f6f5fc4b28568d1e53081b191a69fd5 [file] [log] [blame]
Manuel Klimek8f9e4442015-10-22 14:54:50 +00001// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
Alexander Kornienko76c28802015-08-19 11:15:36 +00002// RUN: -config='{CheckOptions: [ \
3// RUN: {key: readability-identifier-naming.AbstractClassCase, value: CamelCase}, \
4// RUN: {key: readability-identifier-naming.AbstractClassPrefix, value: 'A'}, \
5// RUN: {key: readability-identifier-naming.ClassCase, value: CamelCase}, \
6// RUN: {key: readability-identifier-naming.ClassPrefix, value: 'C'}, \
7// RUN: {key: readability-identifier-naming.ClassConstantCase, value: CamelCase}, \
8// RUN: {key: readability-identifier-naming.ClassConstantPrefix, value: 'k'}, \
9// RUN: {key: readability-identifier-naming.ClassMemberCase, value: CamelCase}, \
10// RUN: {key: readability-identifier-naming.ClassMethodCase, value: camelBack}, \
11// RUN: {key: readability-identifier-naming.ConstantCase, value: UPPER_CASE}, \
12// RUN: {key: readability-identifier-naming.ConstantSuffix, value: '_CST'}, \
13// RUN: {key: readability-identifier-naming.ConstexprFunctionCase, value: lower_case}, \
14// RUN: {key: readability-identifier-naming.ConstexprMethodCase, value: lower_case}, \
15// RUN: {key: readability-identifier-naming.ConstexprVariableCase, value: lower_case}, \
16// RUN: {key: readability-identifier-naming.EnumCase, value: CamelCase}, \
17// RUN: {key: readability-identifier-naming.EnumPrefix, value: 'E'}, \
18// RUN: {key: readability-identifier-naming.EnumConstantCase, value: UPPER_CASE}, \
19// RUN: {key: readability-identifier-naming.FunctionCase, value: camelBack}, \
20// RUN: {key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE}, \
21// RUN: {key: readability-identifier-naming.GlobalFunctionCase, value: CamelCase}, \
22// RUN: {key: readability-identifier-naming.GlobalVariableCase, value: lower_case}, \
23// RUN: {key: readability-identifier-naming.GlobalVariablePrefix, value: 'g_'}, \
24// RUN: {key: readability-identifier-naming.InlineNamespaceCase, value: lower_case}, \
25// RUN: {key: readability-identifier-naming.LocalConstantCase, value: CamelCase}, \
26// RUN: {key: readability-identifier-naming.LocalConstantPrefix, value: 'k'}, \
27// RUN: {key: readability-identifier-naming.LocalVariableCase, value: lower_case}, \
28// RUN: {key: readability-identifier-naming.MemberCase, value: CamelCase}, \
29// RUN: {key: readability-identifier-naming.MemberPrefix, value: 'm_'}, \
30// RUN: {key: readability-identifier-naming.ConstantMemberCase, value: lower_case}, \
31// RUN: {key: readability-identifier-naming.PrivateMemberPrefix, value: '__'}, \
32// RUN: {key: readability-identifier-naming.ProtectedMemberPrefix, value: '_'}, \
33// RUN: {key: readability-identifier-naming.PublicMemberCase, value: lower_case}, \
34// RUN: {key: readability-identifier-naming.MethodCase, value: camelBack}, \
35// RUN: {key: readability-identifier-naming.PrivateMethodPrefix, value: '__'}, \
36// RUN: {key: readability-identifier-naming.ProtectedMethodPrefix, value: '_'}, \
37// RUN: {key: readability-identifier-naming.NamespaceCase, value: lower_case}, \
38// RUN: {key: readability-identifier-naming.ParameterCase, value: camelBack}, \
39// RUN: {key: readability-identifier-naming.ParameterPrefix, value: 'a_'}, \
40// RUN: {key: readability-identifier-naming.ConstantParameterCase, value: camelBack}, \
41// RUN: {key: readability-identifier-naming.ConstantParameterPrefix, value: 'i_'}, \
42// RUN: {key: readability-identifier-naming.ParameterPackCase, value: camelBack}, \
43// RUN: {key: readability-identifier-naming.PureFunctionCase, value: lower_case}, \
44// RUN: {key: readability-identifier-naming.PureMethodCase, value: camelBack}, \
45// RUN: {key: readability-identifier-naming.StaticConstantCase, value: UPPER_CASE}, \
46// RUN: {key: readability-identifier-naming.StaticVariableCase, value: camelBack}, \
47// RUN: {key: readability-identifier-naming.StaticVariablePrefix, value: 's_'}, \
48// RUN: {key: readability-identifier-naming.StructCase, value: lower_case}, \
49// RUN: {key: readability-identifier-naming.TemplateParameterCase, value: UPPER_CASE}, \
50// RUN: {key: readability-identifier-naming.TemplateTemplateParameterCase, value: CamelCase}, \
51// RUN: {key: readability-identifier-naming.TemplateUsingCase, value: lower_case}, \
52// RUN: {key: readability-identifier-naming.TemplateUsingPrefix, value: 'u_'}, \
53// RUN: {key: readability-identifier-naming.TypeTemplateParameterCase, value: camelBack}, \
54// RUN: {key: readability-identifier-naming.TypeTemplateParameterSuffix, value: '_t'}, \
55// RUN: {key: readability-identifier-naming.TypedefCase, value: lower_case}, \
56// RUN: {key: readability-identifier-naming.TypedefSuffix, value: '_t'}, \
57// RUN: {key: readability-identifier-naming.UnionCase, value: CamelCase}, \
58// RUN: {key: readability-identifier-naming.UnionPrefix, value: 'U'}, \
59// RUN: {key: readability-identifier-naming.UsingCase, value: lower_case}, \
60// RUN: {key: readability-identifier-naming.ValueTemplateParameterCase, value: camelBack}, \
61// RUN: {key: readability-identifier-naming.VariableCase, value: lower_case}, \
Kirill Bobyrev5d8f0712016-07-20 12:28:38 +000062// RUN: {key: readability-identifier-naming.VirtualMethodCase, value: Camel_Snake_Case}, \
Alexander Kornienko76c28802015-08-19 11:15:36 +000063// RUN: {key: readability-identifier-naming.VirtualMethodPrefix, value: 'v_'}, \
Alexander Kornienko21503902016-06-17 09:25:24 +000064// RUN: {key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE}, \
Kirill Bobyrev5d8f0712016-07-20 12:28:38 +000065// RUN: {key: readability-identifier-naming.TypeAliasCase, value: camel_Snake_Back}, \
Alexander Kornienko5ae76e02016-06-07 09:11:19 +000066// RUN: {key: readability-identifier-naming.TypeAliasSuffix, value: '_t'}, \
Alexander Kornienko76c28802015-08-19 11:15:36 +000067// RUN: {key: readability-identifier-naming.IgnoreFailedSplit, value: 0} \
Alexander Kornienko30c423b2015-10-01 09:19:40 +000068// RUN: ]}' -- -std=c++11 -fno-delayed-template-parsing \
69// RUN: -I%S/Inputs/readability-identifier-naming \
70// RUN: -isystem %S/Inputs/readability-identifier-naming/system
Alexander Kornienko76c28802015-08-19 11:15:36 +000071
Alexander Kornienko3d777682015-09-28 08:59:12 +000072// clang-format off
73
Alexander Kornienko30c423b2015-10-01 09:19:40 +000074#include <system-header.h>
75#include "user-header.h"
76// NO warnings or fixes expected from declarations within header files without
77// the -header-filter= option
78
Alexander Kornienko76c28802015-08-19 11:15:36 +000079namespace FOO_NS {
Mike Aizatsky5b55df42015-12-04 20:57:03 +000080// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for namespace 'FOO_NS' [readability-identifier-naming]
Alexander Kornienko76c28802015-08-19 11:15:36 +000081// CHECK-FIXES: {{^}}namespace foo_ns {{{$}}
82inline namespace InlineNamespace {
Mike Aizatsky5b55df42015-12-04 20:57:03 +000083// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for inline namespace 'InlineNamespace'
Alexander Kornienko76c28802015-08-19 11:15:36 +000084// CHECK-FIXES: {{^}}inline namespace inline_namespace {{{$}}
85
Alexander Kornienko30c423b2015-10-01 09:19:40 +000086SYSTEM_NS::structure g_s1;
87// NO warnings or fixes expected as SYSTEM_NS and structure are declared in a header file
88
89USER_NS::object g_s2;
90// NO warnings or fixes expected as USER_NS and object are declared in a header file
91
92SYSTEM_MACRO(var1);
93// NO warnings or fixes expected as var1 is from macro expansion
94
95USER_MACRO(var2);
96// NO warnings or fixes expected as var2 is declared in a macro expansion
97
98int global;
99#define USE_IN_MACRO(m) auto use_##m = m
100USE_IN_MACRO(global);
101// NO warnings or fixes expected as global is used in a macro expansion
102
Alexander Kornienko76c28802015-08-19 11:15:36 +0000103#define BLA int FOO_bar
104BLA;
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000105// NO warnings or fixes expected as FOO_bar is from macro expansion
Alexander Kornienko76c28802015-08-19 11:15:36 +0000106
107enum my_enumeration {
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000108// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for enum 'my_enumeration'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000109// CHECK-FIXES: {{^}}enum EMyEnumeration {{{$}}
110 MyConstant = 1,
111// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for enum constant 'MyConstant'
112// CHECK-FIXES: {{^}} MY_CONSTANT = 1,{{$}}
113 your_CONST = 1,
114// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for enum constant 'your_CONST'
115// CHECK-FIXES: {{^}} YOUR_CONST = 1,{{$}}
116 THIS_ConstValue = 1,
117// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for enum constant 'THIS_ConstValue'
118// CHECK-FIXES: {{^}} THIS_CONST_VALUE = 1,{{$}}
119};
120
121constexpr int ConstExpr_variable = MyConstant;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000122// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for constexpr variable 'ConstExpr_variable'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000123// CHECK-FIXES: {{^}}constexpr int const_expr_variable = MY_CONSTANT;{{$}}
124
125class my_class {
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000126// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_class'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000127// CHECK-FIXES: {{^}}class CMyClass {{{$}}
128 my_class();
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000129// CHECK-FIXES: {{^}} CMyClass();{{$}}
130
131 ~
132 my_class();
133// (space in destructor token test, we could check trigraph but they will be deprecated)
134// CHECK-FIXES: {{^}} ~{{$}}
135// CHECK-FIXES: {{^}} CMyClass();{{$}}
Alexander Kornienko76c28802015-08-19 11:15:36 +0000136
137 const int MEMBER_one_1 = ConstExpr_variable;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000138// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for constant member 'MEMBER_one_1'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000139// CHECK-FIXES: {{^}} const int member_one_1 = const_expr_variable;{{$}}
140 int member2 = 2;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000141// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member 'member2'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000142// CHECK-FIXES: {{^}} int __member2 = 2;{{$}}
143
144private:
145 int private_member = 3;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000146// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for private member 'private_member'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000147// CHECK-FIXES: {{^}} int __private_member = 3;{{$}}
148
149protected:
150 int ProtMember;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000151// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for protected member 'ProtMember'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000152// CHECK-FIXES: {{^}} int _ProtMember;{{$}}
153
154public:
155 int PubMem;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000156// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for public member 'PubMem'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000157// CHECK-FIXES: {{^}} int pub_mem;{{$}}
158
159 static const int classConstant;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000160// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for class constant 'classConstant'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000161// CHECK-FIXES: {{^}} static const int kClassConstant;{{$}}
162 static int ClassMember_2;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000163// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for class member 'ClassMember_2'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000164// CHECK-FIXES: {{^}} static int ClassMember2;{{$}}
165};
166
167const int my_class::classConstant = 4;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000168// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for class constant 'classConstant'
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000169// CHECK-FIXES: {{^}}const int CMyClass::kClassConstant = 4;{{$}}
Alexander Kornienko76c28802015-08-19 11:15:36 +0000170
171int my_class::ClassMember_2 = 5;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000172// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for class member 'ClassMember_2'
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000173// CHECK-FIXES: {{^}}int CMyClass::ClassMember2 = 5;{{$}}
174
175class my_derived_class : public virtual my_class {};
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000176// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_derived_class'
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000177// CHECK-FIXES: {{^}}class CMyDerivedClass : public virtual CMyClass {};{{$}}
178
179class CMyWellNamedClass {};
180// No warning expected as this class is well named.
181
182template<typename T>
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000183// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for type template parameter 'T'
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000184// CHECK-FIXES: {{^}}template<typename t_t>{{$}}
185class my_templated_class : CMyWellNamedClass {};
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000186// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_templated_class'
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000187// CHECK-FIXES: {{^}}class CMyTemplatedClass : CMyWellNamedClass {};{{$}}
188
189template<typename T>
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000190// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for type template parameter 'T'
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000191// CHECK-FIXES: {{^}}template<typename t_t>{{$}}
192class my_other_templated_class : my_templated_class< my_class>, private my_derived_class {};
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000193// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_other_templated_class'
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000194// CHECK-FIXES: {{^}}class CMyOtherTemplatedClass : CMyTemplatedClass< CMyClass>, private CMyDerivedClass {};{{$}}
195
196template<typename t_t>
Alexander Kornienko5ae76e02016-06-07 09:11:19 +0000197using mysuper_tpl_t = my_other_templated_class <:: FOO_NS ::my_class>;
198// CHECK-FIXES: {{^}}using mysuper_tpl_t = CMyOtherTemplatedClass <:: foo_ns ::CMyClass>;{{$}}
Alexander Kornienko76c28802015-08-19 11:15:36 +0000199
200const int global_Constant = 6;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000201// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global constant 'global_Constant'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000202// CHECK-FIXES: {{^}}const int GLOBAL_CONSTANT = 6;{{$}}
203int Global_variable = 7;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000204// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'Global_variable'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000205// CHECK-FIXES: {{^}}int g_global_variable = 7;{{$}}
206
207void global_function(int PARAMETER_1, int const CONST_parameter) {
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000208// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global function 'global_function'
209// CHECK-MESSAGES: :[[@LINE-2]]:26: warning: invalid case style for parameter 'PARAMETER_1'
210// CHECK-MESSAGES: :[[@LINE-3]]:49: warning: invalid case style for constant parameter 'CONST_parameter'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000211// CHECK-FIXES: {{^}}void GlobalFunction(int a_parameter1, int const i_constParameter) {{{$}}
212 static const int THIS_static_ConsTant = 4;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000213// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for static constant 'THIS_static_ConsTant'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000214// CHECK-FIXES: {{^}} static const int THIS_STATIC_CONS_TANT = 4;{{$}}
215 static int THIS_static_variable;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000216// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for static variable 'THIS_static_variable'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000217// CHECK-FIXES: {{^}} static int s_thisStaticVariable;{{$}}
218 int const local_Constant = 3;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000219// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for local constant 'local_Constant'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000220// CHECK-FIXES: {{^}} int const kLocalConstant = 3;{{$}}
221 int LOCAL_VARIABLE;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000222// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for local variable 'LOCAL_VARIABLE'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000223// CHECK-FIXES: {{^}} int local_variable;{{$}}
224
225 int LOCAL_Array__[] = {0, 1, 2};
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000226// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for local variable 'LOCAL_Array__'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000227// CHECK-FIXES: {{^}} int local_array[] = {0, 1, 2};{{$}}
228
229 for (auto _ : LOCAL_Array__) {
230 }
231}
232
233template<typename ... TYPE_parameters>
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000234// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: invalid case style for type template parameter 'TYPE_parameters'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000235// CHECK-FIXES: {{^}}template<typename ... typeParameters_t>{{$}}
236void Global_Fun(TYPE_parameters... PARAMETER_PACK) {
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000237// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global function 'Global_Fun'
238// CHECK-MESSAGES: :[[@LINE-2]]:36: warning: invalid case style for parameter pack 'PARAMETER_PACK'
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000239// CHECK-FIXES: {{^}}void GlobalFun(typeParameters_t... parameterPack) {{{$}}
Alexander Kornienko76c28802015-08-19 11:15:36 +0000240 global_function(1, 2);
241// CHECK-FIXES: {{^}} GlobalFunction(1, 2);{{$}}
242 FOO_bar = Global_variable;
243// CHECK-FIXES: {{^}} FOO_bar = g_global_variable;{{$}}
244// NO fix expected for FOO_bar declared in macro expansion
245}
246
247template<template<typename> class TPL_parameter, int COUNT_params, typename ... TYPE_parameters>
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000248// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: invalid case style for template template parameter 'TPL_parameter'
249// CHECK-MESSAGES: :[[@LINE-2]]:54: warning: invalid case style for value template parameter 'COUNT_params'
250// CHECK-MESSAGES: :[[@LINE-3]]:81: warning: invalid case style for type template parameter 'TYPE_parameters'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000251// CHECK-FIXES: {{^}}template<template<typename> class TplParameter, int countParams, typename ... typeParameters_t>{{$}}
252class test_CLASS {
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000253// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'test_CLASS'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000254// CHECK-FIXES: {{^}}class CTestClass {{{$}}
255};
256
257class abstract_class {
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000258// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for abstract class 'abstract_class'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000259// CHECK-FIXES: {{^}}class AAbstractClass {{{$}}
260 virtual ~abstract_class() = 0;
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000261// CHECK-FIXES: {{^}} virtual ~AAbstractClass() = 0;{{$}}
Alexander Kornienko76c28802015-08-19 11:15:36 +0000262 virtual void VIRTUAL_METHOD();
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000263// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for virtual method 'VIRTUAL_METHOD'
Kirill Bobyrev5d8f0712016-07-20 12:28:38 +0000264// CHECK-FIXES: {{^}} virtual void v_Virtual_Method();{{$}}
Alexander Kornienko76c28802015-08-19 11:15:36 +0000265 void non_Virtual_METHOD() {}
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000266// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for private method 'non_Virtual_METHOD'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000267// CHECK-FIXES: {{^}} void __non_Virtual_METHOD() {}{{$}}
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000268
269public:
Alexander Kornienko76c28802015-08-19 11:15:36 +0000270 static void CLASS_METHOD() {}
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000271// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for class method 'CLASS_METHOD'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000272// CHECK-FIXES: {{^}} static void classMethod() {}{{$}}
273
274 constexpr int CST_expr_Method() { return 2; }
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000275// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for constexpr method 'CST_expr_Method'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000276// CHECK-FIXES: {{^}} constexpr int cst_expr_method() { return 2; }{{$}}
277
278private:
279 void PRIVate_Method();
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000280// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for private method 'PRIVate_Method'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000281// CHECK-FIXES: {{^}} void __PRIVate_Method();{{$}}
282protected:
283 void protected_Method();
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000284// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for protected method 'protected_Method'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000285// CHECK-FIXES: {{^}} void _protected_Method();{{$}}
286public:
287 void public_Method();
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000288// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for method 'public_Method'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000289// CHECK-FIXES: {{^}} void publicMethod();{{$}}
290};
291
292constexpr int CE_function() { return 3; }
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000293// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for constexpr function 'CE_function'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000294// CHECK-FIXES: {{^}}constexpr int ce_function() { return 3; }{{$}}
295
296struct THIS___Structure {
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000297// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for struct 'THIS___Structure'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000298// CHECK-FIXES: {{^}}struct this_structure {{{$}}
299 THIS___Structure();
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000300// CHECK-FIXES: {{^}} this_structure();{{$}}
Alexander Kornienko76c28802015-08-19 11:15:36 +0000301
302 union __MyUnion_is_wonderful__ {};
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000303// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for union '__MyUnion_is_wonderful__'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000304// CHECK-FIXES: {{^}} union UMyUnionIsWonderful {};{{$}}
305};
306
307typedef THIS___Structure struct_type;
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000308// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for typedef 'struct_type'
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000309// CHECK-FIXES: {{^}}typedef this_structure struct_type_t;{{$}}
Alexander Kornienko76c28802015-08-19 11:15:36 +0000310
Alexander Kornienko21503902016-06-17 09:25:24 +0000311struct_type GlobalTypedefTestFunction(struct_type a_argument1) {
312// CHECK-FIXES: {{^}}struct_type_t GlobalTypedefTestFunction(struct_type_t a_argument1) {
313 struct_type typedef_test_1;
314// CHECK-FIXES: {{^}} struct_type_t typedef_test_1;
315}
316
Alexander Kornienko5ae76e02016-06-07 09:11:19 +0000317using my_struct_type = THIS___Structure;
318// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 'my_struct_type'
Kirill Bobyrev5d8f0712016-07-20 12:28:38 +0000319// CHECK-FIXES: {{^}}using my_Struct_Type_t = this_structure;{{$}}
Alexander Kornienko5ae76e02016-06-07 09:11:19 +0000320
321template<typename t_t>
322using SomeOtherTemplate = my_other_templated_class <:: FOO_NS ::my_class>;
323// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 'SomeOtherTemplate'
Kirill Bobyrev5d8f0712016-07-20 12:28:38 +0000324// CHECK-FIXES: {{^}}using some_Other_Template_t = CMyOtherTemplatedClass <:: foo_ns ::CMyClass>;{{$}}
Alexander Kornienko5ae76e02016-06-07 09:11:19 +0000325
Alexander Kornienko76c28802015-08-19 11:15:36 +0000326static void static_Function() {
Mike Aizatsky5b55df42015-12-04 20:57:03 +0000327// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for function 'static_Function'
Alexander Kornienko76c28802015-08-19 11:15:36 +0000328// CHECK-FIXES: {{^}}static void staticFunction() {{{$}}
Alexander Kornienko30c423b2015-10-01 09:19:40 +0000329
330 ::FOO_NS::InlineNamespace::abstract_class::CLASS_METHOD();
331// CHECK-FIXES: {{^}} ::foo_ns::inline_namespace::AAbstractClass::classMethod();{{$}}
332 ::FOO_NS::InlineNamespace::static_Function();
333// CHECK-FIXES: {{^}} ::foo_ns::inline_namespace::staticFunction();{{$}}
334
335 using ::FOO_NS::InlineNamespace::CE_function;
336// CHECK-FIXES: {{^}} using ::foo_ns::inline_namespace::ce_function;{{$}}
Alexander Kornienko76c28802015-08-19 11:15:36 +0000337}
338
Alexander Kornienko21503902016-06-17 09:25:24 +0000339#define MY_TEST_Macro(X) X()
340// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for macro definition 'MY_TEST_Macro'
341// CHECK-FIXES: {{^}}#define MY_TEST_MACRO(X) X()
342
343void MY_TEST_Macro(function) {}
344// CHECK-FIXES: {{^}}void MY_TEST_MACRO(function) {}
Alexander Kornienko76c28802015-08-19 11:15:36 +0000345}
346}
Matthias Gehrea9e812b2016-07-09 20:09:28 +0000347
348template <typename t_t> struct a {
349 typename t_t::template b<> c;
350};
351
352template <template <typename> class A> struct b { A<int> c; };