]> granicus.if.org Git - clang/commitdiff
Kill cocoa::deriveNamingConvention and cocoa::followsFundamentalRule. They are now...
authorJordy Rose <jediknil@belkadan.com>
Sat, 17 Mar 2012 20:51:32 +0000 (20:51 +0000)
committerJordy Rose <jediknil@belkadan.com>
Sat, 17 Mar 2012 20:51:32 +0000 (20:51 +0000)
The one difference between ObjCMethodDecl::getMethodFamily and Selector::getMethodFamily is that the former will do some additional sanity checking, and since CoreFoundation types don't look like Objective-C objects, an otherwise interesting method will get a method family of OMF_None. Future clients that use method families should consider how they want to handle CF types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153000 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/DomainSpecific/CocoaConventions.h
lib/ARCMigrate/Transforms.cpp
lib/Analysis/CocoaConventions.cpp

index fa8afccfcd895576bc789a923eef98e103582626..e6a2f13a0b80d632e97d7a85990b9f11b3819e9c 100644 (file)
 #ifndef LLVM_CLANG_ANALYSIS_DS_COCOA
 #define LLVM_CLANG_ANALYSIS_DS_COCOA
 
-#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringRef.h"
 
 namespace clang {
 class FunctionDecl;
-class ObjCMethodDecl;
 class QualType;
   
 namespace ento {
 namespace cocoa {
-  enum NamingConvention { NoConvention, CreateRule, InitRule };
-
-  NamingConvention deriveNamingConvention(Selector S, const ObjCMethodDecl *MD);
-
-  static inline bool followsFundamentalRule(Selector S, 
-                                            const ObjCMethodDecl *MD) {
-    return deriveNamingConvention(S, MD) == CreateRule;
-  }
   
   bool isRefType(QualType RetTy, StringRef Prefix,
                  StringRef Name = StringRef());
index 70ef6216d66bc6a42e86f9345c58d68a9586ffad..d342d1aa04776f5f0b493d7831f97dac43153cb2 100644 (file)
@@ -12,7 +12,6 @@
 #include "clang/Sema/SemaDiagnostic.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/StmtVisitor.h"
-#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/StringSwitch.h"
index ee8a6efb35876aa4d0910cf4358a263f0d9f2c59..7e9e38fd1eaecbd7c29f812e6dc5a07b25769add 100644 (file)
 using namespace clang;
 using namespace ento;
 
-// The "fundamental rule" for naming conventions of methods:
-//  (url broken into two lines)
-//  http://developer.apple.com/documentation/Cocoa/Conceptual/
-//     MemoryMgmt/Tasks/MemoryManagementRules.html
-//
-// "You take ownership of an object if you create it using a method whose name
-//  begins with "alloc" or "new" or contains "copy" (for example, alloc,
-//  newObject, or mutableCopy), or if you send it a retain message. You are
-//  responsible for relinquishing ownership of objects you own using release
-//  or autorelease. Any other time you receive an object, you must
-//  not release it."
-//
-
-cocoa::NamingConvention cocoa::deriveNamingConvention(Selector S, 
-                                                    const ObjCMethodDecl *MD) {
-  switch (MD && MD->hasAttr<ObjCMethodFamilyAttr>()? MD->getMethodFamily() 
-                                                   : S.getMethodFamily()) {
-  case OMF_None:
-  case OMF_autorelease:
-  case OMF_dealloc:
-  case OMF_finalize:
-  case OMF_release:
-  case OMF_retain:
-  case OMF_retainCount:
-  case OMF_self:
-  case OMF_performSelector:
-    return NoConvention;
-
-  case OMF_init:
-    return InitRule;
-
-  case OMF_alloc:
-  case OMF_copy:
-  case OMF_mutableCopy:
-  case OMF_new:
-    return CreateRule;
-  }
-  llvm_unreachable("unexpected naming convention");
-}
-
 bool cocoa::isRefType(QualType RetTy, StringRef Prefix,
                       StringRef Name) {
   // Recursively walk the typedef stack, allowing typedefs of reference types.