[PATCH] D42947: Support special acronyms inside property names and allow plural forms
Yan Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 5 22:40:43 PST 2018
Wizard updated this revision to Diff 132938.
Wizard added a comment.
resolve conflict in doc
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D42947
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
@@ -14,6 +14,7 @@
@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;
@end
@interface Foo (Bar)
Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===================================================================
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -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,15 @@
return FixItHint();
}
+std::string AcronymsGroupRegex(llvm::ArrayRef<std::string> EscapedAcronyms,
+ bool SupportPlural) {
+ std::string Spliter = SupportPlural ? "s?|" : "|";
+ std::string RegexEnd = SupportPlural ? "s?)" : ")";
+ return "(" +
+ llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), Spliter) +
+ RegexEnd;
+}
+
std::string validPropertyNameRegex(llvm::ArrayRef<std::string> EscapedAcronyms,
bool UsedInMatcher) {
// Allow any of these names:
@@ -130,11 +139,9 @@
// 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(), "|") +
- ")?$";
+ return StartMatcher + "(" + AcronymsGroupRegex(EscapedAcronyms, false) +
+ "[A-Z]?)?[a-z]+[a-z0-9]*(" +
+ AcronymsGroupRegex(EscapedAcronyms, true) + "|([A-Z][a-z0-9]+))*$";
}
bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42947.132938.patch
Type: text/x-patch
Size: 2374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180206/fa84b18f/attachment.bin>
More information about the cfe-commits
mailing list