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

llvm-svn: 324407
diff --git a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
index 32f0dca..ee08e2f 100644
--- a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ b/clang-tools-extra/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,12 @@
   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 @@
   // 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) {