[PATCH] D56896: Update property prefix regex to allow numbers.
Yan Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 17 19:17:44 PST 2019
Wizard created this revision.
Herald added subscribers: cfe-commits, jfb.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D56896
Files:
clang-tidy/objc/PropertyDeclarationCheck.cpp
test/clang-tidy/objc-property-declaration.m
Index: test/clang-tidy/objc-property-declaration.m
===================================================================
--- test/clang-tidy/objc-property-declaration.m
+++ test/clang-tidy/objc-property-declaration.m
@@ -46,9 +46,10 @@
@property(strong, nonatomic) NSString *URLStr;
@property(assign, nonatomic) int abc_camelCase;
@property(strong, nonatomic) NSString *abc_URL;
+ at property(strong, nonatomic) NSString *opac2_sourceComponent;
@end
@interface Foo ()
@property(assign, nonatomic) int abc_inClassExtension;
// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abc_inClassExtension' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
@end
\ No newline at end of file
Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===================================================================
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -81,7 +81,8 @@
}
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);
}
@@ -92,8 +93,7 @@
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
@@ -110,13 +110,12 @@
// 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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56896.182439.patch
Type: text/x-patch
Size: 2381 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190118/c34b8c5f/attachment.bin>
More information about the cfe-commits
mailing list