Index: clang-tidy/objc/PropertyDeclarationCheck.cpp =================================================================== --- clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -12,8 +12,8 @@ #include "../utils/OptionsUtils.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" -#include "llvm/ADT/STLExtras.h" #include "clang/Basic/CharInfo.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Regex.h" @@ -118,6 +118,15 @@ return FixItHint(); } +std::string AcronymsGroupRegex(llvm::ArrayRef EscapedAcronyms, + bool SupportPlural) { + std::string Spliter = SupportPlural ? "s?|" : "|"; + std::string RegexEnd = SupportPlural ? "s?)" : ")"; + return "(" + + llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), Spliter) + + RegexEnd; +} + std::string validPropertyNameRegex(llvm::ArrayRef EscapedAcronyms, bool UsedInMatcher) { // Allow any of these names: @@ -130,11 +139,9 @@ // bundleID std::string StartMatcher = UsedInMatcher ? "::" : "^"; - return StartMatcher + "((" + - llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") + - ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*" + "(" + - llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") + - ")?$"; + return StartMatcher + "(" + AcronymsGroupRegex(EscapedAcronyms, false) + + "[A-Z]?)?[a-z]+[a-z0-9]*(" + + AcronymsGroupRegex(EscapedAcronyms, true) + "|([A-Z][a-z0-9]+))*$"; } bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) { Index: test/clang-tidy/objc-property-declaration.m =================================================================== --- test/clang-tidy/objc-property-declaration.m +++ test/clang-tidy/objc-property-declaration.m @@ -14,6 +14,7 @@ @property(strong, nonatomic) UIViewController *notificationsVC; @property(strong, nonatomic) NSString *URL_string; // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration] +@property(strong, nonatomic) NSString *supportURLsCamelCase; @end @interface Foo (Bar)