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