Author: wizard Date: Wed Feb 20 09:32:41 2019 New Revision: 354485 URL: http://llvm.org/viewvc/llvm-project?rev=354485&view=rev Log: Update property prefix regex to allow numbers.
Subscribers: jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D56896 Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=354485&r1=354484&r2=354485&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Wed Feb 20 09:32:41 2019 @@ -80,7 +80,8 @@ std::string validPropertyNameRegex(bool } bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) { - auto RegexExp = llvm::Regex("^[a-zA-Z]+_[a-zA-Z0-9][a-zA-Z0-9_]+$"); + auto RegexExp = + llvm::Regex("^[a-zA-Z][a-zA-Z0-9]*_[a-zA-Z0-9][a-zA-Z0-9_]+$"); return RegexExp.match(PropertyName); } @@ -91,8 +92,7 @@ bool prefixedPropertyNameValid(llvm::Str if (Prefix.lower() != Prefix) { return false; } - auto RegexExp = - llvm::Regex(llvm::StringRef(validPropertyNameRegex(false))); + auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false))); return RegexExp.match(PropertyName.substr(Start + 1)); } } // namespace @@ -101,13 +101,12 @@ void PropertyDeclarationCheck::registerM // this check should only be applied to ObjC sources. if (!getLangOpts().ObjC) return; - Finder->addMatcher( - objcPropertyDecl( - // the property name should be in Lower Camel Case like - // 'lowerCamelCase' - unless(matchesName(validPropertyNameRegex(true)))) - .bind("property"), - this); + Finder->addMatcher(objcPropertyDecl( + // the property name should be in Lower Camel Case like + // 'lowerCamelCase' + unless(matchesName(validPropertyNameRegex(true)))) + .bind("property"), + this); } void PropertyDeclarationCheck::check(const MatchFinder::MatchResult &Result) { Modified: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m?rev=354485&r1=354484&r2=354485&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m (original) +++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Wed Feb 20 09:32:41 2019 @@ -46,6 +46,7 @@ typedef void *CGColorRef; @property(strong, nonatomic) NSString *URLStr; @property(assign, nonatomic) int abc_camelCase; @property(strong, nonatomic) NSString *abc_URL; +@property(strong, nonatomic) NSString *opac2_sourceComponent; @end @interface Foo () _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits