This revision was automatically updated to reflect the committed changes.
Closed by commit rL322602: add ID as a special acronym to objc property 
declaration check for property… (authored by Wizard, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D42143

Files:
  clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m


Index: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
@@ -7,6 +7,7 @@
 // CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
 @property(assign, nonatomic) int camelCase;
 @property(strong, nonatomic) NSString *URLString;
+@property(strong, nonatomic) NSString *bundleID;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should 
use lowerCamelCase style, according to the Apple Coding Guidelines 
[objc-property-declaration]
 @end
Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -41,7 +41,8 @@
     "RGB;"
     "CMYK;"
     "MIDI;"
-    "FTP";
+    "FTP;"
+    "ID";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
@@ -58,24 +59,26 @@
   return FixItHint();
 }
 
-std::string validPropertyNameRegex(const std::vector<std::string> &Prefixes) {
-  std::vector<std::string> EscapedPrefixes;
-  EscapedPrefixes.reserve(Prefixes.size());
+std::string validPropertyNameRegex(const std::vector<std::string> &Acronyms) {
+  std::vector<std::string> EscapedAcronyms;
+  EscapedAcronyms.reserve(Acronyms.size());
   // In case someone defines a custom prefix which includes a regex
   // special character, escape all the prefixes.
-  std::transform(Prefixes.begin(), Prefixes.end(),
-                 std::back_inserter(EscapedPrefixes), [](const std::string& s) 
{
+  std::transform(Acronyms.begin(), Acronyms.end(),
+                 std::back_inserter(EscapedAcronyms), [](const std::string& s) 
{
                    return llvm::Regex::escape(s); });
   // Allow any of these names:
   // foo
   // fooBar
   // url
   // urlString
   // URL
   // URLString
+  // bundleID
   return std::string("::((") +
-      llvm::join(EscapedPrefixes.begin(), EscapedPrefixes.end(), "|") +
-      ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*$";
+      llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") +
+      ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*" + "(" +
+      llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") + ")?$";
 }
 }  // namespace
 


Index: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
@@ -7,6 +7,7 @@
 // CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
 @property(assign, nonatomic) int camelCase;
 @property(strong, nonatomic) NSString *URLString;
+@property(strong, nonatomic) NSString *bundleID;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 @end
Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -41,7 +41,8 @@
     "RGB;"
     "CMYK;"
     "MIDI;"
-    "FTP";
+    "FTP;"
+    "ID";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
@@ -58,24 +59,26 @@
   return FixItHint();
 }
 
-std::string validPropertyNameRegex(const std::vector<std::string> &Prefixes) {
-  std::vector<std::string> EscapedPrefixes;
-  EscapedPrefixes.reserve(Prefixes.size());
+std::string validPropertyNameRegex(const std::vector<std::string> &Acronyms) {
+  std::vector<std::string> EscapedAcronyms;
+  EscapedAcronyms.reserve(Acronyms.size());
   // In case someone defines a custom prefix which includes a regex
   // special character, escape all the prefixes.
-  std::transform(Prefixes.begin(), Prefixes.end(),
-                 std::back_inserter(EscapedPrefixes), [](const std::string& s) {
+  std::transform(Acronyms.begin(), Acronyms.end(),
+                 std::back_inserter(EscapedAcronyms), [](const std::string& s) {
                    return llvm::Regex::escape(s); });
   // Allow any of these names:
   // foo
   // fooBar
   // url
   // urlString
   // URL
   // URLString
+  // bundleID
   return std::string("::((") +
-      llvm::join(EscapedPrefixes.begin(), EscapedPrefixes.end(), "|") +
-      ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*$";
+      llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") +
+      ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*" + "(" +
+      llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") + ")?$";
 }
 }  // namespace
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to