Move some of the logic about classifying Objective-C methods into
conventional categories into Basic and AST.  Update the self-init checker
to use this logic;  CFRefCountChecker is complicated enough that I didn't
want to touch it.

llvm-svn: 126817
diff --git a/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
index cb591ac..617121f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
@@ -52,7 +52,6 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/GRStateTrait.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
-#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
 #include "clang/AST/ParentMap.h"
 
 using namespace clang;
@@ -347,15 +346,11 @@
 }
 
 static bool isInitializationMethod(const ObjCMethodDecl *MD) {
-  // Init methods with prefix like '-(id)_init' are private and the requirements
-  // are less strict so we don't check those.
-  return MD->isInstanceMethod() &&
-      cocoa::deriveNamingConvention(MD->getSelector(),
-                                    /*ignorePrefix=*/false) == cocoa::InitRule;
+  return MD->getMethodFamily() == OMF_init;
 }
 
 static bool isInitMessage(const ObjCMessage &msg) {
-  return cocoa::deriveNamingConvention(msg.getSelector()) == cocoa::InitRule;
+  return msg.getMethodFamily() == OMF_init;
 }
 
 //===----------------------------------------------------------------------===//
diff --git a/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp b/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp
index 2e370d6..b227296 100644
--- a/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp
@@ -37,6 +37,35 @@
   return propE->getGetterSelector();
 }
 
+ObjCMethodFamily ObjCMessage::getMethodFamily() const {
+  assert(isValid() && "This ObjCMessage is uninitialized!");
+  // Case 1.  Explicit message send.
+  if (const ObjCMessageExpr *msgE = dyn_cast<ObjCMessageExpr>(MsgOrPropE))
+    return msgE->getMethodFamily();
+
+  const ObjCPropertyRefExpr *propE = cast<ObjCPropertyRefExpr>(MsgOrPropE);
+
+  // Case 2.  Reference to implicit property.
+  if (propE->isImplicitProperty()) {
+    if (isPropertySetter())
+      return propE->getImplicitPropertySetter()->getMethodFamily();
+    else
+      return propE->getImplicitPropertyGetter()->getMethodFamily();
+  }
+
+  // Case 3.  Reference to explicit property.
+  const ObjCPropertyDecl *prop = propE->getExplicitProperty();
+  if (isPropertySetter()) {
+    if (prop->getSetterMethodDecl())
+      return prop->getSetterMethodDecl()->getMethodFamily();
+    return prop->getSetterName().getMethodFamily();
+  } else {
+    if (prop->getGetterMethodDecl())
+      return prop->getGetterMethodDecl()->getMethodFamily();
+    return prop->getGetterName().getMethodFamily();
+  }
+}
+
 const ObjCMethodDecl *ObjCMessage::getMethodDecl() const {
   assert(isValid() && "This ObjCMessage is uninitialized!");
   if (const ObjCMessageExpr *msgE = dyn_cast<ObjCMessageExpr>(MsgOrPropE))