[analyzer] Place checking for Core Foundation "Create" rule into a proper API.  No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135349 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/CocoaConventions.cpp b/lib/Analysis/CocoaConventions.cpp
index 9068ca3..428032b 100644
--- a/lib/Analysis/CocoaConventions.cpp
+++ b/lib/Analysis/CocoaConventions.cpp
@@ -86,12 +86,12 @@
   return Name.startswith(Prefix);
 }
 
-bool cocoa::isCFObjectRef(QualType T) {
-  return isRefType(T, "CF") || // Core Foundation.
-         isRefType(T, "CG") || // Core Graphics.
-         isRefType(T, "DADisk") || // Disk Arbitration API.
-         isRefType(T, "DADissenter") ||
-         isRefType(T, "DASessionRef");
+bool coreFoundation::isCFObjectRef(QualType T) {
+  return cocoa::isRefType(T, "CF") || // Core Foundation.
+         cocoa::isRefType(T, "CG") || // Core Graphics.
+         cocoa::isRefType(T, "DADisk") || // Disk Arbitration API.
+         cocoa::isRefType(T, "DADissenter") ||
+         cocoa::isRefType(T, "DASessionRef");
 }
 
 
@@ -126,3 +126,8 @@
   
   return false;
 }
+
+bool coreFoundation::followsCreateRule(llvm::StringRef functionName) {
+  return functionName.find("Create") != StringRef::npos ||
+         functionName.find("Copy") != StringRef::npos;
+}
diff --git a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
index 235b400..9fc8163 100644
--- a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
+++ b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
@@ -606,7 +606,7 @@
       continue;
     
     // Ignore CF references, which can be toll-free bridged.
-    if (cocoa::isCFObjectRef(ArgTy))
+    if (coreFoundation::isCFObjectRef(ArgTy))
       continue;
 
     // Generate only one error node to use for all bug reports.
diff --git a/lib/StaticAnalyzer/Core/CFRefCount.cpp b/lib/StaticAnalyzer/Core/CFRefCount.cpp
index 8306b7f..bf53029 100644
--- a/lib/StaticAnalyzer/Core/CFRefCount.cpp
+++ b/lib/StaticAnalyzer/Core/CFRefCount.cpp
@@ -1135,8 +1135,7 @@
 RetainSummary*
 RetainSummaryManager::getCFCreateGetRuleSummary(const FunctionDecl* FD,
                                                 StringRef FName) {
-  if (FName.find("Create") != StringRef::npos ||
-      FName.find("Copy") != StringRef::npos)
+  if (coreFoundation::followsCreateRule(FName))
     return getCFSummaryCreateRule(FD);
 
   return getCFSummaryGetRule(FD);
@@ -1206,7 +1205,8 @@
   assert(ScratchArgs.isEmpty());
   // 'init' methods conceptually return a newly allocated object and claim
   // the receiver.
-  if (cocoa::isCocoaObjectRef(RetTy) || cocoa::isCFObjectRef(RetTy))
+  if (cocoa::isCocoaObjectRef(RetTy) ||
+      coreFoundation::isCFObjectRef(RetTy))
     return getPersistentSummary(ObjCInitRetE, DecRefMsg);
 
   return getDefaultSummary();
@@ -1356,7 +1356,7 @@
   }
 
   // Look for methods that return an owned core foundation object.
-  if (cocoa::isCFObjectRef(RetTy)) {
+  if (coreFoundation::isCFObjectRef(RetTy)) {
     RetEffect E = cocoa::followsFundamentalRule(S, MD)
       ? RetEffect::MakeOwned(RetEffect::CF, true)
       : RetEffect::MakeNotOwned(RetEffect::CF);