[cfe-commits] r153000 - in /cfe/trunk: include/clang/Analysis/DomainSpecific/CocoaConventions.h lib/ARCMigrate/Transforms.cpp lib/Analysis/CocoaConventions.cpp

Jordy Rose jediknil at belkadan.com
Sat Mar 17 13:51:32 PDT 2012


Author: jrose
Date: Sat Mar 17 15:51:32 2012
New Revision: 153000

URL: http://llvm.org/viewvc/llvm-project?rev=153000&view=rev
Log:
Kill cocoa::deriveNamingConvention and cocoa::followsFundamentalRule. They are now just simple wrappers around method families, and method decls can cache method family lookups. Also, no one is using them right now.

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.

Modified:
    cfe/trunk/include/clang/Analysis/DomainSpecific/CocoaConventions.h
    cfe/trunk/lib/ARCMigrate/Transforms.cpp
    cfe/trunk/lib/Analysis/CocoaConventions.cpp

Modified: cfe/trunk/include/clang/Analysis/DomainSpecific/CocoaConventions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/DomainSpecific/CocoaConventions.h?rev=153000&r1=152999&r2=153000&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/DomainSpecific/CocoaConventions.h (original)
+++ cfe/trunk/include/clang/Analysis/DomainSpecific/CocoaConventions.h Sat Mar 17 15:51:32 2012
@@ -14,25 +14,15 @@
 #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());

Modified: cfe/trunk/lib/ARCMigrate/Transforms.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.cpp?rev=153000&r1=152999&r2=153000&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/Transforms.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/Transforms.cpp Sat Mar 17 15:51:32 2012
@@ -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"

Modified: cfe/trunk/lib/Analysis/CocoaConventions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CocoaConventions.cpp?rev=153000&r1=152999&r2=153000&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CocoaConventions.cpp (original)
+++ cfe/trunk/lib/Analysis/CocoaConventions.cpp Sat Mar 17 15:51:32 2012
@@ -20,46 +20,6 @@
 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.





More information about the cfe-commits mailing list