[clang-tools-extra] r345858 - Fix the issue that not recognizing single acronym with prefix as ObjC property name.
Yan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 1 10:36:18 PDT 2018
Author: wizard
Date: Thu Nov 1 10:36:18 2018
New Revision: 345858
URL: http://llvm.org/viewvc/llvm-project?rev=345858&view=rev
Log:
Fix the issue that not recognizing single acronym with prefix as ObjC property name.
Summary: This will make clang-tidy accept property names like xyz_URL (URL is a common acronym).
Reviewers: benhamilton, hokein
Reviewed By: benhamilton
Subscribers: jfb, cfe-commits
Differential Revision: https://reviews.llvm.org/D53955
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=345858&r1=345857&r2=345858&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Thu Nov 1 10:36:18 2018
@@ -201,8 +201,7 @@ PropertyDeclarationCheck::PropertyDeclar
void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
// this check should only be applied to ObjC sources.
- if (!getLangOpts().ObjC)
- return;
+ if (!getLangOpts().ObjC) return;
if (IncludeDefaultAcronyms) {
EscapedAcronyms.reserve(llvm::array_lengthof(DefaultSpecialAcronyms) +
@@ -235,9 +234,9 @@ void PropertyDeclarationCheck::check(con
auto *DeclContext = MatchedDecl->getDeclContext();
auto *CategoryDecl = llvm::dyn_cast<ObjCCategoryDecl>(DeclContext);
- auto AcronymsRegex =
- llvm::Regex("^" + AcronymsGroupRegex(EscapedAcronyms) + "$");
- if (AcronymsRegex.match(MatchedDecl->getName())) {
+ auto SingleAcronymRegex =
+ llvm::Regex("^([a-zA-Z]+_)?" + AcronymsGroupRegex(EscapedAcronyms) + "$");
+ if (SingleAcronymRegex.match(MatchedDecl->getName())) {
return;
}
if (CategoryDecl != nullptr &&
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=345858&r1=345857&r2=345858&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 Thu Nov 1 10:36:18 2018
@@ -38,6 +38,7 @@
// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'wrongFormat_' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
@property(strong, nonatomic) NSString *URLStr;
@property(assign, nonatomic) int abc_camelCase;
+ at property(strong, nonatomic) NSString *abc_URL;
@end
@interface Foo ()
More information about the cfe-commits
mailing list