diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h @@ -36,7 +36,6 @@ IdentifierNamingCheck(StringRef Name, ClangTidyContext *Context); ~IdentifierNamingCheck(); - std::string getDeclTypeName(const clang::NamedDecl *Decl) const; void storeOptions(ClangTidyOptions::OptionMap &Opts) override; enum CaseType { @@ -50,6 +49,14 @@ CT_HungarianNotation }; + struct HungarianNotationOption { + llvm::StringMap Options; + llvm::StringMap CString; + llvm::StringMap PrimitiveType; + llvm::StringMap UserDefinedType; + llvm::StringMap DerivedType; + }; + struct NamingStyle { NamingStyle() = default; @@ -57,9 +64,15 @@ const std::string &Suffix) : Case(Case), Prefix(Prefix), Suffix(Suffix) {} + NamingStyle(llvm::Optional Case, const std::string &Prefix, + const std::string &Suffix, + const std::shared_ptr HNOption) + : Case(Case), Prefix(Prefix), Suffix(Suffix), HNOption(HNOption) {} + llvm::Optional Case; std::string Prefix; std::string Suffix; + std::shared_ptr HNOption; }; private: diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -105,6 +105,7 @@ m(TypeAlias) \ m(MacroDefinition) \ m(ObjcIvar) \ + m(HungarianNotation) \ enum StyleKind { #define ENUMERATE(v) SK_ ## v, @@ -120,12 +121,293 @@ #undef STRINGIZE }; +#define HUNGARIAN_NOTATION_PRIMITIVE_TYPES(m) \ + m(int8_t) \ + m(int16_t) \ + m(int32_t) \ + m(int64_t) \ + m(uint8_t) \ + m(uint16_t) \ + m(uint32_t) \ + m(uint64_t) \ + m(char8_t) \ + m(char16_t) \ + m(char32_t) \ + m(float) \ + m(double) \ + m(char) \ + m(bool) \ + m(_Bool) \ + m(int) \ + m(size_t) \ + m(wchar_t) \ + m(short-int) \ + m(short) \ + m(signed-int) \ + m(signed-short) \ + m(signed-short-int) \ + m(signed-long-long-int) \ + m(signed-long-long) \ + m(signed-long-int) \ + m(signed-long) \ + m(signed) \ + m(unsigned-long-long-int) \ + m(unsigned-long-long) \ + m(unsigned-long-int) \ + m(unsigned-long) \ + m(unsigned-short-int) \ + m(unsigned-short) \ + m(unsigned-int) \ + m(unsigned) \ + m(long-long-int) \ + m(long-double) \ + m(long-long) \ + m(long-int) \ + m(long) \ + m(ptrdiff_t) \ + +static StringRef const HungarainNotationPrimitiveTypes[] = { +#define STRINGIZE(v) #v, + HUNGARIAN_NOTATION_PRIMITIVE_TYPES(STRINGIZE) +#undef STRINGIZE +}; + +#define HUNGARIAN_NOTATION_USER_DEFINED_TYPES(m) \ + m(BOOL) \ + m(BOOLEAN) \ + m(BYTE) \ + m(CHAR) \ + m(UCHAR) \ + m(SHORT) \ + m(USHORT) \ + m(WORD) \ + m(DWORD) \ + m(DWORD32) \ + m(DWORD64) \ + m(LONG) \ + m(ULONG) \ + m(ULONG32) \ + m(ULONG64) \ + m(ULONGLONG) \ + m(HANDLE) \ + m(INT) \ + m(INT8) \ + m(INT16) \ + m(INT32) \ + m(INT64) \ + m(UINT) \ + m(UINT8) \ + m(UINT16) \ + m(UINT32) \ + m(UINT64) \ + m(PVOID) \ + +static StringRef const HungarainNotationUserDefinedTypes[] = { +#define STRINGIZE(v) #v, + HUNGARIAN_NOTATION_USER_DEFINED_TYPES(STRINGIZE) +#undef STRINGIZE +}; + + #undef NAMING_KEYS // clang-format on +static void getHungarianNotationDefaultConfig( + std::shared_ptr HNOption) { + + // Options + const static llvm::StringMap Options = { + {"ClassPrefixWithC", "0"}, {"VirtualClassPrefixWithI", "0"}}; + for (auto &Opt : Options) { + std::string Val = HNOption->Options.lookup(Opt.getKey()); + if (Val.empty()) { + HNOption->Options.insert({Opt.getKey(), Opt.getValue()}); + } + } + + // Derived types + const static llvm::StringMap DerivedTypes = { + {"Array", "a"}, {"Pointer", "p"}, {"FunctionPointer", "fn"}}; + for (auto &Other : DerivedTypes) { + std::string Val = HNOption->DerivedType.lookup(Other.getKey()); + if (Val.empty()) { + HNOption->DerivedType.insert({Other.getKey(), Other.getValue()}); + } + } + + // C strings + const static llvm::StringMap CStrings = { + {"char*", "sz"}, {"char", "sz"}, {"wchar_t*", "wsz"}, {"wchar_t", "wsz"}}; + for (auto &CStr : CStrings) { + std::string Val = HNOption->CString.lookup(CStr.getKey()); + if (Val.empty()) { + HNOption->CString.insert({CStr.getKey(), CStr.getValue()}); + } + } + + // clang-format off + const static llvm::StringMap PrimitiveTypes = { + {"int8_t", "i8" }, + {"int16_t", "i16" }, + {"int32_t", "i32" }, + {"int64_t", "i64" }, + {"uint8_t", "u8" }, + {"uint16_t", "u16" }, + {"uint32_t", "u32" }, + {"uint64_t", "u64" }, + {"char8_t", "c8" }, + {"char16_t", "c16" }, + {"char32_t", "c32" }, + {"float", "f" }, + {"double", "d" }, + {"char", "c" }, + {"bool", "b" }, + {"_Bool", "b" }, + {"int", "i" }, + {"size_t", "n" }, + {"wchar_t", "wc" }, + {"short int", "si" }, + {"short", "s" }, + {"signed int", "si" }, + {"signed short", "ss" }, + {"signed short int", "ssi" }, + {"signed long long int", "slli"}, + {"signed long long", "sll" }, + {"signed long int", "sli" }, + {"signed long", "sl" }, + {"signed", "s" }, + {"unsigned long long int", "ulli"}, + {"unsigned long long", "ull" }, + {"unsigned long int", "uli" }, + {"unsigned long", "ul" }, + {"unsigned short int", "usi" }, + {"unsigned short", "us" }, + {"unsigned int", "ui" }, + {"unsigned", "u" }, + {"long long int", "lli" }, + {"long double", "ld" }, + {"long long", "ll" }, + {"long int", "li" }, + {"long", "l" }, + {"ptrdiff_t", "p" }}; + // clang-format on + for (auto &Type : PrimitiveTypes) { + std::string Val = HNOption->PrimitiveType.lookup(Type.getKey()); + if (Val.empty()) { + HNOption->PrimitiveType.insert({Type.getKey(), Type.getValue()}); + } + } + + // clang-format off + const static llvm::StringMap UserDefinedTypes = { + // Windows data types + {"BOOL", "b" }, + {"BOOLEAN", "b" }, + {"BYTE", "by" }, + {"CHAR", "c" }, + {"UCHAR", "uc" }, + {"SHORT", "s" }, + {"USHORT", "us" }, + {"WORD", "w" }, + {"DWORD", "dw" }, + {"DWORD32", "dw32"}, + {"DWORD64", "dw64"}, + {"LONG", "l" }, + {"ULONG", "ul" }, + {"ULONG32", "ul32"}, + {"ULONG64", "ul64"}, + {"ULONGLONG", "ull" }, + {"HANDLE", "h" }, + {"INT", "i" }, + {"INT8", "i8" }, + {"INT16", "i16" }, + {"INT32", "i32" }, + {"INT64", "i64" }, + {"UINT", "ui" }, + {"UINT8", "u8" }, + {"UINT16", "u16" }, + {"UINT32", "u32" }, + {"UINT64", "u64" }, + {"PVOID", "p" } }; + // clang-format on + for (auto &Type : UserDefinedTypes) { + std::string Val = HNOption->UserDefinedType.lookup(Type.getKey()); + if (Val.empty()) { + HNOption->UserDefinedType.insert({Type.getKey(), Type.getValue()}); + } + } +} + +static void getHungarianNotationFileConfig( + const ClangTidyCheck::OptionsView &Options, + std::shared_ptr HNOption) { + std::string Section = "HungarianNotation."; + + std::vector HNOptions = {"ClassPrefixWithC", + "VirtualClassPrefixWithI"}; + for (auto const &Opt : HNOptions) { + std::string Key = Section + "Options." + Opt; + std::string Val = Options.get(Key, ""); + if (!Val.empty()) { + HNOption->Options.insert({Opt, Val}); + } + } + + std::vector HNDerivedTypes = {"Array", "Pointer", + "FunctionPointer"}; + for (auto const &DerivedType : HNDerivedTypes) { + std::string Key = Section + "DerivedType." + DerivedType; + std::string Val = Options.get(Key, ""); + if (!Val.empty()) { + HNOption->DerivedType.insert({DerivedType, Val}); + } + } + + std::vector> HNCStrings = { + {"CharPrinter", "char*"}, + {"CharArray", "char"}, + {"WideCharPrinter", "wchar_t*"}, + {"WideCharArray", "wchar_t"}}; + + for (auto const &CStr : HNCStrings) { + std::string Key = Section + "CString." + CStr.first; + std::string Val = Options.get(Key, ""); + if (!Val.empty()) { + HNOption->CString.insert({CStr.second, Val}); + } + } + + for (auto const &PrimType : HungarainNotationPrimitiveTypes) { + std::string Key = Section + "PrimitiveType." + PrimType.str(); + std::string Val = Options.get(Key, ""); + std::string Type = PrimType.str(); + if (!Val.empty()) { + if (Type.find('-') != std::string::npos) { + for (size_t i = 0; i < Type.length(); ++i) { + if (Type[i] == '-') { + Type.replace(i, 1, " "); + } + } + } + HNOption->PrimitiveType.insert({Type, Val}); + } + } + + for (auto const &WDType : HungarainNotationUserDefinedTypes) { + std::string Key = Section + "UserDefinedType." + WDType.str(); + std::string Val = Options.get(Key, ""); + std::string Type = WDType.str(); + if (!Val.empty()) { + HNOption->UserDefinedType.insert({Type, Val}); + } + } +} + static std::vector> getNamingStyles(const ClangTidyCheck::OptionsView &Options) { std::vector> Styles; + auto HNOption = + std::make_shared(); Styles.reserve(array_lengthof(StyleNames)); for (auto const &StyleName : StyleNames) { auto CaseOptional = Options.getOptional( @@ -135,10 +417,15 @@ if (CaseOptional || !Prefix.empty() || !Postfix.empty()) Styles.emplace_back(IdentifierNamingCheck::NamingStyle{ - std::move(CaseOptional), std::move(Prefix), std::move(Postfix)}); + std::move(CaseOptional), std::move(Prefix), std::move(Postfix), + HNOption}); else Styles.emplace_back(llvm::None); } + + getHungarianNotationFileConfig(Options, HNOption); + getHungarianNotationDefaultConfig(HNOption); + return Styles; } @@ -180,101 +467,51 @@ Options.store(Opts, "IgnoreMainLikeFunctions", IgnoreMainLikeFunctions); } -static const std::string -getHungarianNotationTypePrefix(const std::string &TypeName, - const NamedDecl *InputDecl) { - if (!InputDecl || TypeName.empty()) { +static const std::string getHungarianNotationDataTypePrefix( + const std::string &TypeName, const NamedDecl *ND, + const IdentifierNamingCheck::HungarianNotationOption &HNOption) { + if (!ND || TypeName.empty()) { return TypeName; } - // clang-format off - const static llvm::StringMap HungarianNotationTable = { - // Primitive types - {"int8_t", "i8"}, - {"int16_t", "i16"}, - {"int32_t", "i32"}, - {"int64_t", "i64"}, - {"uint8_t", "u8"}, - {"uint16_t", "u16"}, - {"uint32_t", "u32"}, - {"uint64_t", "u64"}, - {"char8_t", "c8"}, - {"char16_t", "c16"}, - {"char32_t", "c32"}, - {"float", "f"}, - {"double", "d"}, - {"char", "c"}, - {"bool", "b"}, - {"_Bool", "b"}, - {"int", "i"}, - {"size_t", "n"}, - {"wchar_t", "wc"}, - {"short", "s"}, - {"signed", "i"}, - {"unsigned", "u"}, - {"long", "l"}, - {"long long", "ll"}, - {"unsigned long", "ul"}, - {"long double", "ld"}, - {"ptrdiff_t", "p"}, - // Windows data types - {"BOOL", "b"}, - {"BOOLEAN", "b"}, - {"BYTE", "by"}, - {"WORD", "w"}, - {"DWORD", "dw"}}; - // clang-format on - - std::string ClonedTypeName = TypeName; + std::string ModifiedTypeName = TypeName; - // Handle null string + // Derived types std::string PrefixStr; - if (const auto *TD = dyn_cast(InputDecl)) { + if (const auto *TD = dyn_cast(ND)) { auto QT = TD->getType(); if (QT->isFunctionPointerType()) { - PrefixStr = "fn"; // Function Pointer + PrefixStr = HNOption.DerivedType.lookup("FunctionPointer"); } else if (QT->isPointerType()) { - // clang-format off - const static llvm::StringMap NullString = { - {"char*", "sz"}, - {"wchar_t*", "wsz"}}; - // clang-format on - for (const auto &Type : NullString) { - const auto &Key = Type.getKey(); - if (ClonedTypeName.find(Key.str()) == 0) { - PrefixStr = Type.getValue().str(); - ClonedTypeName = ClonedTypeName.substr( - Key.size(), ClonedTypeName.size() - Key.size()); + for (const auto &CStr : HNOption.CString) { + auto Key = CStr.getKey().str(); + if (ModifiedTypeName.find(Key) == 0) { + PrefixStr = CStr.getValue(); + ModifiedTypeName = ModifiedTypeName.substr( + Key.size(), ModifiedTypeName.size() - Key.size()); break; } } } else if (QT->isArrayType()) { - // clang-format off - const static llvm::StringMap NullString = { - {"char", "sz"}, - {"wchar_t", "wsz"}}; - // clang-format on - for (const auto &Type : NullString) { - const auto &Key = Type.getKey(); - if (ClonedTypeName.find(Key.str()) == 0) { - PrefixStr = Type.getValue().str(); - ClonedTypeName = ClonedTypeName.substr( - Key.size(), ClonedTypeName.size() - Key.size()); + for (const auto &CStr : HNOption.CString) { + auto Key = CStr.getKey().str(); + if (ModifiedTypeName.find(Key) == 0) { + PrefixStr = CStr.getValue(); break; } } if (PrefixStr.empty()) { - PrefixStr = 'a'; // Array + PrefixStr = HNOption.DerivedType.lookup("Array"); } } else if (QT->isReferenceType()) { - size_t Pos = ClonedTypeName.find_last_of("&"); + size_t Pos = ModifiedTypeName.find_last_of("&"); if (Pos != std::string::npos) { - ClonedTypeName = ClonedTypeName.substr(0, Pos); + ModifiedTypeName = ModifiedTypeName.substr(0, Pos); } } } - // Handle pointers + // Pointers size_t PtrCount = [&](std::string TypeName) -> size_t { size_t Pos = TypeName.find('*'); size_t Count = 0; @@ -283,55 +520,166 @@ break; } return Count; - }(ClonedTypeName); + }(ModifiedTypeName); if (PtrCount > 0) { - ClonedTypeName = [&](std::string Str, const std::string &From, - const std::string &To) { + ModifiedTypeName = [&](std::string Str, const std::string &From, + const std::string &To) { size_t StartPos = 0; while ((StartPos = Str.find(From, StartPos)) != std::string::npos) { Str.replace(StartPos, From.length(), To); StartPos += To.length(); } return Str; - }(ClonedTypeName, "*", ""); + }(ModifiedTypeName, "*", ""); } + // Primitive types if (PrefixStr.empty()) { - for (const auto &Type : HungarianNotationTable) { - const auto &Key = Type.getKey(); - if (ClonedTypeName == Key) { - PrefixStr = Type.getValue().str(); + for (const auto &Type : HNOption.PrimitiveType) { + const auto &key = Type.getKey().str(); + if (ModifiedTypeName == key) { + PrefixStr = Type.getValue(); break; } } } - if (PtrCount > 0) { - for (size_t Idx = 0; Idx < PtrCount; Idx++) { - PrefixStr.insert(PrefixStr.begin(), 'p'); + // User-Defined types + if (PrefixStr.empty()) { + for (const auto &Type : HNOption.UserDefinedType) { + const auto &key = Type.getKey().str(); + if (ModifiedTypeName == key) { + PrefixStr = Type.getValue(); + break; + } } } + for (size_t Idx = 0; Idx < PtrCount; Idx++) { + PrefixStr.insert(0, HNOption.DerivedType.lookup("Pointer")); + } + return PrefixStr; } -std::string -IdentifierNamingCheck::getDeclTypeName(const clang::NamedDecl *Decl) const { - const ValueDecl *ValDecl = dyn_cast(Decl); - if (!ValDecl) { +static bool isHungarianNotationPrefix( + const std::string Prefix, + const IdentifierNamingCheck::HungarianNotationOption &HNOption) { + for (const auto &Type : HNOption.PrimitiveType) { + if (Prefix == Type.getValue()) + return true; + } + + std::size_t PtrCount = 0; + for (size_t Idx = 0; Idx < Prefix.size(); Idx++) { + if (Prefix[Idx] == 'p') + PtrCount++; + } + if (Prefix.length() == PtrCount) + return true; + + return false; +} + +static std::string getHungarianNotationClassPrefix( + const CXXRecordDecl *CRD, + const IdentifierNamingCheck::HungarianNotationOption &HNOption) { + bool ClassPrefixWithC = false; + std::string CArg = HNOption.Options.lookup("ClassPrefixWithC"); + for (auto &C : CArg) + C = toupper(C); + if (CArg == "1" || CArg == "TRUE" || CArg == "ON") { + ClassPrefixWithC = true; + } + + bool ClassPrefixWithI = false; + std::string IArg = HNOption.Options.lookup("VirtualClassPrefixWithI"); + for (auto &C : IArg) + C = toupper(C); + if (CArg == "1" || CArg == "TRUE" || CArg == "ON") { + ClassPrefixWithI = true; + } + + // A class is made abstract by declaring at least one of + // its functions as pure virtual function. + bool IsAbstractClass = false; + for (const auto *Method : CRD->methods()) { + if (Method->isPure()) { + IsAbstractClass = true; + break; + } + } + + std::string Prefix; + if (IsAbstractClass) { + if (ClassPrefixWithI) + Prefix = "I"; + } else { + if (ClassPrefixWithC) + Prefix = "C"; + } + + return Prefix; +} + +static std::string getHungarianNotationEnumPrefix(const EnumConstantDecl *ECD) { + std::string Name = ECD->getType().getAsString(); + if (std::string::npos != Name.find("enum")) { + Name = Name.substr(strlen("enum"), Name.length() - strlen("enum")); + Name = Name.erase(0, Name.find_first_not_of(" ")); + } + + static llvm::Regex Splitter( + "([a-z0-9A-Z]*)(_+)|([A-Z]?[a-z0-9]+)([A-Z]|$)|([A-Z]+)([A-Z]|$)"); + + llvm::StringRef EnumName(Name); + SmallVector Substrs; + EnumName.split(Substrs, "_", -1, false); + + SmallVector Words; + SmallVector Groups; + for (auto Substr : Substrs) { + while (!Substr.empty()) { + Groups.clear(); + if (!Splitter.match(Substr, &Groups)) + break; + + if (Groups[2].size() > 0) { + Words.push_back(Groups[1]); + Substr = Substr.substr(Groups[0].size()); + } else if (Groups[3].size() > 0) { + Words.push_back(Groups[3]); + Substr = Substr.substr(Groups[0].size() - Groups[4].size()); + } else if (Groups[5].size() > 0) { + Words.push_back(Groups[5]); + Substr = Substr.substr(Groups[0].size() - Groups[6].size()); + } + } + } + + std::string Initial; + for (auto const &Word : Words) { + Initial += tolower(Word[0]); + } + return Initial; +} + +static std::string getDeclTypeName(const clang::NamedDecl *ND) { + const auto VD = dyn_cast(ND); + if (!VD) { return ""; } - if (clang::Decl::Kind::EnumConstant == Decl->getKind() || - clang::Decl::Kind::CXXMethod == Decl->getKind()|| - clang::Decl::Kind::Function == Decl->getKind()) { + if (clang::Decl::Kind::EnumConstant == ND->getKind() || + clang::Decl::Kind::CXXMethod == ND->getKind()|| + clang::Decl::Kind::Function == ND->getKind()) { return ""; } // Get type text of variable declarations. - auto &SM = ValDecl->getASTContext().getSourceManager(); - const char *Begin = SM.getCharacterData(ValDecl->getBeginLoc()); - const char *End = SM.getCharacterData(ValDecl->getEndLoc()); + auto &SM = VD->getASTContext().getSourceManager(); + const char *Begin = SM.getCharacterData(VD->getBeginLoc()); + const char *End = SM.getCharacterData(VD->getEndLoc()); intptr_t StrLen = End - Begin; // FIXME: Sometimes the value that returns from ValDecl->getEndLoc() @@ -372,6 +720,7 @@ Type.replace(Pos, Kw.length(), ""); } } + TypeName = Type.erase(0, Type.find_first_not_of(" ")); // Replace spaces with single space. for (size_t Pos = 0; (Pos = Type.find(" ", Pos)) != std::string::npos; @@ -393,10 +742,11 @@ // Remove redundant tailing. const static std::list TailsOfMultiWordType = { - " int", " char", " double", " long"}; + " int", " char", " double", " long", " short"}; bool RedundantRemoved = false; - for (const std::string &Kw : TailsOfMultiWordType) { - for (size_t Pos = 0; (Pos = Type.find(Kw, Pos)) != std::string::npos;) { + for (const auto &Kw : TailsOfMultiWordType) { + size_t Pos = Type.rfind(Kw); + if (Pos != std::string::npos) { Type = Type.substr(0, Pos + Kw.length()); RedundantRemoved = true; break; @@ -416,6 +766,42 @@ return TypeName; } +static std::string getHungarianNotationPrefix( + const clang::NamedDecl *ND, + const IdentifierNamingCheck::HungarianNotationOption &HNOption) { + std::string Prefix; + switch (ND->getKind()) { + case clang::Decl::Kind::Var: + case clang::Decl::Kind::Field: + case clang::Decl::Kind::ParmVar: + case clang::Decl::Kind::Record: + if (ND) { + std::string TypeName = getDeclTypeName(ND); + if (!TypeName.empty()) + Prefix = getHungarianNotationDataTypePrefix(TypeName, ND, HNOption); + } + break; + + case clang::Decl::Kind::EnumConstant: + if (ND) { + const auto ECD = dyn_cast(ND); + Prefix = getHungarianNotationEnumPrefix(ECD); + } + break; + + case clang::Decl::Kind::CXXRecord: + if (ND) { + const auto CRD = dyn_cast(ND); + Prefix = getHungarianNotationClassPrefix(CRD, HNOption); + } + break; + + default: + break; + } + return Prefix; +} + static bool matchesStyle(StringRef Type, StringRef Name, IdentifierNamingCheck::NamingStyle Style, const NamedDecl *Decl) { @@ -441,12 +827,12 @@ return false; if (Style.Case == IdentifierNamingCheck::CaseType::CT_HungarianNotation) { - const std::string TypePrefix = - getHungarianNotationTypePrefix(Type.str(), Decl); - if (TypePrefix.length() > 0) { - if (!Name.startswith(TypePrefix)) + const std::string Prefix = + getHungarianNotationPrefix(Decl, *Style.HNOption); + if (Prefix.length() > 0) { + if (!Name.startswith(Prefix)) return false; - Name = Name.drop_front(TypePrefix.size()); + Name = Name.drop_front(Prefix.size()); } } @@ -456,9 +842,11 @@ return true; } -static std::string fixupWithCase(const StringRef &Type, const StringRef &Name, - const Decl *InputDecl, - IdentifierNamingCheck::CaseType Case) { +static std::string +fixupWithCase(const StringRef &Type, const StringRef &Name, + const Decl *InputDecl, + const IdentifierNamingCheck::NamingStyle &Style, + IdentifierNamingCheck::CaseType Case) { static llvm::Regex Splitter( "([a-z0-9A-Z]*)(_+)|([A-Z]?[a-z0-9]+)([A-Z]|$)|([A-Z]+)([A-Z]|$)"); @@ -551,21 +939,24 @@ break; case IdentifierNamingCheck::CT_HungarianNotation: { - const NamedDecl *ND = dyn_cast(InputDecl); - const std::string TypePrefix = - getHungarianNotationTypePrefix(Type.str(), ND); - Fixup = TypePrefix; - for (size_t Idx = 0; Idx < Words.size(); Idx++) { - // Skip first part if it's a lowercase string. - if (Idx == 0) { - bool LowerAlnum = - std::all_of(Words[Idx].begin(), Words[Idx].end(), - [](const char C) { return isdigit(C) || islower(C); }); - if (LowerAlnum) - continue; + const auto ND = dyn_cast(InputDecl); + Fixup = getHungarianNotationPrefix(ND, *Style.HNOption); + + std::string Concating = ""; + for (size_t WordIdx = 0; WordIdx < Words.size(); WordIdx++) { + std::string Word = Words[WordIdx].str(); + if ((WordIdx == 0) && isHungarianNotationPrefix(Word, *Style.HNOption)) + continue; + + for (size_t LtrIdx = 0; LtrIdx < Word.size(); LtrIdx++) { + if (LtrIdx == 0) + Word[LtrIdx] = toupper(Word[LtrIdx]); + else + Word[LtrIdx] = tolower(Word[LtrIdx]); } - Fixup += Words[Idx]; + Concating += Word; } + Fixup += Concating; break; } } @@ -638,7 +1029,7 @@ const IdentifierNamingCheck::NamingStyle &Style, const Decl *InputDecl) { const std::string Fixed = fixupWithCase( - Type, Name, InputDecl, + Type, Name, InputDecl, Style, Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase)); StringRef Mid = StringRef(Fixed).trim("_"); if (Mid.empty()) @@ -926,7 +1317,7 @@ } static llvm::Optional getFailureInfo( - const StringRef &Type, const StringRef &Name, const NamedDecl *Decl, + const StringRef &Type, const StringRef &Name, const NamedDecl *ND, SourceLocation Location, ArrayRef> NamingStyles, StyleKind SK, const SourceManager &SM, bool IgnoreFailedSplit) { @@ -934,14 +1325,14 @@ return None; const IdentifierNamingCheck::NamingStyle &Style = *NamingStyles[SK]; - if (matchesStyle(Type, Name, Style, Decl)) + if (matchesStyle(Type, Name, Style, ND)) return None; - std::string KindName = fixupWithCase(Type, StyleNames[SK], Decl, + std::string KindName = fixupWithCase(Type, StyleNames[SK], ND, Style, IdentifierNamingCheck::CT_LowerCase); std::replace(KindName.begin(), KindName.end(), '_', ' '); - std::string Fixup = fixupWithStyle(Type, Name, Style, Decl); + std::string Fixup = fixupWithStyle(Type, Name, Style, ND); if (StringRef(Fixup).equals(Name)) { if (!IgnoreFailedSplit) { LLVM_DEBUG(Location.print(llvm::dbgs(), SM); diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst b/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst --- a/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst @@ -34,64 +34,50 @@ Hungarian Notation casing type ------------------------------ -In Hungarian notation, a variable name starts with a group of lower-case +In Hungarian notation, a variable name starts with a group of lower-case letters which are mnemonics for the type or purpose of that variable, followed -by whatever name the programmer has chosen; this last part is sometimes -distinguished as the given name. The first character of the given name can be -capitalized to separate it from the type indicators (see also CamelCase). +by whatever name the programmer has chosen; this last part is sometimes +distinguished as the given name. The first character of the given name can be +capitalized to separate it from the type indicators (see also CamelCase). Otherwise the case of this character denotes scope. -============ ============= ================ ============= =========== ============== -Primitive Types Microsoft data types ---------------------------------------------------------- -------------------------- - Type Prefix Type Prefix Type Prefix -============ ============= ================ ============= =========== ============== -int8_t i8 short s BOOL b -int16_t i16 signed i BOOLEAN b -int32_t i32 unsigned u BYTE by -int64_t i64 long l WORD w -uint8_t u8 long long ll DWORD dw -uint16_t u16 unsigned long ul -uint32_t u32 long double ld -uint64_t u64 ptrdiff_t p -char8_t c8 -char16_t c16 -char32_t c32 -float f -double d -char c -bool b -_Bool b -int i -size_t n -============ ============= ================ ============= =========== ============== +================= ============== ====================== ============== =========== ============== +Primitive Types Microsoft data types +---------------------------------------------------------------------- -------------------------- + Type Prefix Type Prefix Type Prefix +================= ============== ====================== ============== =========== ============== +int8_t i8 signed int si BOOL b +int16_t i16 signed short ss BOOLEAN b +int32_t i32 signed short int ssi BYTE by +int64_t i64 signed long long int slli CHAR c +uint8_t u8 signed long long sll UCHAR uc +uint16_t u16 signed long int sli SHORT s +uint32_t u32 signed long sl USHORT us +uint64_t u64 signed s WORD w +char8_t c8 unsigned long long int ulli DWORD dw +char16_t c16 unsigned long long ull DWORD32 dw32 +char32_t c32 unsigned long int uli DWORD64 dw64 +float f unsigned long ul LONG l +double d unsigned short int usi ULONG ul +char c unsigned short us ULONG32 ul32 +bool b unsigned int ui ULONG64 ul64 +_Bool b unsigned u ULONGLONG ull +int i long long int lli HANDLE h +size_t n long double ld INT i +short s long long ll INT8 i8 +signed i long int li INT16 i16 +unsigned u long l INT32 i32 +long l ptrdiff_t p INT64 i64 +long long ll UINT ui +unsigned long ul UINT8 u8 +long double ld UINT16 u16 +ptrdiff_t p UINT32 u32 +wchar_t wc UINT64 u64 +short int si PVOID p +short s +================= ============== ====================== ============== =========== ============== - -- **Pointer type starts with `p`,** - - .. code-block:: c++ - - void *pData = NULL; - void **ppData = NULL; - uint8_t *pu8Data = NULL; - -- **Array type start with `a`,** - - .. code-block:: c++ - - int aDataInt[1] = {0}; - int* paDataIntPtr[1] = {0}; - -- **Null terminated string starts with `sz`** - - .. code-block:: c++ - - char szNameArray[] = {"Text"}; - char *szNamePtr = {"Text"}; - char **pszNamePtr = {"Text"}; - - Options ------- @@ -2100,3 +2086,179 @@ public: virtual int pre_member_function_post(); } + + +Options for Hungarian Notation +----------------------------- + +The following options(readability-identifier-naming.HungarianNotation.Options.) are describe below: + + - :option:`ClassPrefixWithC`, :option:`VirtualClassPrefixWithI` + +.. option:: ClassPrefixWithC + + When set to `1` it makes the name of class starting with a `C` character. Default value is `0`. + +.. option:: VirtualClassPrefixWithI + + When set to `1` it makes the name of abstract class starting with a `I` character. Default value is `0`. + + +The following options(readability-identifier-naming.HungarianNotation.DerivedType.) are describe below: + + - :option:`Array`, :option:`Pointer`, :option:`FunctionPointer` + +.. option:: Array + + When defined, the check will ensure variable names will add the + prefix with the given value. + +.. option:: Pointer + + When defined, the check will ensure variable names will add the + prefix with the given value. + +.. option:: FunctionPointer + + When defined, the check will ensure variable names will add the + prefix with the given value. + +For example using values of: + + - Array of ``a`` + - Pointer of ``p`` + - FunctionPointer of ``fn`` + +Before: + +.. code-block:: c++ + + // Array + int DataArray[2] = {0}; + + // Pointer + void *DataBuffer = NULL; + + // FunctionPointer + typedef void (*FUNC_PTR)(); + FUNC_PTR FuncPtr = NULL; + +After: + +.. code-block:: c++ + + // Array + int aDataArray[2] = {0}; + + // Pointer + void *pDataBuffer = NULL; + + // FunctionPointer + typedef void (*FUNC_PTR)(); + FUNC_PTR fnFuncPtr = NULL; + + +The following options(readability-identifier-naming.HungarianNotation.CString.) are describe below: + + - :option:`CharPrinter`, :option:`CharArray`, :option:`WideCharPrinter`, :option:`WideCharArray` + +.. option:: CharPrinter + + When defined, the check will ensure variable names will add the + prefix with the given value. + +.. option:: CharArray + + When defined, the check will ensure variable names will add the + prefix with the given value. + +.. option:: WideCharPrinter + + When defined, the check will ensure variable names will add the + prefix with the given value. + +.. option:: WideCharArray + + When defined, the check will ensure variable names will add the + prefix with the given value. + +For example using values of: + + - CharPrinter of ``sz`` + - CharArray of ``sz`` + - WideCharPrinter of ``wsz`` + - WideCharArray of ``wsz`` + +Before: + +.. code-block:: c++ + + // CharPrinter + const char *NamePtr = "Name"; + + // CharArray + const char NameArray[] = "Name"; + + // WideCharPrinter + const wchar_t *WideNamePtr = L"Name"; + + // WideCharArray + const wchar_t WideNameArray[] = L"Name"; + +After: + +.. code-block:: c++ + + // CharPrinter + const char *szNamePtr = "Name"; + + // CharArray + const char szNameArray[] = "Name"; + + // WideCharPrinter + const wchar_t *wszWideNamePtr = L"Name"; + + // WideCharArray + const wchar_t wszWideNameArray[] = L"Name"; + + +The following options(readability-identifier-naming.HungarianNotation.PrimitiveType.) are describe below: + + - :option:`int8_t`, :option:`int16_t`, :option:`int32_t`, :option:`int64_t`, :option:`uint8_t`, :option:`uint16_t`, :option:`uint32_t`, :option:`uint64_t`, :option:`char8_t`, :option:`char16_t`, :option:`char32_t` + - :option:`char`, :option:`wchar_t`, :option:`float`, :option:`double`, :option:`bool`, :option:`_Bool`, :option:`int`, :option:`size_t`, :option:`short`, :option:`long`, :option:`ptrdiff_t` + - :option:`short-int`, :option:`signed-int`, :option:`signed-short`, :option:`signed-short-int`, :option:`signed-long-long-int`, :option:`signed-long-long`, :option:`signed-long-int`, :option:`signed-long`, :option:`signed`, :option:`unsigned-long-long-int`, :option:`unsigned-long-long`, :option:`unsigned-long-int`, :option:`unsigned-long`, :option:`unsigned-short-int`, :option:`unsigned-short`, :option:`unsigned-int`, :option:`unsigned`, :option:`long-long-int`, :option:`long-double`, :option:`long-long`, :option:`long-int` + - :option:`BOOL`, :option:`BOOLEAN`, :option:`BYTE`, :option:`CHAR`, :option:`UCHAR`, :option:`SHORT`, :option:`USHORT`, :option:`WORD`, :option:`DWORD`, :option:`DWORD32`, :option:`DWORD64`, :option:`LONG`, :option:`ULONG`, :option:`ULONG32`, :option:`ULONG64`, :option:`ULONGLONG`, :option:`HANDLE`, :option:`INT`, :option:`INT8`, :option:`INT16`, :option:`INT32`, :option:`INT64`, :option:`UINT`, :option:`UINT8`, :option:`UINT16`, :option:`UINT32`, :option:`UINT64`, :option:`PVOID` + +Before: + +.. code-block:: c++ + + int8_t ValueI8; + int16_t ValueI16; + int32_t ValueI32; + int64_t ValueI64; + uint8_t ValueU8; + uint16_t ValueU16; + uint32_t ValueU32; + uint64_t ValueU64; + float ValueFloat; + double ValueDouble; + ULONG ValueUlong; + DWORD ValueDword; + +After: + +.. code-block:: c++ + + int8_t i8ValueI8; + int16_t i16ValueI16; + int32_t i32ValueI32; + int64_t i64ValueI64; + uint8_t u8ValueU8; + uint16_t u16ValueU16; + uint32_t u32ValueU32; + uint64_t u64ValueU64; + float fValueFloat; + double dValueDouble; + ULONG ulValueUlong; + DWORD dwValueDword; diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation-cfgfile-class.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation-cfgfile-class.cpp new file mode 100644 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation-cfgfile-class.cpp @@ -0,0 +1,44 @@ +// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \ +// RUN: -config='{ CheckOptions: [ \ +// RUN: { key: readability-identifier-naming.ClassMemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantMemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantPointerParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstexprVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.GlobalConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.GlobalConstantPointerCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.GlobalVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalConstantPointerCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalPointerCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.MemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.PointerParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.PrivateMemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.StaticConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.StaticVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.StructCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.UnionCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.VariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.Options.ClassPrefixWithC , value: 1 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.Options.VirtualClassPrefixWithI , value: 1 }, \ +// RUN: ]}' + +// clang-format off +//===----------------------------------------------------------------------===// +// Class +//===----------------------------------------------------------------------===// +class MyClass { int Func(); }; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for struct 'MyClass' [readability-identifier-naming] +// CHECK-FIXES: {{^}}class CMyClass { int Func(); }; + +class AbstractClass { virtual int Func() = 0; }; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for struct 'AbstractClass' [readability-identifier-naming] +// CHECK-FIXES: {{^}}class IAbstractClass { virtual int Func() = 0; }; + +class AbstractClass1 { virtual int Func1() = 0; int Func2(); }; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for struct 'AbstractClass1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}class IAbstractClass1 { virtual int Func1() = 0; int Func2(); }; +// clang-format on diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation-cfgfile.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation-cfgfile.cpp new file mode 100644 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation-cfgfile.cpp @@ -0,0 +1,782 @@ +// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \ +// RUN: -config='{ CheckOptions: [ \ +// RUN: { key: readability-identifier-naming.ClassMemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantMemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantPointerParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstexprVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.GlobalConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.GlobalConstantPointerCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.GlobalVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalConstantPointerCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalPointerCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.MemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.PointerParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.PrivateMemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.StaticConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.StaticVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.StructCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.UnionCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.VariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.DerivedType.Array , value: a }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.DerivedType.Pointer , value: p }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.DerivedType.FunctionPointer , value: fn }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.CString.CharPrinter , value: sz }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.CString.CharArray , value: sz }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.CString.WideCharPrinter , value: wsz }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.CString.WideCharArray , value: wsz }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.int8_t , value: i8 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.int16_t , value: i16 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.int32_t , value: i32 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.int64_t , value: i64 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.uint8_t , value: u8 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.uint16_t , value: u16 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.uint32_t , value: u32 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.uint64_t , value: u64 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.char8_t , value: c8 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.char16_t , value: c16 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.char32_t , value: c32 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.float , value: f }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.double , value: d }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.char , value: c }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.bool , value: b }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType._Bool , value: b }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.int , value: i }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.size_t , value: n }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.wchar_t , value: wc }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.short-int , value: si }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.short , value: s }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.signed-int , value: si }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.signed-short , value: ss }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.signed-short-int , value: ssi }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.signed-long-long-int , value: slli }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.signed-long-long , value: sll }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.signed-long-int , value: sli }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.signed-long , value: sl }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.signed , value: s }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.unsigned-long-long-int , value: ulli }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.unsigned-long-long , value: ull }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.unsigned-long-int , value: uli }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.unsigned-long , value: ul }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.unsigned-short-int , value: usi }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.unsigned-short , value: us }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.unsigned-int , value: ui }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.unsigned , value: u }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.long-long-int , value: lli }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.long-double , value: ld }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.long-long , value: ll }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.long-int , value: li }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.long , value: l }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.PrimitiveType.ptrdiff_t , value: p }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.BOOL , value: b }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.BOOLEAN , value: b }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.BYTE , value: by }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.CHAR , value: c }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.UCHAR , value: uc }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.SHORT , value: s }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.USHORT , value: us }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.WORD , value: w }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.DWORD , value: dw }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.DWORD32 , value: dw32 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.DWORD64 , value: dw64 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.LONG , value: l }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.ULONG , value: ul }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.ULONG32 , value: ul32 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.ULONG64 , value: ul64 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.ULONGLONG , value: ull }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.HANDLE , value: h }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.INT , value: i }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.INT8 , value: i8 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.INT16 , value: i16 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.INT32 , value: i32 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.INT64 , value: i64 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.UINT , value: ui }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.UINT8 , value: u8 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.UINT16 , value: u16 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.UINT32 , value: u32 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.UINT64 , value: u64 }, \ +// RUN: { key: readability-identifier-naming.HungarianNotation.UserDefinedType.PVOID , value: p }, \ +// RUN: ]}' + +// clang-format off +typedef signed char int8_t; // NOLINT +typedef short int16_t; // NOLINT +typedef long int32_t; // NOLINT +typedef long long int64_t; // NOLINT +typedef unsigned char uint8_t; // NOLINT +typedef unsigned short uint16_t; // NOLINT +typedef unsigned long uint32_t; // NOLINT +typedef unsigned long long uint64_t; // NOLINT +#ifndef _WIN32 +typedef unsigned long long size_t; // NOLINT +#endif +typedef long intptr_t; // NOLINT +typedef unsigned long uintptr_t; // NOLINT +typedef long int ptrdiff_t; // NOLINT +typedef unsigned char BYTE; // NOLINT +typedef unsigned short WORD; // NOLINT +typedef unsigned long DWORD; // NOLINT +typedef int BOOL; // NOLINT +typedef int BOOLEAN; // NOLINT +typedef float FLOAT; // NOLINT +typedef int INT; // NOLINT +typedef unsigned int UINT; // NOLINT +typedef unsigned long ULONG; // NOLINT +typedef short SHORT; // NOLINT +typedef unsigned short USHORT; // NOLINT +typedef char CHAR; // NOLINT +typedef unsigned char UCHAR; // NOLINT +typedef signed char INT8; // NOLINT +typedef signed short INT16; // NOLINT +typedef signed int INT32; // NOLINT +typedef signed long long INT64; // NOLINT +typedef unsigned char UINT8; // NOLINT +typedef unsigned short UINT16; // NOLINT +typedef unsigned int UINT32; // NOLINT +typedef unsigned long long UINT64; // NOLINT +typedef long LONG; // NOLINT +typedef signed int LONG32; // NOLINT +typedef unsigned int ULONG32; // NOLINT +typedef uint64_t ULONG64; // NOLINT +typedef unsigned int DWORD32; // NOLINT +typedef uint64_t DWORD64; // NOLINT +typedef uint64_t ULONGLONG; // NOLINT +typedef void* PVOID; // NOLINT +typedef void* HANDLE; // NOLINT +typedef void* FILE; // NOLINT +#define NULL (0) // NOLINT +// clang-format on + +// clang-format off +//===----------------------------------------------------------------------===// +// Cases to CheckOptions +//===----------------------------------------------------------------------===// +class MyClass1 { +public: + static int ClassMemberCase; + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for class member 'ClassMemberCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} static int iClassMemberCase; + + char const ConstantMemberCase = 0; + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for constant member 'ConstantMemberCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} char const cConstantMemberCase = 0; + + void MyFunc1(const int ConstantParameterCase); + // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for constant parameter 'ConstantParameterCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} void MyFunc1(const int iConstantParameterCase); + + void MyFunc2(const int* ConstantPointerParameterCase); + // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: invalid case style for pointer parameter 'ConstantPointerParameterCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} void MyFunc2(const int* piConstantPointerParameterCase); + + static constexpr int ConstexprVariableCase = 123; + // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: invalid case style for constexpr variable 'ConstexprVariableCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} static constexpr int iConstexprVariableCase = 123; +}; + +const int GlobalConstantCase = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global constant 'GlobalConstantCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const int iGlobalConstantCase = 0; + +const int* GlobalConstantPointerCase = nullptr; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'GlobalConstantPointerCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const int* piGlobalConstantPointerCase = nullptr; + +int GlobalVariableCase = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'GlobalVariableCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iGlobalVariableCase = 0; + +void Func1(){ + int const LocalConstantCase = 3; + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for local constant 'LocalConstantCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} int const iLocalConstantCase = 3; + + int* const LocalConstantPointerCase = nullptr; + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for local constant pointer 'LocalConstantPointerCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} int* const piLocalConstantPointerCase = nullptr; + + int *LocalPointerCase = nullptr; + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local pointer 'LocalPointerCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} int *piLocalPointerCase = nullptr; + + int LocalVariableCase = 0; + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for local variable 'LocalVariableCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} int iLocalVariableCase = 0; +} + +class MyClass2 { + char MemberCase; + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for private member 'MemberCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} char cMemberCase; + + void Func1(int ParameterCase); + // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'ParameterCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} void Func1(int iParameterCase); + + void Func2(const int ParameterCase); + // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: invalid case style for constant parameter 'ParameterCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} void Func2(const int iParameterCase); + + void Func3(const int *PointerParameterCase); + // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: invalid case style for pointer parameter 'PointerParameterCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} void Func3(const int *piPointerParameterCase); +}; + +class MyClass3 { +private: + char PrivateMemberCase; + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for private member 'PrivateMemberCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} char cPrivateMemberCase; +}; + +static const int StaticConstantCase = 3; +// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global constant 'StaticConstantCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}static const int iStaticConstantCase = 3; + +static int StaticVariableCase = 3; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'StaticVariableCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}static int iStaticVariableCase = 3; + +struct MyStruct { int StructCase; }; +// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: invalid case style for member 'StructCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}struct MyStruct { int iStructCase; }; + +union MyUnion { int UnionCase1; long lUnionCase2; }; +// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for member 'UnionCase1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}union MyUnion { int iUnionCase1; long lUnionCase2; }; + +//===----------------------------------------------------------------------===// +// C string +//===----------------------------------------------------------------------===// +const char *NamePtr = "Name"; +// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'NamePtr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const char *szNamePtr = "Name"; + +const char NameArray[] = "Name"; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global constant 'NameArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const char szNameArray[] = "Name"; + +const char *NamePtrArray[] = {"AA", "BB"}; +// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'NamePtrArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const char *pszNamePtrArray[] = {"AA", "BB"}; + +const wchar_t *WideNamePtr = L"Name"; +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global variable 'WideNamePtr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const wchar_t *wszWideNamePtr = L"Name"; + +const wchar_t WideNameArray[] = L"Name"; +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global constant 'WideNameArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const wchar_t wszWideNameArray[] = L"Name"; + +const wchar_t *WideNamePtrArray[] = {L"AA", L"BB"}; +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global variable 'WideNamePtrArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const wchar_t *pwszWideNamePtrArray[] = {L"AA", L"BB"}; + +class MyClass4 { +private: + char *Name = "Text"; + // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for private member 'Name' [readability-identifier-naming] + // CHECK-FIXES: {{^}} char *szName = "Text"; + + const char *ConstName = "Text"; + // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for private member 'ConstName' [readability-identifier-naming] + // CHECK-FIXES: {{^}} const char *szConstName = "Text"; + +public: + const char* DuplicateString(const char* Input, size_t nRequiredSize); + // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: invalid case style for pointer parameter 'Input' [readability-identifier-naming] + // CHECK-FIXES: {{^}} const char* DuplicateString(const char* szInput, size_t nRequiredSize); + + size_t UpdateText(const char* Buffer, size_t nBufferSize); + // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: invalid case style for pointer parameter 'Buffer' [readability-identifier-naming] + // CHECK-FIXES: {{^}} size_t UpdateText(const char* szBuffer, size_t nBufferSize); +}; + + +//===----------------------------------------------------------------------===// +// Microsoft Windows data types +//===----------------------------------------------------------------------===// +DWORD MsDword = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsDword' [readability-identifier-naming] +// CHECK-FIXES: {{^}}DWORD dwMsDword = 0; + +BYTE MsByte = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsByte' [readability-identifier-naming] +// CHECK-FIXES: {{^}}BYTE byMsByte = 0; + +WORD MsWord = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsWord' [readability-identifier-naming] +// CHECK-FIXES: {{^}}WORD wMsWord = 0; + +BOOL MsBool = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsBool' [readability-identifier-naming] +// CHECK-FIXES: {{^}}BOOL bMsBool = 0; + +BOOLEAN MsBoolean = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsBoolean' [readability-identifier-naming] +// CHECK-FIXES: {{^}}BOOLEAN bMsBoolean = 0; + +CHAR MsValueChar = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueChar' [readability-identifier-naming] +// CHECK-FIXES: {{^}}CHAR cMsValueChar = 0; + +UCHAR MsValueUchar = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueUchar' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UCHAR ucMsValueUchar = 0; + +SHORT MsValueShort = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueShort' [readability-identifier-naming] +// CHECK-FIXES: {{^}}SHORT sMsValueShort = 0; + +USHORT MsValueUshort = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUshort' [readability-identifier-naming] +// CHECK-FIXES: {{^}}USHORT usMsValueUshort = 0; + +WORD MsValueWord = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueWord' [readability-identifier-naming] +// CHECK-FIXES: {{^}}WORD wMsValueWord = 0; + +DWORD MsValueDword = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueDword' [readability-identifier-naming] +// CHECK-FIXES: {{^}}DWORD dwMsValueDword = 0; + +DWORD32 MsValueDword32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueDword32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}DWORD32 dw32MsValueDword32 = 0; + +DWORD64 MsValueDword64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueDword64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}DWORD64 dw64MsValueDword64 = 0; + +LONG MsValueLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}LONG lMsValueLong = 0; + +ULONG MsValueUlong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueUlong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}ULONG ulMsValueUlong = 0; + +ULONG32 MsValueUlong32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueUlong32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}ULONG32 ul32MsValueUlong32 = 0; + +ULONG64 MsValueUlong64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueUlong64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}ULONG64 ul64MsValueUlong64 = 0; + +ULONGLONG MsValueUlongLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'MsValueUlongLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}ULONGLONG ullMsValueUlongLong = 0; + +HANDLE MsValueHandle = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueHandle' [readability-identifier-naming] +// CHECK-FIXES: {{^}}HANDLE hMsValueHandle = 0; + +INT MsValueInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'MsValueInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INT iMsValueInt = 0; + +INT8 MsValueInt8 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueInt8' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INT8 i8MsValueInt8 = 0; + +INT16 MsValueInt16 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueInt16' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INT16 i16MsValueInt16 = 0; + +INT32 MsValueInt32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueInt32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INT32 i32MsValueInt32 = 0; + +INT64 MsValueINt64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueINt64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INT64 i64MsValueINt64 = 0; + +UINT MsValueUint = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueUint' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UINT uiMsValueUint = 0; + +UINT8 MsValueUint8 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueUint8' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UINT8 u8MsValueUint8 = 0; + +UINT16 MsValueUint16 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUint16' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UINT16 u16MsValueUint16 = 0; + +UINT32 MsValueUint32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUint32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UINT32 u32MsValueUint32 = 0; + +UINT64 MsValueUint64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUint64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UINT64 u64MsValueUint64 = 0; + +PVOID MsValuePvoid = NULL; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValuePvoid' [readability-identifier-naming] +// CHECK-FIXES: {{^}}PVOID pMsValuePvoid = NULL; + + +//===----------------------------------------------------------------------===// +// Array +//===----------------------------------------------------------------------===// +unsigned GlobalUnsignedArray[] = {1, 2, 3}; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'GlobalUnsignedArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned aGlobalUnsignedArray[] = {1, 2, 3}; + +int GlobalIntArray[] = {1, 2, 3}; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'GlobalIntArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int aGlobalIntArray[] = {1, 2, 3}; + +int DataInt[1] = {0}; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'DataInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int aDataInt[1] = {0}; + +int DataArray[2] = {0}; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'DataArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int aDataArray[2] = {0}; + + +//===----------------------------------------------------------------------===// +// Pointer +//===----------------------------------------------------------------------===// +int *DataIntPtr[1] = {0}; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'DataIntPtr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int *paDataIntPtr[1] = {0}; + +void *BufferPtr1; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'BufferPtr1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}void *pBufferPtr1; + +void **BufferPtr2; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'BufferPtr2' [readability-identifier-naming] +// CHECK-FIXES: {{^}}void **ppBufferPtr2; + +void **pBufferPtr3; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'pBufferPtr3' [readability-identifier-naming] +// CHECK-FIXES: {{^}}void **ppBufferPtr3; + +int *pBufferPtr4; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'pBufferPtr4' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int *piBufferPtr4; + +typedef void (*FUNC_PTR_HELLO)(); +FUNC_PTR_HELLO Hello = NULL; +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global variable 'Hello' [readability-identifier-naming] +// CHECK-FIXES: {{^}}FUNC_PTR_HELLO fnHello = NULL; + +void *ValueVoidPtr = NULL; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'ValueVoidPtr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}void *pValueVoidPtr = NULL; + +ptrdiff_t PtrDiff = NULL; +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'PtrDiff' [readability-identifier-naming] +// CHECK-FIXES: {{^}}ptrdiff_t pPtrDiff = NULL; + +int8_t *ValueI8Ptr; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI8Ptr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int8_t *pi8ValueI8Ptr; + +uint8_t *ValueU8Ptr; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU8Ptr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}uint8_t *pu8ValueU8Ptr; + +void MyFunc2(void* Val){} +// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for pointer parameter 'Val' [readability-identifier-naming] +// CHECK-FIXES: {{^}}void MyFunc2(void* pVal){} + + +//===----------------------------------------------------------------------===// +// Reference +//===----------------------------------------------------------------------===// +int iValueIndex = 1; +int &RefValueIndex = iValueIndex; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'RefValueIndex' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int &iRefValueIndex = iValueIndex; + +const int &ConstRefValue = iValueIndex; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'ConstRefValue' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const int &iConstRefValue = iValueIndex; + +long long llValueLongLong = 2; +long long &RefValueLongLong = llValueLongLong; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'RefValueLongLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long long &llRefValueLongLong = llValueLongLong; + + +//===----------------------------------------------------------------------===// +// Various types +//===----------------------------------------------------------------------===// +int8_t ValueI8; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueI8' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int8_t i8ValueI8; + +int16_t ValueI16 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI16' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int16_t i16ValueI16 = 0; + +int32_t ValueI32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int32_t i32ValueI32 = 0; + +int64_t ValueI64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int64_t i64ValueI64 = 0; + +uint8_t ValueU8 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueU8' [readability-identifier-naming] +// CHECK-FIXES: {{^}}uint8_t u8ValueU8 = 0; + +uint16_t ValueU16 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU16' [readability-identifier-naming] +// CHECK-FIXES: {{^}}uint16_t u16ValueU16 = 0; + +uint32_t ValueU32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}uint32_t u32ValueU32 = 0; + +uint64_t ValueU64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}uint64_t u64ValueU64 = 0; + +float ValueFloat = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'ValueFloat' [readability-identifier-naming] +// CHECK-FIXES: {{^}}float fValueFloat = 0; + +double ValueDouble = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueDouble' [readability-identifier-naming] +// CHECK-FIXES: {{^}}double dValueDouble = 0; + +char ValueChar = 'c'; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueChar' [readability-identifier-naming] +// CHECK-FIXES: {{^}}char cValueChar = 'c'; + +bool ValueBool = true; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueBool' [readability-identifier-naming] +// CHECK-FIXES: {{^}}bool bValueBool = true; + +int ValueInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'ValueInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iValueInt = 0; + +size_t ValueSize = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueSize' [readability-identifier-naming] +// CHECK-FIXES: {{^}}size_t nValueSize = 0; + +wchar_t ValueWchar = 'w'; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueWchar' [readability-identifier-naming] +// CHECK-FIXES: {{^}}wchar_t wcValueWchar = 'w'; + +short ValueShort = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'ValueShort' [readability-identifier-naming] +// CHECK-FIXES: {{^}}short sValueShort = 0; + +unsigned ValueUnsigned = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueUnsigned' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned uValueUnsigned = 0; + +signed ValueSigned = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueSigned' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed sValueSigned = 0; + +long ValueLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long lValueLong = 0; + +long long ValueLongLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'ValueLongLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long long llValueLongLong = 0; + +long long int ValueLongLongInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'ValueLongLongInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long long int lliValueLongLongInt = 0; + +long double ValueLongDouble = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'ValueLongDouble' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long double ldValueLongDouble = 0; + +signed int ValueSignedInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'ValueSignedInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed int siValueSignedInt = 0; + +signed short ValueSignedShort = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global variable 'ValueSignedShort' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed short ssValueSignedShort = 0; + +signed short int ValueSignedShortInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global variable 'ValueSignedShortInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed short int ssiValueSignedShortInt = 0; + +signed long long ValueSignedLongLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global variable 'ValueSignedLongLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed long long sllValueSignedLongLong = 0; + +signed long int ValueSignedLongInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for global variable 'ValueSignedLongInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed long int sliValueSignedLongInt = 0; + +signed long ValueSignedLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'ValueSignedLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed long slValueSignedLong = 0; + +unsigned long long int ValueUnsignedLongLongInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: invalid case style for global variable 'ValueUnsignedLongLongInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned long long int ulliValueUnsignedLongLongInt = 0; + +unsigned long long ValueUnsignedLongLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for global variable 'ValueUnsignedLongLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned long long ullValueUnsignedLongLong = 0; + +unsigned long int ValueUnsignedLongInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for global variable 'ValueUnsignedLongInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned long int uliValueUnsignedLongInt = 0; + +unsigned long ValueUnsignedLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'ValueUnsignedLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned long ulValueUnsignedLong = 0; + +unsigned short int ValueUnsignedShortInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for global variable 'ValueUnsignedShortInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned short int usiValueUnsignedShortInt = 0; + +unsigned short ValueUnsignedShort = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global variable 'ValueUnsignedShort' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned short usValueUnsignedShort = 0; + +unsigned int ValueUnsignedInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global variable 'ValueUnsignedInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned int uiValueUnsignedInt = 0; + +long int ValueLongInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueLongInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long int liValueLongInt = 0; + + +//===----------------------------------------------------------------------===// +// Specifier, Qualifier, Other keywords +//===----------------------------------------------------------------------===// +volatile int VolatileInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global variable 'VolatileInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}volatile int iVolatileInt = 0; + +thread_local int ThreadLocalValueInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global variable 'ThreadLocalValueInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}thread_local int iThreadLocalValueInt = 0; + +extern int ExternValueInt; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'ExternValueInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}extern int iExternValueInt; + +struct DataBuffer { + mutable size_t Size; +}; +// CHECK-MESSAGES: :[[@LINE-2]]:20: warning: invalid case style for member 'Size' [readability-identifier-naming] +// CHECK-FIXES: {{^}} mutable size_t nSize; + +static constexpr int const &ConstExprInt = 42; +// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: invalid case style for constexpr variable 'ConstExprInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}static constexpr int const &iConstExprInt = 42; + + +//===----------------------------------------------------------------------===// +// Redefined types +//===----------------------------------------------------------------------===// +typedef int INDEX; +INDEX iIndex = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'iIndex' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INDEX Index = 0; + + +//===----------------------------------------------------------------------===// +// Unsupported +//===----------------------------------------------------------------------===// +class UnlistedClass { public: mutable int ValInt; }; +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: invalid case style for member 'ValInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}class UnlistedClass { public: mutable int iValInt; }; + +UnlistedClass cUnlisted2; +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'cUnlisted2' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UnlistedClass Unlisted2; + +UnlistedClass objUnlistedClass3; +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'objUnlistedClass3' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UnlistedClass ObjUnlistedClass3; + +//===----------------------------------------------------------------------===// +// Other Cases +//===----------------------------------------------------------------------===// +int lower_case = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'lower_case' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iLowerCase = 0; + +int lower_case1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'lower_case1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iLowerCase1 = 0; + +int lower_case_2 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'lower_case_2' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iLowerCase2 = 0; + +int UPPER_CASE = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'UPPER_CASE' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iUpperCase = 0; + +int UPPER_CASE_1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'UPPER_CASE_1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iUpperCase1 = 0; + +int camelBack = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camelBack' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelBack = 0; + +int camelBack_1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camelBack_1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelBack1 = 0; + +int camelBack2 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camelBack2' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelBack2 = 0; + +int CamelCase = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'CamelCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelCase = 0; + +int CamelCase_1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'CamelCase_1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelCase1 = 0; + +int CamelCase2 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'CamelCase2' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelCase2 = 0; + +int camel_Snake_Back = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camel_Snake_Back' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelSnakeBack = 0; + +int camel_Snake_Back_1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camel_Snake_Back_1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelSnakeBack1 = 0; + +int Camel_Snake_Case = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'Camel_Snake_Case' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelSnakeCase = 0; + +int Camel_Snake_Case_1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'Camel_Snake_Case_1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelSnakeCase1 = 0; + +//===----------------------------------------------------------------------===// +// Enum +//===----------------------------------------------------------------------===// +enum REVINFO_TYPE { RevValid }; +// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for constant 'RevValid' [readability-identifier-naming] +// CHECK-FIXES: {{^}}enum REVINFO_TYPE { rtRevValid }; + +enum DataType { OneByte }; +// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for constant 'OneByte' [readability-identifier-naming] +// CHECK-FIXES: {{^}}enum DataType { dtOneByte }; +// clang-format on diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation-default.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation-default.cpp new file mode 100644 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation-default.cpp @@ -0,0 +1,704 @@ +// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \ +// RUN: -config='{ CheckOptions: [ \ +// RUN: { key: readability-identifier-naming.ClassMemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantMemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstantPointerParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ConstexprVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.GlobalConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.GlobalConstantPointerCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.GlobalVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalConstantPointerCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalPointerCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.LocalVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.MemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.ParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.PointerParameterCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.PrivateMemberCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.StaticConstantCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.StaticVariableCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.StructCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.UnionCase , value: szHungarianNotation }, \ +// RUN: { key: readability-identifier-naming.VariableCase , value: szHungarianNotation } \ +// RUN: ]}' + +// clang-format off +typedef signed char int8_t; // NOLINT +typedef short int16_t; // NOLINT +typedef long int32_t; // NOLINT +typedef long long int64_t; // NOLINT +typedef unsigned char uint8_t; // NOLINT +typedef unsigned short uint16_t; // NOLINT +typedef unsigned long uint32_t; // NOLINT +typedef unsigned long long uint64_t; // NOLINT +#ifndef _WIN32 +typedef unsigned long long size_t; // NOLINT +#endif +typedef long intptr_t; // NOLINT +typedef unsigned long uintptr_t; // NOLINT +typedef long int ptrdiff_t; // NOLINT +typedef unsigned char BYTE; // NOLINT +typedef unsigned short WORD; // NOLINT +typedef unsigned long DWORD; // NOLINT +typedef int BOOL; // NOLINT +typedef int BOOLEAN; // NOLINT +typedef float FLOAT; // NOLINT +typedef int INT; // NOLINT +typedef unsigned int UINT; // NOLINT +typedef unsigned long ULONG; // NOLINT +typedef short SHORT; // NOLINT +typedef unsigned short USHORT; // NOLINT +typedef char CHAR; // NOLINT +typedef unsigned char UCHAR; // NOLINT +typedef signed char INT8; // NOLINT +typedef signed short INT16; // NOLINT +typedef signed int INT32; // NOLINT +typedef signed long long INT64; // NOLINT +typedef unsigned char UINT8; // NOLINT +typedef unsigned short UINT16; // NOLINT +typedef unsigned int UINT32; // NOLINT +typedef unsigned long long UINT64; // NOLINT +typedef long LONG; // NOLINT +typedef signed int LONG32; // NOLINT +typedef unsigned int ULONG32; // NOLINT +typedef uint64_t ULONG64; // NOLINT +typedef unsigned int DWORD32; // NOLINT +typedef uint64_t DWORD64; // NOLINT +typedef uint64_t ULONGLONG; // NOLINT +typedef void* PVOID; // NOLINT +typedef void* HANDLE; // NOLINT +typedef void* FILE; // NOLINT +#define NULL (0) // NOLINT +// clang-format on + +// clang-format off +//===----------------------------------------------------------------------===// +// Cases to CheckOptions +//===----------------------------------------------------------------------===// +class MyClass1 { +public: + static int ClassMemberCase; + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for class member 'ClassMemberCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} static int iClassMemberCase; + + char const ConstantMemberCase = 0; + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for constant member 'ConstantMemberCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} char const cConstantMemberCase = 0; + + void MyFunc1(const int ConstantParameterCase); + // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for constant parameter 'ConstantParameterCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} void MyFunc1(const int iConstantParameterCase); + + void MyFunc2(const int* ConstantPointerParameterCase); + // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: invalid case style for pointer parameter 'ConstantPointerParameterCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} void MyFunc2(const int* piConstantPointerParameterCase); + + static constexpr int ConstexprVariableCase = 123; + // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: invalid case style for constexpr variable 'ConstexprVariableCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} static constexpr int iConstexprVariableCase = 123; +}; + +const int GlobalConstantCase = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global constant 'GlobalConstantCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const int iGlobalConstantCase = 0; + +const int* GlobalConstantPointerCase = nullptr; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'GlobalConstantPointerCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const int* piGlobalConstantPointerCase = nullptr; + +int GlobalVariableCase = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'GlobalVariableCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iGlobalVariableCase = 0; + +void Func1(){ + int const LocalConstantCase = 3; + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for local constant 'LocalConstantCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} int const iLocalConstantCase = 3; + + int* const LocalConstantPointerCase = nullptr; + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for local constant pointer 'LocalConstantPointerCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} int* const piLocalConstantPointerCase = nullptr; + + int *LocalPointerCase = nullptr; + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local pointer 'LocalPointerCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} int *piLocalPointerCase = nullptr; + + int LocalVariableCase = 0; + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for local variable 'LocalVariableCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} int iLocalVariableCase = 0; +} + +class MyClass2 { + char MemberCase; + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for private member 'MemberCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} char cMemberCase; + + void Func1(int ParameterCase); + // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'ParameterCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} void Func1(int iParameterCase); + + void Func2(const int ParameterCase); + // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: invalid case style for constant parameter 'ParameterCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} void Func2(const int iParameterCase); + + void Func3(const int *PointerParameterCase); + // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: invalid case style for pointer parameter 'PointerParameterCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} void Func3(const int *piPointerParameterCase); +}; + +class MyClass3 { +private: + char PrivateMemberCase; + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for private member 'PrivateMemberCase' [readability-identifier-naming] + // CHECK-FIXES: {{^}} char cPrivateMemberCase; +}; + +static const int StaticConstantCase = 3; +// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global constant 'StaticConstantCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}static const int iStaticConstantCase = 3; + +static int StaticVariableCase = 3; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'StaticVariableCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}static int iStaticVariableCase = 3; + +struct MyStruct { int StructCase; }; +// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: invalid case style for member 'StructCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}struct MyStruct { int iStructCase; }; + +union MyUnion { int UnionCase1; long lUnionCase2; }; +// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for member 'UnionCase1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}union MyUnion { int iUnionCase1; long lUnionCase2; }; + +//===----------------------------------------------------------------------===// +// C string +//===----------------------------------------------------------------------===// +const char *NamePtr = "Name"; +// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'NamePtr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const char *szNamePtr = "Name"; + +const char NameArray[] = "Name"; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global constant 'NameArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const char szNameArray[] = "Name"; + +const char *NamePtrArray[] = {"AA", "BB"}; +// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'NamePtrArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const char *pszNamePtrArray[] = {"AA", "BB"}; + +const wchar_t *WideNamePtr = L"Name"; +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global variable 'WideNamePtr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const wchar_t *wszWideNamePtr = L"Name"; + +const wchar_t WideNameArray[] = L"Name"; +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global constant 'WideNameArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const wchar_t wszWideNameArray[] = L"Name"; + +const wchar_t *WideNamePtrArray[] = {L"AA", L"BB"}; +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global variable 'WideNamePtrArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const wchar_t *pwszWideNamePtrArray[] = {L"AA", L"BB"}; + +class MyClass4 { +private: + char *Name = "Text"; + // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for private member 'Name' [readability-identifier-naming] + // CHECK-FIXES: {{^}} char *szName = "Text"; + + const char *ConstName = "Text"; + // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for private member 'ConstName' [readability-identifier-naming] + // CHECK-FIXES: {{^}} const char *szConstName = "Text"; + +public: + const char* DuplicateString(const char* Input, size_t nRequiredSize); + // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: invalid case style for pointer parameter 'Input' [readability-identifier-naming] + // CHECK-FIXES: {{^}} const char* DuplicateString(const char* szInput, size_t nRequiredSize); + + size_t UpdateText(const char* Buffer, size_t nBufferSize); + // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: invalid case style for pointer parameter 'Buffer' [readability-identifier-naming] + // CHECK-FIXES: {{^}} size_t UpdateText(const char* szBuffer, size_t nBufferSize); +}; + + +//===----------------------------------------------------------------------===// +// Microsoft Windows data types +//===----------------------------------------------------------------------===// +DWORD MsDword = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsDword' [readability-identifier-naming] +// CHECK-FIXES: {{^}}DWORD dwMsDword = 0; + +BYTE MsByte = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsByte' [readability-identifier-naming] +// CHECK-FIXES: {{^}}BYTE byMsByte = 0; + +WORD MsWord = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsWord' [readability-identifier-naming] +// CHECK-FIXES: {{^}}WORD wMsWord = 0; + +BOOL MsBool = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsBool' [readability-identifier-naming] +// CHECK-FIXES: {{^}}BOOL bMsBool = 0; + +BOOLEAN MsBoolean = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsBoolean' [readability-identifier-naming] +// CHECK-FIXES: {{^}}BOOLEAN bMsBoolean = 0; + +CHAR MsValueChar = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueChar' [readability-identifier-naming] +// CHECK-FIXES: {{^}}CHAR cMsValueChar = 0; + +UCHAR MsValueUchar = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueUchar' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UCHAR ucMsValueUchar = 0; + +SHORT MsValueShort = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueShort' [readability-identifier-naming] +// CHECK-FIXES: {{^}}SHORT sMsValueShort = 0; + +USHORT MsValueUshort = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUshort' [readability-identifier-naming] +// CHECK-FIXES: {{^}}USHORT usMsValueUshort = 0; + +WORD MsValueWord = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueWord' [readability-identifier-naming] +// CHECK-FIXES: {{^}}WORD wMsValueWord = 0; + +DWORD MsValueDword = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueDword' [readability-identifier-naming] +// CHECK-FIXES: {{^}}DWORD dwMsValueDword = 0; + +DWORD32 MsValueDword32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueDword32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}DWORD32 dw32MsValueDword32 = 0; + +DWORD64 MsValueDword64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueDword64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}DWORD64 dw64MsValueDword64 = 0; + +LONG MsValueLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}LONG lMsValueLong = 0; + +ULONG MsValueUlong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueUlong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}ULONG ulMsValueUlong = 0; + +ULONG32 MsValueUlong32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueUlong32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}ULONG32 ul32MsValueUlong32 = 0; + +ULONG64 MsValueUlong64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsValueUlong64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}ULONG64 ul64MsValueUlong64 = 0; + +ULONGLONG MsValueUlongLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'MsValueUlongLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}ULONGLONG ullMsValueUlongLong = 0; + +HANDLE MsValueHandle = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueHandle' [readability-identifier-naming] +// CHECK-FIXES: {{^}}HANDLE hMsValueHandle = 0; + +INT MsValueInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'MsValueInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INT iMsValueInt = 0; + +INT8 MsValueInt8 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueInt8' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INT8 i8MsValueInt8 = 0; + +INT16 MsValueInt16 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueInt16' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INT16 i16MsValueInt16 = 0; + +INT32 MsValueInt32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueInt32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INT32 i32MsValueInt32 = 0; + +INT64 MsValueINt64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueINt64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INT64 i64MsValueINt64 = 0; + +UINT MsValueUint = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsValueUint' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UINT uiMsValueUint = 0; + +UINT8 MsValueUint8 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValueUint8' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UINT8 u8MsValueUint8 = 0; + +UINT16 MsValueUint16 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUint16' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UINT16 u16MsValueUint16 = 0; + +UINT32 MsValueUint32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUint32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UINT32 u32MsValueUint32 = 0; + +UINT64 MsValueUint64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'MsValueUint64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UINT64 u64MsValueUint64 = 0; + +PVOID MsValuePvoid = NULL; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsValuePvoid' [readability-identifier-naming] +// CHECK-FIXES: {{^}}PVOID pMsValuePvoid = NULL; + + +//===----------------------------------------------------------------------===// +// Array +//===----------------------------------------------------------------------===// +unsigned GlobalUnsignedArray[] = {1, 2, 3}; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'GlobalUnsignedArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned aGlobalUnsignedArray[] = {1, 2, 3}; + +int GlobalIntArray[] = {1, 2, 3}; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'GlobalIntArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int aGlobalIntArray[] = {1, 2, 3}; + +int DataInt[1] = {0}; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'DataInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int aDataInt[1] = {0}; + +int DataArray[2] = {0}; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'DataArray' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int aDataArray[2] = {0}; + + +//===----------------------------------------------------------------------===// +// Pointer +//===----------------------------------------------------------------------===// +int *DataIntPtr[1] = {0}; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'DataIntPtr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int *paDataIntPtr[1] = {0}; + +void *BufferPtr1; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'BufferPtr1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}void *pBufferPtr1; + +void **BufferPtr2; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'BufferPtr2' [readability-identifier-naming] +// CHECK-FIXES: {{^}}void **ppBufferPtr2; + +void **pBufferPtr3; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'pBufferPtr3' [readability-identifier-naming] +// CHECK-FIXES: {{^}}void **ppBufferPtr3; + +int *pBufferPtr4; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'pBufferPtr4' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int *piBufferPtr4; + +typedef void (*FUNC_PTR_HELLO)(); +FUNC_PTR_HELLO Hello = NULL; +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global variable 'Hello' [readability-identifier-naming] +// CHECK-FIXES: {{^}}FUNC_PTR_HELLO fnHello = NULL; + +void *ValueVoidPtr = NULL; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'ValueVoidPtr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}void *pValueVoidPtr = NULL; + +ptrdiff_t PtrDiff = NULL; +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'PtrDiff' [readability-identifier-naming] +// CHECK-FIXES: {{^}}ptrdiff_t pPtrDiff = NULL; + +int8_t *ValueI8Ptr; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI8Ptr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int8_t *pi8ValueI8Ptr; + +uint8_t *ValueU8Ptr; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU8Ptr' [readability-identifier-naming] +// CHECK-FIXES: {{^}}uint8_t *pu8ValueU8Ptr; + +void MyFunc2(void* Val){} +// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for pointer parameter 'Val' [readability-identifier-naming] +// CHECK-FIXES: {{^}}void MyFunc2(void* pVal){} + + +//===----------------------------------------------------------------------===// +// Reference +//===----------------------------------------------------------------------===// +int iValueIndex = 1; +int &RefValueIndex = iValueIndex; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'RefValueIndex' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int &iRefValueIndex = iValueIndex; + +const int &ConstRefValue = iValueIndex; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'ConstRefValue' [readability-identifier-naming] +// CHECK-FIXES: {{^}}const int &iConstRefValue = iValueIndex; + +long long llValueLongLong = 2; +long long &RefValueLongLong = llValueLongLong; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'RefValueLongLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long long &llRefValueLongLong = llValueLongLong; + + +//===----------------------------------------------------------------------===// +// Various types +//===----------------------------------------------------------------------===// +int8_t ValueI8; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueI8' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int8_t i8ValueI8; + +int16_t ValueI16 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI16' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int16_t i16ValueI16 = 0; + +int32_t ValueI32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int32_t i32ValueI32 = 0; + +int64_t ValueI64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int64_t i64ValueI64 = 0; + +uint8_t ValueU8 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueU8' [readability-identifier-naming] +// CHECK-FIXES: {{^}}uint8_t u8ValueU8 = 0; + +uint16_t ValueU16 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU16' [readability-identifier-naming] +// CHECK-FIXES: {{^}}uint16_t u16ValueU16 = 0; + +uint32_t ValueU32 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU32' [readability-identifier-naming] +// CHECK-FIXES: {{^}}uint32_t u32ValueU32 = 0; + +uint64_t ValueU64 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU64' [readability-identifier-naming] +// CHECK-FIXES: {{^}}uint64_t u64ValueU64 = 0; + +float ValueFloat = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'ValueFloat' [readability-identifier-naming] +// CHECK-FIXES: {{^}}float fValueFloat = 0; + +double ValueDouble = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueDouble' [readability-identifier-naming] +// CHECK-FIXES: {{^}}double dValueDouble = 0; + +char ValueChar = 'c'; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueChar' [readability-identifier-naming] +// CHECK-FIXES: {{^}}char cValueChar = 'c'; + +bool ValueBool = true; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueBool' [readability-identifier-naming] +// CHECK-FIXES: {{^}}bool bValueBool = true; + +int ValueInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'ValueInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iValueInt = 0; + +size_t ValueSize = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueSize' [readability-identifier-naming] +// CHECK-FIXES: {{^}}size_t nValueSize = 0; + +wchar_t ValueWchar = 'w'; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueWchar' [readability-identifier-naming] +// CHECK-FIXES: {{^}}wchar_t wcValueWchar = 'w'; + +short ValueShort = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'ValueShort' [readability-identifier-naming] +// CHECK-FIXES: {{^}}short sValueShort = 0; + +unsigned ValueUnsigned = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueUnsigned' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned uValueUnsigned = 0; + +signed ValueSigned = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueSigned' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed sValueSigned = 0; + +long ValueLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long lValueLong = 0; + +long long ValueLongLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'ValueLongLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long long llValueLongLong = 0; + +long long int ValueLongLongInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'ValueLongLongInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long long int lliValueLongLongInt = 0; + +long double ValueLongDouble = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'ValueLongDouble' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long double ldValueLongDouble = 0; + +signed int ValueSignedInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'ValueSignedInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed int siValueSignedInt = 0; + +signed short ValueSignedShort = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global variable 'ValueSignedShort' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed short ssValueSignedShort = 0; + +signed short int ValueSignedShortInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global variable 'ValueSignedShortInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed short int ssiValueSignedShortInt = 0; + +signed long long ValueSignedLongLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global variable 'ValueSignedLongLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed long long sllValueSignedLongLong = 0; + +signed long int ValueSignedLongInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for global variable 'ValueSignedLongInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed long int sliValueSignedLongInt = 0; + +signed long ValueSignedLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'ValueSignedLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}signed long slValueSignedLong = 0; + +unsigned long long int ValueUnsignedLongLongInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: invalid case style for global variable 'ValueUnsignedLongLongInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned long long int ulliValueUnsignedLongLongInt = 0; + +unsigned long long ValueUnsignedLongLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for global variable 'ValueUnsignedLongLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned long long ullValueUnsignedLongLong = 0; + +unsigned long int ValueUnsignedLongInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for global variable 'ValueUnsignedLongInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned long int uliValueUnsignedLongInt = 0; + +unsigned long ValueUnsignedLong = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'ValueUnsignedLong' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned long ulValueUnsignedLong = 0; + +unsigned short int ValueUnsignedShortInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for global variable 'ValueUnsignedShortInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned short int usiValueUnsignedShortInt = 0; + +unsigned short ValueUnsignedShort = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global variable 'ValueUnsignedShort' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned short usValueUnsignedShort = 0; + +unsigned int ValueUnsignedInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global variable 'ValueUnsignedInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}unsigned int uiValueUnsignedInt = 0; + +long int ValueLongInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueLongInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}long int liValueLongInt = 0; + + +//===----------------------------------------------------------------------===// +// Specifier, Qualifier, Other keywords +//===----------------------------------------------------------------------===// +volatile int VolatileInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global variable 'VolatileInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}volatile int iVolatileInt = 0; + +thread_local int ThreadLocalValueInt = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global variable 'ThreadLocalValueInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}thread_local int iThreadLocalValueInt = 0; + +extern int ExternValueInt; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'ExternValueInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}extern int iExternValueInt; + +struct DataBuffer { + mutable size_t Size; +}; +// CHECK-MESSAGES: :[[@LINE-2]]:20: warning: invalid case style for member 'Size' [readability-identifier-naming] +// CHECK-FIXES: {{^}} mutable size_t nSize; + +static constexpr int const &ConstExprInt = 42; +// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: invalid case style for constexpr variable 'ConstExprInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}static constexpr int const &iConstExprInt = 42; + + +//===----------------------------------------------------------------------===// +// Redefined types +//===----------------------------------------------------------------------===// +typedef int INDEX; +INDEX iIndex = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'iIndex' [readability-identifier-naming] +// CHECK-FIXES: {{^}}INDEX Index = 0; + + +//===----------------------------------------------------------------------===// +// Unsupported +//===----------------------------------------------------------------------===// +class UnlistedClass { public: mutable int ValInt; }; +// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: invalid case style for member 'ValInt' [readability-identifier-naming] +// CHECK-FIXES: {{^}}class UnlistedClass { public: mutable int iValInt; }; + +UnlistedClass cUnlisted2; +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'cUnlisted2' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UnlistedClass Unlisted2; + +UnlistedClass objUnlistedClass3; +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'objUnlistedClass3' [readability-identifier-naming] +// CHECK-FIXES: {{^}}UnlistedClass ObjUnlistedClass3; + +//===----------------------------------------------------------------------===// +// Other Cases +//===----------------------------------------------------------------------===// +int lower_case = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'lower_case' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iLowerCase = 0; + +int lower_case1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'lower_case1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iLowerCase1 = 0; + +int lower_case_2 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'lower_case_2' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iLowerCase2 = 0; + +int UPPER_CASE = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'UPPER_CASE' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iUpperCase = 0; + +int UPPER_CASE_1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'UPPER_CASE_1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iUpperCase1 = 0; + +int camelBack = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camelBack' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelBack = 0; + +int camelBack_1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camelBack_1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelBack1 = 0; + +int camelBack2 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camelBack2' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelBack2 = 0; + +int CamelCase = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'CamelCase' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelCase = 0; + +int CamelCase_1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'CamelCase_1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelCase1 = 0; + +int CamelCase2 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'CamelCase2' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelCase2 = 0; + +int camel_Snake_Back = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camel_Snake_Back' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelSnakeBack = 0; + +int camel_Snake_Back_1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'camel_Snake_Back_1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelSnakeBack1 = 0; + +int Camel_Snake_Case = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'Camel_Snake_Case' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelSnakeCase = 0; + +int Camel_Snake_Case_1 = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'Camel_Snake_Case_1' [readability-identifier-naming] +// CHECK-FIXES: {{^}}int iCamelSnakeCase1 = 0; + +//===----------------------------------------------------------------------===// +// Enum +//===----------------------------------------------------------------------===// +enum REVINFO_TYPE { RevValid }; +// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for constant 'RevValid' [readability-identifier-naming] +// CHECK-FIXES: {{^}}enum REVINFO_TYPE { rtRevValid }; + +enum DataType { OneByte }; +// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for constant 'OneByte' [readability-identifier-naming] +// CHECK-FIXES: {{^}}enum DataType { dtOneByte }; +// clang-format on diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp deleted file mode 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp +++ /dev/null @@ -1,263 +0,0 @@ -typedef signed char int8_t; // NOLINT -typedef short int16_t; // NOLINT -typedef long int32_t; // NOLINT -typedef long long int64_t; // NOLINT -typedef unsigned char uint8_t; // NOLINT -typedef unsigned short uint16_t; // NOLINT -typedef unsigned long uint32_t; // NOLINT -typedef unsigned long long uint64_t; // NOLINT -#ifndef _WIN32 -typedef unsigned long long size_t; // NOLINT -#endif -typedef long intptr_t; // NOLINT -typedef unsigned long uintptr_t; // NOLINT -typedef long int ptrdiff_t; // NOLINT -typedef unsigned char BYTE; // NOLINT -typedef unsigned short WORD; // NOLINT -typedef unsigned long DWORD; // NOLINT -typedef int BOOL; // NOLINT -typedef BYTE BOOLEAN; // NOLINT -#define NULL (0) // NOLINT - -// RUN: clang-tidy %s -checks=readability-identifier-naming \ -// RUN: -config="{CheckOptions: [\ -// RUN: {key: readability-identifier-naming.FunctionCase , value: CamelCase }, \ -// RUN: {key: readability-identifier-naming.ClassCase , value: szHungarianNotation }, \ -// RUN: {key: readability-identifier-naming.TypedefCase , value: szHungarianNotation }, \ -// RUN: {key: readability-identifier-naming.MemberCase , value: szHungarianNotation }, \ -// RUN: {key: readability-identifier-naming.ClassMemberCase , value: szHungarianNotation }, \ -// RUN: {key: readability-identifier-naming.ConstantMemberCase , value: szHungarianNotation }, \ -// RUN: {key: readability-identifier-naming.VariableCase , value: szHungarianNotation }, \ -// RUN: {key: readability-identifier-naming.ParameterCase , value: szHungarianNotation }, \ -// RUN: {key: readability-identifier-naming.GlobalPointerCase , value: szHungarianNotation }, \ -// RUN: {key: readability-identifier-naming.GlobalVariableCase , value: szHungarianNotation }, \ -// RUN: {key: readability-identifier-naming.GlobalFunctionCase , value: CamelCase } \ -// RUN: ]}" - -class UnlistedClass { public: mutable int ValInt; }; -// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: invalid case style for member 'ValInt' [readability-identifier-naming] -// CHECK-FIXES: {{^}}class UnlistedClass { public: mutable int iValInt; }; - -UnlistedClass cUnlisted2; -// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'cUnlisted2' [readability-identifier-naming] -// CHECK-FIXES: {{^}}UnlistedClass Unlisted2; - -UnlistedClass objUnlistedClass3; -// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'objUnlistedClass3' [readability-identifier-naming] -// CHECK-FIXES: {{^}}UnlistedClass UnlistedClass3; - -typedef int INDEX; -INDEX iIndex = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'iIndex' [readability-identifier-naming] -// CHECK-FIXES: {{^}}INDEX Index = 0; - -struct DataBuffer { - mutable size_t Size; -}; -// CHECK-MESSAGES: :[[@LINE-2]]:20: warning: invalid case style for member 'Size' [readability-identifier-naming] -// CHECK-FIXES: {{^}} mutable size_t nSize; - -int &RefValueIndex = iIndex; -// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'RefValueIndex' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int &iRefValueIndex = Index; - -typedef void (*FUNC_PTR_HELLO)(); -FUNC_PTR_HELLO Hello = NULL; -// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global pointer 'Hello' [readability-identifier-naming] -// CHECK-FIXES: {{^}}FUNC_PTR_HELLO fnHello = NULL; - -void *ValueVoidPtr = NULL; -// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global pointer 'ValueVoidPtr' [readability-identifier-naming] -// CHECK-FIXES: {{^}}void *pValueVoidPtr = NULL; - -ptrdiff_t PtrDiff = NULL; -// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'PtrDiff' [readability-identifier-naming] -// CHECK-FIXES: {{^}}ptrdiff_t pPtrDiff = NULL; - -const char *NamePtr = "Name"; -// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global pointer 'NamePtr' [readability-identifier-naming] -// CHECK-FIXES: {{^}}const char *szNamePtr = "Name"; - -const char NameArray[] = "Name"; -// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'NameArray' [readability-identifier-naming] -// CHECK-FIXES: {{^}}const char szNameArray[] = "Name"; - -const char *NamePtrArray[] = {"AA", "BB"}; -// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'NamePtrArray' [readability-identifier-naming] -// CHECK-FIXES: {{^}}const char *pszNamePtrArray[] = {"AA", "BB"}; - -int DataInt[1] = {0}; -// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'DataInt' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int aDataInt[1] = {0}; - -int *DataIntPtr[1] = {0}; -// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'DataIntPtr' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int *paDataIntPtr[1] = {0}; - -void *BufferPtr1; -// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global pointer 'BufferPtr1' [readability-identifier-naming] -// CHECK-FIXES: {{^}}void *pBufferPtr1; - -void **BufferPtr2; -// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global pointer 'BufferPtr2' [readability-identifier-naming] -// CHECK-FIXES: {{^}}void **ppBufferPtr2; - -void **pBufferPtr3; -// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global pointer 'pBufferPtr3' [readability-identifier-naming] -// CHECK-FIXES: {{^}}void **ppBufferPtr3; - -int *pBufferPtr4; -// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global pointer 'pBufferPtr4' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int *piBufferPtr4; - -int DataArray[2] = {0}; -// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'DataArray' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int aDataArray[2] = {0}; - -int8_t *ValueI8Ptr; -// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global pointer 'ValueI8Ptr' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int8_t *pi8ValueI8Ptr; - -uint8_t *ValueU8Ptr; -// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global pointer 'ValueU8Ptr' [readability-identifier-naming] -// CHECK-FIXES: {{^}}uint8_t *pu8ValueU8Ptr; - -int8_t ValueI8; -// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueI8' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int8_t i8ValueI8; - -int16_t ValueI16 = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI16' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int16_t i16ValueI16 = 0; - -int32_t ValueI32 = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI32' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int32_t i32ValueI32 = 0; - -int64_t ValueI64 = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueI64' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int64_t i64ValueI64 = 0; - -uint8_t ValueU8 = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueU8' [readability-identifier-naming] -// CHECK-FIXES: {{^}}uint8_t u8ValueU8 = 0; - -uint16_t ValueU16 = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU16' [readability-identifier-naming] -// CHECK-FIXES: {{^}}uint16_t u16ValueU16 = 0; - -uint32_t ValueU32 = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU32' [readability-identifier-naming] -// CHECK-FIXES: {{^}}uint32_t u32ValueU32 = 0; - -uint64_t ValueU64 = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueU64' [readability-identifier-naming] -// CHECK-FIXES: {{^}}uint64_t u64ValueU64 = 0; - -float ValueFloat = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'ValueFloat' [readability-identifier-naming] -// CHECK-FIXES: {{^}}float fValueFloat = 0; - -double ValueDouble = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueDouble' [readability-identifier-naming] -// CHECK-FIXES: {{^}}double dValueDouble = 0; - -char ValueChar = 'c'; -// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueChar' [readability-identifier-naming] -// CHECK-FIXES: {{^}}char cValueChar = 'c'; - -bool ValueBool = true; -// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueBool' [readability-identifier-naming] -// CHECK-FIXES: {{^}}bool bValueBool = true; - -int ValueInt = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'ValueInt' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int iValueInt = 0; - -int &RefValueInt = ValueInt; -// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'RefValueInt' [readability-identifier-naming] -// CHECK-FIXES: {{^}}int &iRefValueInt = iValueInt; - -size_t ValueSize = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueSize' [readability-identifier-naming] -// CHECK-FIXES: {{^}}size_t nValueSize = 0; - -wchar_t ValueWchar = 'w'; -// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'ValueWchar' [readability-identifier-naming] -// CHECK-FIXES: {{^}}wchar_t wcValueWchar = 'w'; - -short ValueShort = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'ValueShort' [readability-identifier-naming] -// CHECK-FIXES: {{^}}short sValueShort = 0; - -unsigned ValueUnsigned = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'ValueUnsigned' [readability-identifier-naming] -// CHECK-FIXES: {{^}}unsigned uValueUnsigned = 0; - -signed ValueSigned = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global variable 'ValueSigned' [readability-identifier-naming] -// CHECK-FIXES: {{^}}signed iValueSigned = 0; - -long ValueLong = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'ValueLong' [readability-identifier-naming] -// CHECK-FIXES: {{^}}long lValueLong = 0; - -long long ValueLongLong = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'ValueLongLong' [readability-identifier-naming] -// CHECK-FIXES: {{^}}long long llValueLongLong = 0; - -long long &RefValueLongLong = ValueLongLong; -// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'RefValueLongLong' [readability-identifier-naming] -// CHECK-FIXES: {{^}}long long &llRefValueLongLong = llValueLongLong; - -long double ValueLongDouble = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global variable 'ValueLongDouble' [readability-identifier-naming] -// CHECK-FIXES: {{^}}long double ldValueLongDouble = 0; - -volatile int VolatileInt = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global variable 'VolatileInt' [readability-identifier-naming] -// CHECK-FIXES: {{^}}volatile int iVolatileInt = 0; - -const int &ConstRefValue = ValueInt; -// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'ConstRefValue' [readability-identifier-naming] -// CHECK-FIXES: {{^}}const int &iConstRefValue = iValueInt; - -thread_local int ThreadLocalValueInt = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for global variable 'ThreadLocalValueInt' [readability-identifier-naming] -// CHECK-FIXES: {{^}}thread_local int iThreadLocalValueInt = 0; - -extern int ExternValueInt; -// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global variable 'ExternValueInt' [readability-identifier-naming] -// CHECK-FIXES: {{^}}extern int iExternValueInt; - -void MyFunc1(int Val){} -// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'Val' [readability-identifier-naming] -// CHECK-FIXES: {{^}}void MyFunc1(int iVal){} - -void MyFunc2(void* Val){} -// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for parameter 'Val' [readability-identifier-naming] -// CHECK-FIXES: {{^}}void MyFunc2(void* pVal){} - -static constexpr int const &ConstExprInt = 42; -// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: invalid case style for global variable 'ConstExprInt' [readability-identifier-naming] -// CHECK-FIXES: {{^}}static constexpr int const &iConstExprInt = 42; - -DWORD MsDword = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'MsDword' [readability-identifier-naming] -// CHECK-FIXES: {{^}}DWORD dwMsDword = 0; - -BYTE MsByte = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsByte' [readability-identifier-naming] -// CHECK-FIXES: {{^}}BYTE byMsByte = 0; - -WORD MsWord = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsWord' [readability-identifier-naming] -// CHECK-FIXES: {{^}}WORD wMsWord = 0; - -BOOL MsBool = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'MsBool' [readability-identifier-naming] -// CHECK-FIXES: {{^}}BOOL bMsBool = 0; - -BOOLEAN MsBoolean = 0; -// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for global variable 'MsBoolean' [readability-identifier-naming] -// CHECK-FIXES: {{^}}BOOLEAN bMsBoolean = 0;