[clang-tools-extra] r324407 - Support special acronyms inside property names and allow plural forms
Yan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 6 13:40:39 PST 2018
Author: wizard
Date: Tue Feb 6 13:40:38 2018
New Revision: 324407
URL: http://llvm.org/viewvc/llvm-project?rev=324407&view=rev
Log:
Support special acronyms inside property names and allow plural forms
Reviewers: benhamilton, hokein
Reviewed By: benhamilton, hokein
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D42947
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=324407&r1=324406&r2=324407&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Tue Feb 6 13:40:38 2018
@@ -12,8 +12,8 @@
#include "../utils/OptionsUtils.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "llvm/ADT/STLExtras.h"
#include "clang/Basic/CharInfo.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Regex.h"
@@ -118,6 +118,12 @@ FixItHint generateFixItHint(const ObjCPr
return FixItHint();
}
+std::string AcronymsGroupRegex(llvm::ArrayRef<std::string> EscapedAcronyms) {
+ return "(" +
+ llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "s?|") +
+ "s?)";
+}
+
std::string validPropertyNameRegex(llvm::ArrayRef<std::string> EscapedAcronyms,
bool UsedInMatcher) {
// Allow any of these names:
@@ -129,12 +135,9 @@ std::string validPropertyNameRegex(llvm:
// URLString
// bundleID
std::string StartMatcher = UsedInMatcher ? "::" : "^";
-
- return StartMatcher + "((" +
- llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") +
- ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*" + "(" +
- llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") +
- ")?$";
+ std::string AcronymsMatcher = AcronymsGroupRegex(EscapedAcronyms);
+ return StartMatcher + "(" + AcronymsMatcher + "[A-Z]?)?[a-z]+[a-z0-9]*(" +
+ AcronymsMatcher + "|([A-Z][a-z0-9]+))*$";
}
bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
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=324407&r1=324406&r2=324407&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 Tue Feb 6 13:40:38 2018
@@ -14,6 +14,9 @@
@property(strong, nonatomic) UIViewController *notificationsVC;
@property(strong, nonatomic) NSString *URL_string;
// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
+ at property(strong, nonatomic) NSString *supportURLsCamelCase;
+ at property(strong, nonatomic) NSString *supportURLCamelCase;
+ at property(strong, nonatomic) NSString *VCsPluralToAdd;
@end
@interface Foo (Bar)
More information about the cfe-commits
mailing list