[clang-tools-extra] r331545 - Add support for ObjC property name to be a single acronym.
Yan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Fri May 4 11:14:08 PDT 2018
Author: wizard
Date: Fri May 4 11:14:08 2018
New Revision: 331545
URL: http://llvm.org/viewvc/llvm-project?rev=331545&view=rev
Log:
Add support for ObjC property name to be a single acronym.
Summary:
This change will support cases like:
```
@property(assign, nonatomic) int ID;
```
Reviewers: benhamilton, hokein
Reviewed By: benhamilton
Subscribers: klimek, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D46374
Modified:
clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration-custom.m
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=331545&r1=331544&r2=331545&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Fri May 4 11:14:08 2018
@@ -217,6 +217,12 @@ void PropertyDeclarationCheck::check(con
assert(MatchedDecl->getName().size() > 0);
auto *DeclContext = MatchedDecl->getDeclContext();
auto *CategoryDecl = llvm::dyn_cast<ObjCCategoryDecl>(DeclContext);
+
+ auto AcronymsRegex =
+ llvm::Regex("^" + AcronymsGroupRegex(EscapedAcronyms) + "$");
+ if (AcronymsRegex.match(MatchedDecl->getName())) {
+ return;
+ }
if (CategoryDecl != nullptr &&
hasCategoryPropertyPrefix(MatchedDecl->getName())) {
if (!prefixedPropertyNameValid(MatchedDecl->getName(), EscapedAcronyms) ||
Modified: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration-custom.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration-custom.m?rev=331545&r1=331544&r2=331545&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration-custom.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration-custom.m Fri May 4 11:14:08 2018
@@ -14,4 +14,5 @@
// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'ABC_custom_prefix' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
@property(assign, nonatomic) int GIFIgnoreStandardAcronym;
// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'GIFIgnoreStandardAcronym' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
+ at property(strong, nonatomic) NSString *TGIF;
@end
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=331545&r1=331544&r2=331545&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 Fri May 4 11:14:08 2018
@@ -21,6 +21,7 @@
@property(assign, nonatomic) int enable2GBackgroundFetch;
@property(assign, nonatomic) int shouldUseCFPreferences;
@property(assign, nonatomic) int enableGLAcceleration;
+ at property(assign, nonatomic) int ID;
@end
@interface Foo (Bar)
More information about the cfe-commits
mailing list