summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
diff options
context:
space:
mode:
authorYan Zhang <ynzhang@google.com>2018-05-04 18:14:08 +0000
committerYan Zhang <ynzhang@google.com>2018-05-04 18:14:08 +0000
commit4f9ead2356e47f6816e2f88eb91ed1d47acbd245 (patch)
treedf9f0d22af185b5b9afb36f7367caf6a74d48cc8 /clang-tools-extra
parentbf4c41c7e18ddac1328f7873e2ff8d209a96bd50 (diff)
downloadbcm5719-llvm-4f9ead2356e47f6816e2f88eb91ed1d47acbd245.tar.gz
bcm5719-llvm-4f9ead2356e47f6816e2f88eb91ed1d47acbd245.zip
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 llvm-svn: 331545
Diffstat (limited to 'clang-tools-extra')
-rw-r--r--clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp6
-rw-r--r--clang-tools-extra/test/clang-tidy/objc-property-declaration-custom.m1
-rw-r--r--clang-tools-extra/test/clang-tidy/objc-property-declaration.m1
3 files changed, 8 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
index fd15df9dea1..cafeac42ba1 100644
--- a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -217,6 +217,12 @@ void PropertyDeclarationCheck::check(const MatchFinder::MatchResult &Result) {
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) ||
diff --git a/clang-tools-extra/test/clang-tidy/objc-property-declaration-custom.m b/clang-tools-extra/test/clang-tidy/objc-property-declaration-custom.m
index d4a2f5033ad..68374ec0e8f 100644
--- a/clang-tools-extra/test/clang-tidy/objc-property-declaration-custom.m
+++ b/clang-tools-extra/test/clang-tidy/objc-property-declaration-custom.m
@@ -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]
+@property(strong, nonatomic) NSString *TGIF;
@end
diff --git a/clang-tools-extra/test/clang-tidy/objc-property-declaration.m b/clang-tools-extra/test/clang-tidy/objc-property-declaration.m
index 3f001a84316..ede14426df9 100644
--- a/clang-tools-extra/test/clang-tidy/objc-property-declaration.m
+++ b/clang-tools-extra/test/clang-tidy/objc-property-declaration.m
@@ -21,6 +21,7 @@
@property(assign, nonatomic) int enable2GBackgroundFetch;
@property(assign, nonatomic) int shouldUseCFPreferences;
@property(assign, nonatomic) int enableGLAcceleration;
+@property(assign, nonatomic) int ID;
@end
@interface Foo (Bar)
OpenPOWER on IntegriCloud