Update property prefix regex to allow numbers.

Subscribers: jfb, cfe-commits

Differential Revision: https://reviews.llvm.org/D56896

llvm-svn: 354485
This commit is contained in:
Yan Zhang 2019-02-20 17:32:41 +00:00
parent bbc9ed5eef
commit 19bceda879
2 changed files with 10 additions and 10 deletions

View File

@ -80,7 +80,8 @@ std::string validPropertyNameRegex(bool UsedInMatcher) {
}
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::StringRef PropertyName) {
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::registerMatchers(MatchFinder *Finder) {
// 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) {

View File

@ -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 ()