| Manuel Klimek | 8f9e444 | 2015-10-22 14:54:50 +0000 | [diff] [blame] | 1 | // RUN: %check_clang_tidy %s readability-identifier-naming %t -- \ | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 2 | // 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}, \ | 
|  | 62 | // RUN:     {key: readability-identifier-naming.VirtualMethodCase, value: UPPER_CASE}, \ | 
|  | 63 | // RUN:     {key: readability-identifier-naming.VirtualMethodPrefix, value: 'v_'}, \ | 
| Alexander Kornienko | 2150390 | 2016-06-17 09:25:24 +0000 | [diff] [blame] | 64 | // RUN:     {key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE}, \ | 
| Alexander Kornienko | 5ae76e0 | 2016-06-07 09:11:19 +0000 | [diff] [blame] | 65 | // RUN:     {key: readability-identifier-naming.TypeAliasCase, value: lower_case}, \ | 
|  | 66 | // RUN:     {key: readability-identifier-naming.TypeAliasSuffix, value: '_t'}, \ | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 67 | // RUN:     {key: readability-identifier-naming.IgnoreFailedSplit, value: 0} \ | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 68 | // 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 Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 71 |  | 
| Alexander Kornienko | 3d77768 | 2015-09-28 08:59:12 +0000 | [diff] [blame] | 72 | // clang-format off | 
|  | 73 |  | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 74 | #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 Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 79 | namespace FOO_NS { | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 80 | // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for namespace 'FOO_NS' [readability-identifier-naming] | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 81 | // CHECK-FIXES: {{^}}namespace foo_ns {{{$}} | 
|  | 82 | inline namespace InlineNamespace { | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 83 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for inline namespace 'InlineNamespace' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 84 | // CHECK-FIXES: {{^}}inline namespace inline_namespace {{{$}} | 
|  | 85 |  | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 86 | SYSTEM_NS::structure g_s1; | 
|  | 87 | // NO warnings or fixes expected as SYSTEM_NS and structure are declared in a header file | 
|  | 88 |  | 
|  | 89 | USER_NS::object g_s2; | 
|  | 90 | // NO warnings or fixes expected as USER_NS and object are declared in a header file | 
|  | 91 |  | 
|  | 92 | SYSTEM_MACRO(var1); | 
|  | 93 | // NO warnings or fixes expected as var1 is from macro expansion | 
|  | 94 |  | 
|  | 95 | USER_MACRO(var2); | 
|  | 96 | // NO warnings or fixes expected as var2 is declared in a macro expansion | 
|  | 97 |  | 
|  | 98 | int global; | 
|  | 99 | #define USE_IN_MACRO(m) auto use_##m = m | 
|  | 100 | USE_IN_MACRO(global); | 
|  | 101 | // NO warnings or fixes expected as global is used in a macro expansion | 
|  | 102 |  | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 103 | #define BLA int FOO_bar | 
|  | 104 | BLA; | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 105 | // NO warnings or fixes expected as FOO_bar is from macro expansion | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 106 |  | 
|  | 107 | enum my_enumeration { | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 108 | // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for enum 'my_enumeration' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 109 | // 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 |  | 
|  | 121 | constexpr int ConstExpr_variable = MyConstant; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 122 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for constexpr variable 'ConstExpr_variable' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 123 | // CHECK-FIXES: {{^}}constexpr int const_expr_variable = MY_CONSTANT;{{$}} | 
|  | 124 |  | 
|  | 125 | class my_class { | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 126 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_class' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 127 | // CHECK-FIXES: {{^}}class CMyClass {{{$}} | 
|  | 128 | my_class(); | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 129 | // 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 Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 136 |  | 
|  | 137 | const int MEMBER_one_1 = ConstExpr_variable; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 138 | // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for constant member 'MEMBER_one_1' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 139 | // CHECK-FIXES: {{^}}  const int member_one_1 = const_expr_variable;{{$}} | 
|  | 140 | int member2 = 2; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 141 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member 'member2' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 142 | // CHECK-FIXES: {{^}}  int __member2 = 2;{{$}} | 
|  | 143 |  | 
|  | 144 | private: | 
|  | 145 | int private_member = 3; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 146 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for private member 'private_member' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 147 | // CHECK-FIXES: {{^}}    int __private_member = 3;{{$}} | 
|  | 148 |  | 
|  | 149 | protected: | 
|  | 150 | int ProtMember; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 151 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for protected member 'ProtMember' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 152 | // CHECK-FIXES: {{^}}    int _ProtMember;{{$}} | 
|  | 153 |  | 
|  | 154 | public: | 
|  | 155 | int PubMem; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 156 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for public member 'PubMem' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 157 | // CHECK-FIXES: {{^}}    int pub_mem;{{$}} | 
|  | 158 |  | 
|  | 159 | static const int classConstant; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 160 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for class constant 'classConstant' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 161 | // CHECK-FIXES: {{^}}    static const int kClassConstant;{{$}} | 
|  | 162 | static int ClassMember_2; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 163 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for class member 'ClassMember_2' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 164 | // CHECK-FIXES: {{^}}    static int ClassMember2;{{$}} | 
|  | 165 | }; | 
|  | 166 |  | 
|  | 167 | const int my_class::classConstant = 4; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 168 | // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for class constant 'classConstant' | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 169 | // CHECK-FIXES: {{^}}const int CMyClass::kClassConstant = 4;{{$}} | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 170 |  | 
|  | 171 | int my_class::ClassMember_2 = 5; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 172 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for class member 'ClassMember_2' | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 173 | // CHECK-FIXES: {{^}}int CMyClass::ClassMember2 = 5;{{$}} | 
|  | 174 |  | 
|  | 175 | class my_derived_class : public virtual my_class {}; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 176 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_derived_class' | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 177 | // CHECK-FIXES: {{^}}class CMyDerivedClass : public virtual CMyClass {};{{$}} | 
|  | 178 |  | 
|  | 179 | class CMyWellNamedClass {}; | 
|  | 180 | // No warning expected as this class is well named. | 
|  | 181 |  | 
|  | 182 | template<typename T> | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 183 | // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for type template parameter 'T' | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 184 | // CHECK-FIXES: {{^}}template<typename t_t>{{$}} | 
|  | 185 | class my_templated_class : CMyWellNamedClass {}; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 186 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_templated_class' | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 187 | // CHECK-FIXES: {{^}}class CMyTemplatedClass : CMyWellNamedClass {};{{$}} | 
|  | 188 |  | 
|  | 189 | template<typename T> | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 190 | // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for type template parameter 'T' | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 191 | // CHECK-FIXES: {{^}}template<typename t_t>{{$}} | 
|  | 192 | class my_other_templated_class : my_templated_class<  my_class>, private my_derived_class {}; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 193 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_other_templated_class' | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 194 | // CHECK-FIXES: {{^}}class CMyOtherTemplatedClass : CMyTemplatedClass<  CMyClass>, private CMyDerivedClass {};{{$}} | 
|  | 195 |  | 
|  | 196 | template<typename t_t> | 
| Alexander Kornienko | 5ae76e0 | 2016-06-07 09:11:19 +0000 | [diff] [blame] | 197 | using mysuper_tpl_t = my_other_templated_class  <:: FOO_NS  ::my_class>; | 
|  | 198 | // CHECK-FIXES: {{^}}using mysuper_tpl_t = CMyOtherTemplatedClass  <:: foo_ns  ::CMyClass>;{{$}} | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 199 |  | 
|  | 200 | const int global_Constant = 6; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 201 | // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global constant 'global_Constant' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 202 | // CHECK-FIXES: {{^}}const int GLOBAL_CONSTANT = 6;{{$}} | 
|  | 203 | int Global_variable = 7; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 204 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'Global_variable' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 205 | // CHECK-FIXES: {{^}}int g_global_variable = 7;{{$}} | 
|  | 206 |  | 
|  | 207 | void global_function(int PARAMETER_1, int const CONST_parameter) { | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 208 | // 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 Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 211 | // CHECK-FIXES: {{^}}void GlobalFunction(int a_parameter1, int const i_constParameter) {{{$}} | 
|  | 212 | static const int THIS_static_ConsTant = 4; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 213 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for static constant 'THIS_static_ConsTant' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 214 | // CHECK-FIXES: {{^}}    static const int THIS_STATIC_CONS_TANT = 4;{{$}} | 
|  | 215 | static int THIS_static_variable; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 216 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for static variable 'THIS_static_variable' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 217 | // CHECK-FIXES: {{^}}    static int s_thisStaticVariable;{{$}} | 
|  | 218 | int const local_Constant = 3; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 219 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for local constant 'local_Constant' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 220 | // CHECK-FIXES: {{^}}    int const kLocalConstant = 3;{{$}} | 
|  | 221 | int LOCAL_VARIABLE; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 222 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for local variable 'LOCAL_VARIABLE' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 223 | // CHECK-FIXES: {{^}}    int local_variable;{{$}} | 
|  | 224 |  | 
|  | 225 | int LOCAL_Array__[] = {0, 1, 2}; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 226 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for local variable 'LOCAL_Array__' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 227 | // CHECK-FIXES: {{^}}    int local_array[] = {0, 1, 2};{{$}} | 
|  | 228 |  | 
|  | 229 | for (auto _ : LOCAL_Array__) { | 
|  | 230 | } | 
|  | 231 | } | 
|  | 232 |  | 
|  | 233 | template<typename ... TYPE_parameters> | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 234 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: invalid case style for type template parameter 'TYPE_parameters' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 235 | // CHECK-FIXES: {{^}}template<typename ... typeParameters_t>{{$}} | 
|  | 236 | void Global_Fun(TYPE_parameters... PARAMETER_PACK) { | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 237 | // 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 Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 239 | // CHECK-FIXES: {{^}}void GlobalFun(typeParameters_t... parameterPack) {{{$}} | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 240 | 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 |  | 
|  | 247 | template<template<typename> class TPL_parameter, int COUNT_params, typename ... TYPE_parameters> | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 248 | // 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 Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 251 | // CHECK-FIXES: {{^}}template<template<typename> class TplParameter, int countParams, typename ... typeParameters_t>{{$}} | 
|  | 252 | class test_CLASS { | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 253 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'test_CLASS' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 254 | // CHECK-FIXES: {{^}}class CTestClass {{{$}} | 
|  | 255 | }; | 
|  | 256 |  | 
|  | 257 | class abstract_class { | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 258 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for abstract class 'abstract_class' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 259 | // CHECK-FIXES: {{^}}class AAbstractClass {{{$}} | 
|  | 260 | virtual ~abstract_class() = 0; | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 261 | // CHECK-FIXES: {{^}}    virtual ~AAbstractClass() = 0;{{$}} | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 262 | virtual void VIRTUAL_METHOD(); | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 263 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for virtual method 'VIRTUAL_METHOD' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 264 | // CHECK-FIXES: {{^}}    virtual void v_VIRTUAL_METHOD();{{$}} | 
|  | 265 | void non_Virtual_METHOD() {} | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 266 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for private method 'non_Virtual_METHOD' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 267 | // CHECK-FIXES: {{^}}    void __non_Virtual_METHOD() {}{{$}} | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 268 |  | 
|  | 269 | public: | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 270 | static void CLASS_METHOD() {} | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 271 | // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for class method 'CLASS_METHOD' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 272 | // CHECK-FIXES: {{^}}    static void classMethod() {}{{$}} | 
|  | 273 |  | 
|  | 274 | constexpr int CST_expr_Method() { return 2; } | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 275 | // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for constexpr method 'CST_expr_Method' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 276 | // CHECK-FIXES: {{^}}    constexpr int cst_expr_method() { return 2; }{{$}} | 
|  | 277 |  | 
|  | 278 | private: | 
|  | 279 | void PRIVate_Method(); | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 280 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for private method 'PRIVate_Method' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 281 | // CHECK-FIXES: {{^}}    void __PRIVate_Method();{{$}} | 
|  | 282 | protected: | 
|  | 283 | void protected_Method(); | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 284 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for protected method 'protected_Method' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 285 | // CHECK-FIXES: {{^}}    void _protected_Method();{{$}} | 
|  | 286 | public: | 
|  | 287 | void public_Method(); | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 288 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for method 'public_Method' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 289 | // CHECK-FIXES: {{^}}    void publicMethod();{{$}} | 
|  | 290 | }; | 
|  | 291 |  | 
|  | 292 | constexpr int CE_function() { return 3; } | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 293 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for constexpr function 'CE_function' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 294 | // CHECK-FIXES: {{^}}constexpr int ce_function() { return 3; }{{$}} | 
|  | 295 |  | 
|  | 296 | struct THIS___Structure { | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 297 | // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for struct 'THIS___Structure' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 298 | // CHECK-FIXES: {{^}}struct this_structure {{{$}} | 
|  | 299 | THIS___Structure(); | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 300 | // CHECK-FIXES: {{^}}    this_structure();{{$}} | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 301 |  | 
|  | 302 | union __MyUnion_is_wonderful__ {}; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 303 | // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for union '__MyUnion_is_wonderful__' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 304 | // CHECK-FIXES: {{^}}  union UMyUnionIsWonderful {};{{$}} | 
|  | 305 | }; | 
|  | 306 |  | 
|  | 307 | typedef THIS___Structure struct_type; | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 308 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for typedef 'struct_type' | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 309 | // CHECK-FIXES: {{^}}typedef this_structure struct_type_t;{{$}} | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 310 |  | 
| Alexander Kornienko | 2150390 | 2016-06-17 09:25:24 +0000 | [diff] [blame] | 311 | struct_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 Kornienko | 5ae76e0 | 2016-06-07 09:11:19 +0000 | [diff] [blame] | 317 | using my_struct_type = THIS___Structure; | 
|  | 318 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 'my_struct_type' | 
|  | 319 | // CHECK-FIXES: {{^}}using my_struct_type_t = this_structure;{{$}} | 
|  | 320 |  | 
|  | 321 | template<typename t_t> | 
|  | 322 | using SomeOtherTemplate = my_other_templated_class  <:: FOO_NS  ::my_class>; | 
|  | 323 | // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 'SomeOtherTemplate' | 
|  | 324 | // CHECK-FIXES: {{^}}using some_other_template_t = CMyOtherTemplatedClass  <:: foo_ns  ::CMyClass>;{{$}} | 
|  | 325 |  | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 326 | static void static_Function() { | 
| Mike Aizatsky | 5b55df4 | 2015-12-04 20:57:03 +0000 | [diff] [blame] | 327 | // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for function 'static_Function' | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 328 | // CHECK-FIXES: {{^}}static void staticFunction() {{{$}} | 
| Alexander Kornienko | 30c423b | 2015-10-01 09:19:40 +0000 | [diff] [blame] | 329 |  | 
|  | 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 Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 337 | } | 
|  | 338 |  | 
| Alexander Kornienko | 2150390 | 2016-06-17 09:25:24 +0000 | [diff] [blame] | 339 | #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 |  | 
|  | 343 | void MY_TEST_Macro(function) {} | 
|  | 344 | // CHECK-FIXES: {{^}}void MY_TEST_MACRO(function) {} | 
| Alexander Kornienko | 76c2880 | 2015-08-19 11:15:36 +0000 | [diff] [blame] | 345 | } | 
|  | 346 | } |