Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h =================================================================== --- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h +++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h @@ -52,12 +52,32 @@ NamingStyle() = default; NamingStyle(llvm::Optional Case, const std::string &Prefix, - const std::string &Suffix) - : Case(Case), Prefix(Prefix), Suffix(Suffix) {} + const std::string &Suffix, const std::string &IgnoredRegexpStr) + : Case(Case), Prefix(Prefix), Suffix(Suffix), + IgnoredRegexpStr(IgnoredRegexpStr) { + // Create an 'invalid' Regexp if empty + IgnoredRegexp = IgnoredRegexpStr.empty() + ? llvm::Regex() + : llvm::Regex("^" + IgnoredRegexpStr + "$"); + } + + NamingStyle(const NamingStyle &O) + : NamingStyle(O.Case, O.Prefix, O.Suffix, O.IgnoredRegexpStr) {} + NamingStyle &operator=(NamingStyle Style) { + std::swap(Prefix, Style.Prefix); + std::swap(Suffix, Style.Suffix); + std::swap(IgnoredRegexpStr, Style.IgnoredRegexpStr); + std::swap(IgnoredRegexp, Style.IgnoredRegexp); + return *this; + } llvm::Optional Case; std::string Prefix; std::string Suffix; + // Store both compiled and non-compiled forms so original value can be + // serialised + llvm::Regex IgnoredRegexp; + std::string IgnoredRegexpStr; }; struct FileStyle { Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -130,6 +130,9 @@ for (unsigned I = 0; I < SK_Count; ++I) { StyleString = StyleNames[I]; size_t StyleSize = StyleString.size(); + StyleString.append("IgnoredRegexp"); + std::string IgnoredRegexpStr = Options.get((StyleString).str(), ""); + StyleString.resize(StyleSize); StyleString.append("Prefix"); std::string Prefix(Options.get(StyleString, "")); // Fast replacement of [Pre]fix -> [Suf]fix. @@ -141,9 +144,10 @@ auto CaseOptional = Options.getOptional(StyleString); - if (CaseOptional || !Prefix.empty() || !Postfix.empty()) + if (CaseOptional || !Prefix.empty() || !Postfix.empty() || + !IgnoredRegexpStr.empty()) Styles[I].emplace(std::move(CaseOptional), std::move(Prefix), - std::move(Postfix)); + std::move(Postfix), std::move(IgnoredRegexpStr)); } bool IgnoreMainLike = Options.get("IgnoreMainLikeFunctions", false); return {std::move(Styles), IgnoreMainLike}; @@ -175,6 +179,9 @@ continue; StyleString = StyleNames[I]; size_t StyleSize = StyleString.size(); + StyleString.append("IgnoredRegexp"); + Options.store(Opts, StyleString, Styles[I]->IgnoredRegexpStr); + StyleString.resize(StyleSize); StyleString.append("Prefix"); Options.store(Opts, StyleString, Styles[I]->Prefix); // Fast replacement of [Pre]fix -> [Suf]fix. @@ -194,7 +201,7 @@ } static bool matchesStyle(StringRef Name, - IdentifierNamingCheck::NamingStyle Style) { + const IdentifierNamingCheck::NamingStyle &Style) { static llvm::Regex Matchers[] = { llvm::Regex("^.*$"), llvm::Regex("^[a-z][a-z0-9_]*$"), @@ -681,6 +688,9 @@ return None; const IdentifierNamingCheck::NamingStyle &Style = *NamingStyles[SK]; + if (Style.IgnoredRegexp.isValid() && Style.IgnoredRegexp.match(Name)) + return None; + if (matchesStyle(Name, Style)) return None; Index: clang-tools-extra/docs/ReleaseNotes.rst =================================================================== --- clang-tools-extra/docs/ReleaseNotes.rst +++ clang-tools-extra/docs/ReleaseNotes.rst @@ -149,6 +149,9 @@ Added support for specifying the style of scoped ``enum`` constants. If unspecified, will fall back to the style for regular ``enum`` constants. + Added an option `IgnoredRegexp` per identifier type to suppress identifier + naming checks for names matching a regular expression. + - Removed `google-runtime-references` check because the rule it checks does not exist in the Google Style Guide anymore. Index: clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst +++ clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst @@ -20,7 +20,8 @@ - ``aNy_CasE``. It also supports a fixed prefix and suffix that will be prepended or appended -to the identifiers, regardless of the casing. +to the identifiers, regardless of the casing. A threshold for the length of +the identifer may be specified to suppress the checks for short names. Many configuration options are available, in order to be able to create different rules for different kinds of identifiers. In general, the rules are @@ -35,60 +36,60 @@ The following options are describe below: - - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix` + - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`, :option:`AbstractClassIgnoredRegexp` - :option:`AggressiveDependentMemberLookup` - - :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix` - - :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix` - - :option:`ClassMemberCase`, :option:`ClassMemberPrefix`, :option:`ClassMemberSuffix` - - :option:`ClassMethodCase`, :option:`ClassMethodPrefix`, :option:`ClassMethodSuffix` - - :option:`ConstantCase`, :option:`ConstantPrefix`, :option:`ConstantSuffix` - - :option:`ConstantMemberCase`, :option:`ConstantMemberPrefix`, :option:`ConstantMemberSuffix` - - :option:`ConstantParameterCase`, :option:`ConstantParameterPrefix`, :option:`ConstantParameterSuffix` - - :option:`ConstantPointerParameterCase`, :option:`ConstantPointerParameterPrefix`, :option:`ConstantPointerParameterSuffix` - - :option:`ConstexprFunctionCase`, :option:`ConstexprFunctionPrefix`, :option:`ConstexprFunctionSuffix` - - :option:`ConstexprMethodCase`, :option:`ConstexprMethodPrefix`, :option:`ConstexprMethodSuffix` - - :option:`ConstexprVariableCase`, :option:`ConstexprVariablePrefix`, :option:`ConstexprVariableSuffix` - - :option:`EnumCase`, :option:`EnumPrefix`, :option:`EnumSuffix` - - :option:`EnumConstantCase`, :option:`EnumConstantPrefix`, :option:`EnumConstantSuffix` - - :option:`FunctionCase`, :option:`FunctionPrefix`, :option:`FunctionSuffix` + - :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix`, :option:`ClassIgnoredRegexp` + - :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix`, :option:`ClassConstantIgnoredRegexp` + - :option:`ClassMemberCase`, :option:`ClassMemberPrefix`, :option:`ClassMemberSuffix`, :option:`ClassMemberIgnoredRegexp` + - :option:`ClassMethodCase`, :option:`ClassMethodPrefix`, :option:`ClassMethodSuffix`, :option:`ClassMethodIgnoredRegexp` + - :option:`ConstantCase`, :option:`ConstantPrefix`, :option:`ConstantSuffix`, :option:`ConstantIgnoredRegexp` + - :option:`ConstantMemberCase`, :option:`ConstantMemberPrefix`, :option:`ConstantMemberSuffix`, :option:`ConstantMemberIgnoredRegexp` + - :option:`ConstantParameterCase`, :option:`ConstantParameterPrefix`, :option:`ConstantParameterSuffix`, :option:`ConstantParameterIgnoredRegexp` + - :option:`ConstantPointerParameterCase`, :option:`ConstantPointerParameterPrefix`, :option:`ConstantPointerParameterSuffix`, :option:`ConstantPointerParameterIgnoredRegexp` + - :option:`ConstexprFunctionCase`, :option:`ConstexprFunctionPrefix`, :option:`ConstexprFunctionSuffix`, :option:`ConstexprFunctionIgnoredRegexp` + - :option:`ConstexprMethodCase`, :option:`ConstexprMethodPrefix`, :option:`ConstexprMethodSuffix`, :option:`ConstexprMethodIgnoredRegexp` + - :option:`ConstexprVariableCase`, :option:`ConstexprVariablePrefix`, :option:`ConstexprVariableSuffix`, :option:`ConstexprVariableIgnoredRegexp` + - :option:`EnumCase`, :option:`EnumPrefix`, :option:`EnumSuffix`, :option:`EnumIgnoredRegexp` + - :option:`EnumConstantCase`, :option:`EnumConstantPrefix`, :option:`EnumConstantSuffix`, :option:`EnumConstantIgnoredRegexp` + - :option:`FunctionCase`, :option:`FunctionPrefix`, :option:`FunctionSuffix`, :option:`FunctionIgnoredRegexp` - :option:`GetConfigPerFile` - - :option:`GlobalConstantCase`, :option:`GlobalConstantPrefix`, :option:`GlobalConstantSuffix` - - :option:`GlobalConstantPointerCase`, :option:`GlobalConstantPointerPrefix`, :option:`GlobalConstantPointerSuffix` - - :option:`GlobalFunctionCase`, :option:`GlobalFunctionPrefix`, :option:`GlobalFunctionSuffix` - - :option:`GlobalPointerCase`, :option:`GlobalPointerPrefix`, :option:`GlobalPointerSuffix` - - :option:`GlobalVariableCase`, :option:`GlobalVariablePrefix`, :option:`GlobalVariableSuffix` + - :option:`GlobalConstantCase`, :option:`GlobalConstantPrefix`, :option:`GlobalConstantSuffix`, :option:`GlobalConstantIgnoredRegexp` + - :option:`GlobalConstantPointerCase`, :option:`GlobalConstantPointerPrefix`, :option:`GlobalConstantPointerSuffix`, :option:`GlobalConstantPointerIgnoredRegexp` + - :option:`GlobalFunctionCase`, :option:`GlobalFunctionPrefix`, :option:`GlobalFunctionSuffix`, :option:`GlobalFunctionIgnoredRegexp` + - :option:`GlobalPointerCase`, :option:`GlobalPointerPrefix`, :option:`GlobalPointerSuffix`, :option:`GlobalPointerIgnoredRegexp` + - :option:`GlobalVariableCase`, :option:`GlobalVariablePrefix`, :option:`GlobalVariableSuffix`, :option:`GlobalVariableIgnoredRegexp` - :option:`IgnoreMainLikeFunctions` - - :option:`InlineNamespaceCase`, :option:`InlineNamespacePrefix`, :option:`InlineNamespaceSuffix` - - :option:`LocalConstantCase`, :option:`LocalConstantPrefix`, :option:`LocalConstantSuffix` - - :option:`LocalConstantPointerCase`, :option:`LocalConstantPointerPrefix`, :option:`LocalConstantPointerSuffix` - - :option:`LocalPointerCase`, :option:`LocalPointerPrefix`, :option:`LocalPointerSuffix` - - :option:`LocalVariableCase`, :option:`LocalVariablePrefix`, :option:`LocalVariableSuffix` - - :option:`MacroDefinitionCase`, :option:`MacroDefinitionPrefix`, :option:`MacroDefinitionSuffix` - - :option:`MemberCase`, :option:`MemberPrefix`, :option:`MemberSuffix` - - :option:`MethodCase`, :option:`MethodPrefix`, :option:`MethodSuffix` - - :option:`NamespaceCase`, :option:`NamespacePrefix`, :option:`NamespaceSuffix` - - :option:`ParameterCase`, :option:`ParameterPrefix`, :option:`ParameterSuffix` - - :option:`ParameterPackCase`, :option:`ParameterPackPrefix`, :option:`ParameterPackSuffix` - - :option:`PointerParameterCase`, :option:`PointerParameterPrefix`, :option:`PointerParameterSuffix` - - :option:`PrivateMemberCase`, :option:`PrivateMemberPrefix`, :option:`PrivateMemberSuffix` - - :option:`PrivateMethodCase`, :option:`PrivateMethodPrefix`, :option:`PrivateMethodSuffix` - - :option:`ProtectedMemberCase`, :option:`ProtectedMemberPrefix`, :option:`ProtectedMemberSuffix` - - :option:`ProtectedMethodCase`, :option:`ProtectedMethodPrefix`, :option:`ProtectedMethodSuffix` - - :option:`PublicMemberCase`, :option:`PublicMemberPrefix`, :option:`PublicMemberSuffix` - - :option:`PublicMethodCase`, :option:`PublicMethodPrefix`, :option:`PublicMethodSuffix` - - :option:`ScopedEnumConstantCase`, :option:`ScopedEnumConstantPrefix`, :option:`ScopedEnumConstantSuffix` - - :option:`StaticConstantCase`, :option:`StaticConstantPrefix`, :option:`StaticConstantSuffix` - - :option:`StaticVariableCase`, :option:`StaticVariablePrefix`, :option:`StaticVariableSuffix` - - :option:`StructCase`, :option:`StructPrefix`, :option:`StructSuffix` - - :option:`TemplateParameterCase`, :option:`TemplateParameterPrefix`, :option:`TemplateParameterSuffix` - - :option:`TemplateTemplateParameterCase`, :option:`TemplateTemplateParameterPrefix`, :option:`TemplateTemplateParameterSuffix` - - :option:`TypeAliasCase`, :option:`TypeAliasPrefix`, :option:`TypeAliasSuffix` - - :option:`TypedefCase`, :option:`TypedefPrefix`, :option:`TypedefSuffix` - - :option:`TypeTemplateParameterCase`, :option:`TypeTemplateParameterPrefix`, :option:`TypeTemplateParameterSuffix` - - :option:`UnionCase`, :option:`UnionPrefix`, :option:`UnionSuffix` - - :option:`ValueTemplateParameterCase`, :option:`ValueTemplateParameterPrefix`, :option:`ValueTemplateParameterSuffix` - - :option:`VariableCase`, :option:`VariablePrefix`, :option:`VariableSuffix` - - :option:`VirtualMethodCase`, :option:`VirtualMethodPrefix`, :option:`VirtualMethodSuffix` + - :option:`InlineNamespaceCase`, :option:`InlineNamespacePrefix`, :option:`InlineNamespaceSuffix`, :option:`InlineNamespaceIgnoredRegexp` + - :option:`LocalConstantCase`, :option:`LocalConstantPrefix`, :option:`LocalConstantSuffix`, :option:`LocalConstantIgnoredRegexp` + - :option:`LocalConstantPointerCase`, :option:`LocalConstantPointerPrefix`, :option:`LocalConstantPointerSuffix`, :option:`LocalConstantPointerIgnoredRegexp` + - :option:`LocalPointerCase`, :option:`LocalPointerPrefix`, :option:`LocalPointerSuffix`, :option:`LocalPointerIgnoredRegexp` + - :option:`LocalVariableCase`, :option:`LocalVariablePrefix`, :option:`LocalVariableSuffix`, :option:`LocalVariableIgnoredRegexp` + - :option:`MacroDefinitionCase`, :option:`MacroDefinitionPrefix`, :option:`MacroDefinitionSuffix`, :option:`MacroDefinitionIgnoredRegexp` + - :option:`MemberCase`, :option:`MemberPrefix`, :option:`MemberSuffix`, :option:`MemberIgnoredRegexp` + - :option:`MethodCase`, :option:`MethodPrefix`, :option:`MethodSuffix`, :option:`MethodIgnoredRegexp` + - :option:`NamespaceCase`, :option:`NamespacePrefix`, :option:`NamespaceSuffix`, :option:`NamespaceIgnoredRegexp` + - :option:`ParameterCase`, :option:`ParameterPrefix`, :option:`ParameterSuffix`, :option:`ParameterIgnoredRegexp` + - :option:`ParameterPackCase`, :option:`ParameterPackPrefix`, :option:`ParameterPackSuffix`, :option:`ParameterPackIgnoredRegexp` + - :option:`PointerParameterCase`, :option:`PointerParameterPrefix`, :option:`PointerParameterSuffix`, :option:`PointerParameterIgnoredRegexp` + - :option:`PrivateMemberCase`, :option:`PrivateMemberPrefix`, :option:`PrivateMemberSuffix`, :option:`PrivateMemberIgnoredRegexp` + - :option:`PrivateMethodCase`, :option:`PrivateMethodPrefix`, :option:`PrivateMethodSuffix`, :option:`PrivateMethodIgnoredRegexp` + - :option:`ProtectedMemberCase`, :option:`ProtectedMemberPrefix`, :option:`ProtectedMemberSuffix`, :option:`ProtectedMemberIgnoredRegexp` + - :option:`ProtectedMethodCase`, :option:`ProtectedMethodPrefix`, :option:`ProtectedMethodSuffix`, :option:`ProtectedMethodIgnoredRegexp` + - :option:`PublicMemberCase`, :option:`PublicMemberPrefix`, :option:`PublicMemberSuffix`, :option:`PublicMemberIgnoredRegexp` + - :option:`PublicMethodCase`, :option:`PublicMethodPrefix`, :option:`PublicMethodSuffix`, :option:`PublicMethodIgnoredRegexp` + - :option:`ScopedEnumConstantCase`, :option:`ScopedEnumConstantPrefix`, :option:`ScopedEnumConstantSuffix`, :option:`ScopedEnumConstantIgnoredRegexp` + - :option:`StaticConstantCase`, :option:`StaticConstantPrefix`, :option:`StaticConstantSuffix`, :option:`StaticConstantIgnoredRegexp` + - :option:`StaticVariableCase`, :option:`StaticVariablePrefix`, :option:`StaticVariableSuffix`, :option:`StaticVariableIgnoredRegexp` + - :option:`StructCase`, :option:`StructPrefix`, :option:`StructSuffix`, :option:`StructIgnoredRegexp` + - :option:`TemplateParameterCase`, :option:`TemplateParameterPrefix`, :option:`TemplateParameterSuffix`, :option:`TemplateParameterIgnoredRegexp` + - :option:`TemplateTemplateParameterCase`, :option:`TemplateTemplateParameterPrefix`, :option:`TemplateTemplateParameterSuffix`, :option:`TemplateTemplateParameterIgnoredRegexp` + - :option:`TypeAliasCase`, :option:`TypeAliasPrefix`, :option:`TypeAliasSuffix`, :option:`TypeAliasIgnoredRegexp` + - :option:`TypedefCase`, :option:`TypedefPrefix`, :option:`TypedefSuffix`, :option:`TypedefIgnoredRegexp` + - :option:`TypeTemplateParameterCase`, :option:`TypeTemplateParameterPrefix`, :option:`TypeTemplateParameterSuffix`, :option:`TypeTemplateParameterIgnoredRegexp` + - :option:`UnionCase`, :option:`UnionPrefix`, :option:`UnionSuffix`, :option:`UnionIgnoredRegexp` + - :option:`ValueTemplateParameterCase`, :option:`ValueTemplateParameterPrefix`, :option:`ValueTemplateParameterSuffix`, :option:`ValueTemplateParameterIgnoredRegexp` + - :option:`VariableCase`, :option:`VariablePrefix`, :option:`VariableSuffix`, :option:`VariableIgnoredRegexp` + - :option:`VirtualMethodCase`, :option:`VirtualMethodPrefix`, :option:`VirtualMethodSuffix`, :option:`VirtualMethodIgnoredRegexp` .. option:: AbstractClassCase @@ -100,6 +101,11 @@ When defined, the check will ensure abstract class names will add the prefixed with the given value (regardless of casing). +.. option:: AbstractClassIgnoredRegexp + + Identifier naming checks won't be enforced for abstract class names + matching this regular expression. + .. option:: AbstractClassSuffix When defined, the check will ensure abstract class names will add the @@ -199,6 +205,11 @@ When defined, the check will ensure class names will add the prefixed with the given value (regardless of casing). +.. option:: ClassIgnoredRegexp + + Identifier naming checks won't be enforced for class names matching + this regular expression. + .. option:: ClassSuffix When defined, the check will ensure class names will add the @@ -242,6 +253,11 @@ When defined, the check will ensure class constant names will add the prefixed with the given value (regardless of casing). +.. option:: ClassConstantIgnoredRegexp + + Identifier naming checks won't be enforced for class constant names + matching this regular expression. + .. option:: ClassConstantSuffix When defined, the check will ensure class constant names will add the @@ -283,6 +299,11 @@ When defined, the check will ensure class member names will add the prefixed with the given value (regardless of casing). +.. option:: ClassMemberIgnoredRegexp + + Identifier naming checks won't be enforced for class member names + matching this regular expression. + .. option:: ClassMemberSuffix When defined, the check will ensure class member names will add the @@ -324,6 +345,11 @@ When defined, the check will ensure class method names will add the prefixed with the given value (regardless of casing). +.. option:: ClassMethodIgnoredRegexp + + Identifier naming checks won't be enforced for class method names + matching this regular expression. + .. option:: ClassMethodSuffix When defined, the check will ensure class method names will add the @@ -365,6 +391,11 @@ When defined, the check will ensure constant names will add the prefixed with the given value (regardless of casing). +.. option:: ConstantIgnoredRegexp + + Identifier naming checks won't be enforced for constant names + matching this regular expression. + .. option:: ConstantSuffix When defined, the check will ensure constant names will add the @@ -400,6 +431,11 @@ When defined, the check will ensure constant member names will add the prefixed with the given value (regardless of casing). +.. option:: ConstantMemberIgnoredRegexp + + Identifier naming checks won't be enforced for constant member names + matching this regular expression. + .. option:: ConstantMemberSuffix When defined, the check will ensure constant member names will add the @@ -439,6 +475,11 @@ When defined, the check will ensure constant parameter names will add the prefixed with the given value (regardless of casing). +.. option:: ConstantParameterIgnoredRegexp + + Identifier naming checks won't be enforced for constant parameter names + matching this regular expression. + .. option:: ConstantParameterSuffix When defined, the check will ensure constant parameter names will add the @@ -474,6 +515,11 @@ When defined, the check will ensure constant pointer parameter names will add the prefixed with the given value (regardless of casing). +.. option:: ConstantPointerParameterIgnoredRegexp + + Identifier naming checks won't be enforced for constant pointer parameter + names matching this regular expression. + .. option:: ConstantPointerParameterSuffix When defined, the check will ensure constant pointer parameter names will add the @@ -509,6 +555,11 @@ When defined, the check will ensure constexpr function names will add the prefixed with the given value (regardless of casing). +.. option:: ConstexprFunctionIgnoredRegexp + + Identifier naming checks won't be enforced for constexpr function names + matching this regular expression. + .. option:: ConstexprFunctionSuffix When defined, the check will ensure constexpr function names will add the @@ -544,6 +595,11 @@ When defined, the check will ensure constexpr method names will add the prefixed with the given value (regardless of casing). +.. option:: ConstexprMethodIgnoredRegexp + + Identifier naming checks won't be enforced for constexpr method names + matching this regular expression. + .. option:: ConstexprMethodSuffix When defined, the check will ensure constexpr method names will add the @@ -585,6 +641,11 @@ When defined, the check will ensure constexpr variable names will add the prefixed with the given value (regardless of casing). +.. option:: ConstexprVariableIgnoredRegexp + + Identifier naming checks won't be enforced for constexpr variable names + matching this regular expression. + .. option:: ConstexprVariableSuffix When defined, the check will ensure constexpr variable names will add the @@ -620,6 +681,11 @@ When defined, the check will ensure enumeration names will add the prefixed with the given value (regardless of casing). +.. option:: EnumConstantIgnoredRegexp + + Identifier naming checks won't be enforced for enumeration names + matching this regular expression. + .. option:: EnumSuffix When defined, the check will ensure enumeration names will add the @@ -655,6 +721,11 @@ When defined, the check will ensure enumeration constant names will add the prefixed with the given value (regardless of casing). +.. option:: EnumConstantIgnoredRegexp + + Identifier naming checks won't be enforced for enumeration constant names + matching this regular expression. + .. option:: EnumConstantSuffix When defined, the check will ensure enumeration constant names will add the @@ -690,6 +761,11 @@ When defined, the check will ensure function names will add the prefixed with the given value (regardless of casing). +.. option:: FunctionIgnoredRegexp + + Identifier naming checks won't be enforced for function names + matching this regular expression. + .. option:: FunctionSuffix When defined, the check will ensure function names will add the @@ -732,6 +808,11 @@ When defined, the check will ensure global constant names will add the prefixed with the given value (regardless of casing). +.. option:: GlobalConstantIgnoredRegexp + + Identifier naming checks won't be enforced for global constant names + matching this regular expression. + .. option:: GlobalConstantSuffix When defined, the check will ensure global constant names will add the @@ -767,6 +848,11 @@ When defined, the check will ensure global constant pointer names will add the prefixed with the given value (regardless of casing). +.. option:: GlobalConstantPointerIgnoredRegexp + + Identifier naming checks won't be enforced for global constant pointer + names matching this regular expression. + .. option:: GlobalConstantPointerSuffix When defined, the check will ensure global constant pointer names will add the @@ -802,6 +888,11 @@ When defined, the check will ensure global function names will add the prefixed with the given value (regardless of casing). +.. option:: GlobalFunctionIgnoredRegexp + + Identifier naming checks won't be enforced for global function names + matching this regular expression. + .. option:: GlobalFunctionSuffix When defined, the check will ensure global function names will add the @@ -837,6 +928,11 @@ When defined, the check will ensure global pointer names will add the prefixed with the given value (regardless of casing). +.. option:: GlobalPointerIgnoredRegexp + + Identifier naming checks won't be enforced for global pointer names + matching this regular expression. + .. option:: GlobalPointerSuffix When defined, the check will ensure global pointer names will add the @@ -872,6 +968,11 @@ When defined, the check will ensure global variable names will add the prefixed with the given value (regardless of casing). +.. option:: GlobalVariableIgnoredRegexp + + Identifier naming checks won't be enforced for global variable names + matching this regular expression. + .. option:: GlobalVariableSuffix When defined, the check will ensure global variable names will add the @@ -913,6 +1014,11 @@ When defined, the check will ensure inline namespaces names will add the prefixed with the given value (regardless of casing). +.. option:: InlineNamespaceIgnoredRegexp + + Identifier naming checks won't be enforced for inline namespaces names + matching this regular expression. + .. option:: InlineNamespaceSuffix When defined, the check will ensure inline namespaces names will add the @@ -956,6 +1062,11 @@ When defined, the check will ensure local constant names will add the prefixed with the given value (regardless of casing). +.. option:: LocalConstantIgnoredRegexp + + Identifier naming checks won't be enforced for local constant names + matching this regular expression. + .. option:: LocalConstantSuffix When defined, the check will ensure local constant names will add the @@ -991,6 +1102,11 @@ When defined, the check will ensure local constant pointer names will add the prefixed with the given value (regardless of casing). +.. option:: LocalConstantPointerIgnoredRegexp + + Identifier naming checks won't be enforced for local constant pointer names + matching this regular expression. + .. option:: LocalConstantPointerSuffix When defined, the check will ensure local constant pointer names will add the @@ -1026,6 +1142,11 @@ When defined, the check will ensure local pointer names will add the prefixed with the given value (regardless of casing). +.. option:: LocalPointerIgnoredRegexp + + Identifier naming checks won't be enforced for local pointer names + matching this regular expression. + .. option:: LocalPointerSuffix When defined, the check will ensure local pointer names will add the @@ -1061,6 +1182,11 @@ When defined, the check will ensure local variable names will add the prefixed with the given value (regardless of casing). +.. option:: LocalVariableIgnoredRegexp + + Identifier naming checks won't be enforced for local variable names + matching this regular expression. + .. option:: LocalVariableSuffix When defined, the check will ensure local variable names will add the @@ -1096,6 +1222,11 @@ When defined, the check will ensure macro definitions will add the prefixed with the given value (regardless of casing). +.. option:: MacroDefinitionIgnoredRegexp + + Identifier naming checks won't be enforced for macro definitions + matching this regular expression. + .. option:: MacroDefinitionSuffix When defined, the check will ensure macro definitions will add the @@ -1134,6 +1265,11 @@ When defined, the check will ensure member names will add the prefixed with the given value (regardless of casing). +.. option:: MemberIgnoredRegexp + + Identifier naming checks won't be enforced for member names + matching this regular expression. + .. option:: MemberSuffix When defined, the check will ensure member names will add the @@ -1173,6 +1309,11 @@ When defined, the check will ensure method names will add the prefixed with the given value (regardless of casing). +.. option:: MethodIgnoredRegexp + + Identifier naming checks won't be enforced for method names + matching this regular expression. + .. option:: MethodSuffix When defined, the check will ensure method names will add the @@ -1212,6 +1353,11 @@ When defined, the check will ensure namespace names will add the prefixed with the given value (regardless of casing). +.. option:: NamespaceIgnoredRegexp + + Identifier naming checks won't be enforced for namespace names + matching this regular expression. + .. option:: NamespaceSuffix When defined, the check will ensure namespace names will add the @@ -1251,6 +1397,11 @@ When defined, the check will ensure parameter names will add the prefixed with the given value (regardless of casing). +.. option:: ParameterIgnoredRegexp + + Identifier naming checks won't be enforced for parameter names + matching this regular expression. + .. option:: ParameterSuffix When defined, the check will ensure parameter names will add the @@ -1286,6 +1437,11 @@ When defined, the check will ensure parameter pack names will add the prefixed with the given value (regardless of casing). +.. option:: ParameterPackIgnoredRegexp + + Identifier naming checks won't be enforced for parameter pack names + matching this regular expression. + .. option:: ParameterPackSuffix When defined, the check will ensure parameter pack names will add the @@ -1325,6 +1481,11 @@ When defined, the check will ensure pointer parameter names will add the prefixed with the given value (regardless of casing). +.. option:: PointerParameterIgnoredRegexp + + Identifier naming checks won't be enforced for pointer parameter names + matching this regular expression. + .. option:: PointerParameterSuffix When defined, the check will ensure pointer parameter names will add the @@ -1360,6 +1521,11 @@ When defined, the check will ensure private member names will add the prefixed with the given value (regardless of casing). +.. option:: PrivateMemberIgnoredRegexp + + Identifier naming checks won't be enforced for private member names + matching this regular expression. + .. option:: PrivateMemberSuffix When defined, the check will ensure private member names will add the @@ -1401,6 +1567,11 @@ When defined, the check will ensure private method names will add the prefixed with the given value (regardless of casing). +.. option:: PrivateMethodIgnoredRegexp + + Identifier naming checks won't be enforced for private method names + matching this regular expression. + .. option:: PrivateMethodSuffix When defined, the check will ensure private method names will add the @@ -1442,6 +1613,11 @@ When defined, the check will ensure protected member names will add the prefixed with the given value (regardless of casing). +.. option:: ProtectedMemberIgnoredRegexp + + Identifier naming checks won't be enforced for protected member names + matching this regular expression. + .. option:: ProtectedMemberSuffix When defined, the check will ensure protected member names will add the @@ -1475,17 +1651,22 @@ .. option:: ProtectedMethodCase - When defined, the check will ensure protect method names conform to the + When defined, the check will ensure protected method names conform to the selected casing. .. option:: ProtectedMethodPrefix - When defined, the check will ensure protect method names will add the + When defined, the check will ensure protected method names will add the prefixed with the given value (regardless of casing). +.. option:: ProtectedMethodIgnoredRegexp + + Identifier naming checks won't be enforced for protected method names + matching this regular expression. + .. option:: ProtectedMethodSuffix - When defined, the check will ensure protect method names will add the + When defined, the check will ensure protected method names will add the suffix with the given value (regardless of casing). For example using values of: @@ -1524,6 +1705,11 @@ When defined, the check will ensure public member names will add the prefixed with the given value (regardless of casing). +.. option:: PublicMemberIgnoredRegexp + + Identifier naming checks won't be enforced for public member names + matching this regular expression. + .. option:: PublicMemberSuffix When defined, the check will ensure public member names will add the @@ -1565,6 +1751,11 @@ When defined, the check will ensure public method names will add the prefixed with the given value (regardless of casing). +.. option:: PublicMethodIgnoredRegexp + + Identifier naming checks won't be enforced for public method names + matching this regular expression. + .. option:: PublicMethodSuffix When defined, the check will ensure public method names will add the @@ -1606,6 +1797,11 @@ When defined, the check will ensure scoped enum constant names will add the prefixed with the given value (regardless of casing). +.. option:: ScopedEnumConstantIgnoredRegexp + + Identifier naming checks won't be enforced for scoped enum constant names + matching this regular expression. + .. option:: ScopedEnumConstantSuffix When defined, the check will ensure scoped enum constant names will add the @@ -1641,6 +1837,11 @@ When defined, the check will ensure static constant names will add the prefixed with the given value (regardless of casing). +.. option:: StaticConstantIgnoredRegexp + + Identifier naming checks won't be enforced for static constant names + matching this regular expression. + .. option:: StaticConstantSuffix When defined, the check will ensure static constant names will add the @@ -1676,6 +1877,11 @@ When defined, the check will ensure static variable names will add the prefixed with the given value (regardless of casing). +.. option:: StaticVariableIgnoredRegexp + + Identifier naming checks won't be enforced for static variable names + matching this regular expression. + .. option:: StaticVariableSuffix When defined, the check will ensure static variable names will add the @@ -1711,6 +1917,11 @@ When defined, the check will ensure struct names will add the prefixed with the given value (regardless of casing). +.. option:: StructIgnoredRegexp + + Identifier naming checks won't be enforced for struct names + matching this regular expression. + .. option:: StructSuffix When defined, the check will ensure struct names will add the @@ -1752,6 +1963,11 @@ When defined, the check will ensure template parameter names will add the prefixed with the given value (regardless of casing). +.. option:: TemplateParameterIgnoredRegexp + + Identifier naming checks won't be enforced for template parameter names + matching this regular expression. + .. option:: TemplateParameterSuffix When defined, the check will ensure template parameter names will add the @@ -1787,6 +2003,11 @@ When defined, the check will ensure template template parameter names will add the prefixed with the given value (regardless of casing). +.. option:: TemplateTemplateParameterIgnoredRegexp + + Identifier naming checks won't be enforced for template template parameter + names matching this regular expression. + .. option:: TemplateTemplateParameterSuffix When defined, the check will ensure template template parameter names will add the @@ -1824,6 +2045,11 @@ When defined, the check will ensure type alias names will add the prefixed with the given value (regardless of casing). +.. option:: TypeAliasIgnoredRegexp + + Identifier naming checks won't be enforced for type alias names + matching this regular expression. + .. option:: TypeAliasSuffix When defined, the check will ensure type alias names will add the @@ -1859,6 +2085,11 @@ When defined, the check will ensure typedef names will add the prefixed with the given value (regardless of casing). +.. option:: TypedefIgnoredRegexp + + Identifier naming checks won't be enforced for typedef names + matching this regular expression. + .. option:: TypedefSuffix When defined, the check will ensure typedef names will add the @@ -1894,6 +2125,11 @@ When defined, the check will ensure type template parameter names will add the prefixed with the given value (regardless of casing). +.. option:: TypeTemplateParameterIgnoredRegexp + + Identifier naming checks won't be enforced for type template names + matching this regular expression. + .. option:: TypeTemplateParameterSuffix When defined, the check will ensure type template parameter names will add the @@ -1931,6 +2167,11 @@ When defined, the check will ensure union names will add the prefixed with the given value (regardless of casing). +.. option:: UnionIgnoredRegexp + + Identifier naming checks won't be enforced for union names + matching this regular expression. + .. option:: UnionSuffix When defined, the check will ensure union names will add the @@ -1972,6 +2213,11 @@ When defined, the check will ensure value template parameter names will add the prefixed with the given value (regardless of casing). +.. option:: ValueTemplateParameterIgnoredRegexp + + Identifier naming checks won't be enforced for value template parameter + names matching this regular expression. + .. option:: ValueTemplateParameterSuffix When defined, the check will ensure value template parameter names will add the @@ -2009,6 +2255,11 @@ When defined, the check will ensure variable names will add the prefixed with the given value (regardless of casing). +.. option:: VariableIgnoredRegexp + + Identifier naming checks won't be enforced for variable names + matching this regular expression. + .. option:: VariableSuffix When defined, the check will ensure variable names will add the @@ -2044,6 +2295,11 @@ When defined, the check will ensure virtual method names will add the prefixed with the given value (regardless of casing). +.. option:: VirtualMethodIgnoredRegexp + + Identifier naming checks won't be enforced for virtual method names + matching this regular expression. + .. option:: VirtualMethodSuffix When defined, the check will ensure virtual method names will add the Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignore-regexp.cpp =================================================================== --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignore-regexp.cpp @@ -0,0 +1,43 @@ +// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \ +// RUN: -config='{CheckOptions: [ \ +// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \ +// RUN: {key: readability-identifier-naming.ParameterIgnoredRegexp, value: "^[a-z]{1,2}$"}, \ +// RUN: {key: readability-identifier-naming.ClassCase, value: CamelCase}, \ +// RUN: {key: readability-identifier-naming.ClassIgnoredRegexp, value: "^fo$|^fooo$"}, \ +// RUN: {key: readability-identifier-naming.StructCase, value: CamelCase}, \ +// RUN: {key: readability-identifier-naming.StructIgnoredRegexp, value: "sooo|so|soo|$o["} \ +// RUN: ]}' + +int testFunc(int a, char **b); +int testFunc(int ab, char **ba); +int testFunc(int abc, char **cba); +// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'abc' +// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'cba' +// CHECK-FIXES: {{^}}int testFunc(int Abc, char **Cba);{{$}} +int testFunc(int Abc, char **Cba); + +class fo { +}; + +class fofo { + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'fofo' + // CHECK-FIXES: {{^}}class Fofo {{{$}} +}; + +class foo { + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'foo' + // CHECK-FIXES: {{^}}class Foo {{{$}} +}; + +class fooo { +}; + +class afooo { + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'afooo' + // CHECK-FIXES: {{^}}class Afooo {{{$}} +}; + +struct soo { + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for struct 'soo' + // CHECK-FIXES: {{^}}struct Soo {{{$}} +};