summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclObjC.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-03-02 01:50:55 +0000
committerJohn McCall <rjmccall@apple.com>2011-03-02 01:50:55 +0000
commitb4526252db52ddbb931c0ea09a1f3dba3b5ce3f9 (patch)
tree8f9cd2793db72bf31d5bc6dbba25e5c16aeb54d2 /clang/lib/AST/DeclObjC.cpp
parent846ded2e53c77b43aae86a6ed60772ae46647e63 (diff)
downloadbcm5719-llvm-b4526252db52ddbb931c0ea09a1f3dba3b5ce3f9.tar.gz
bcm5719-llvm-b4526252db52ddbb931c0ea09a1f3dba3b5ce3f9.zip
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
Diffstat (limited to 'clang/lib/AST/DeclObjC.cpp')
-rw-r--r--clang/lib/AST/DeclObjC.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 45f5188d404..3a7c2a6e70d 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -398,6 +398,48 @@ ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() {
return this;
}
+ObjCMethodFamily ObjCMethodDecl::getMethodFamily() const {
+ ObjCMethodFamily family = static_cast<ObjCMethodFamily>(Family);
+ if (family != InvalidObjCMethodFamily)
+ return family;
+
+ family = getSelector().getMethodFamily();
+ switch (family) {
+ case OMF_None: break;
+
+ // init only has a conventional meaning for an instance method, and
+ // it has to return an object.
+ case OMF_init:
+ if (!isInstanceMethod() || !getResultType()->isObjCObjectPointerType())
+ family = OMF_None;
+ break;
+
+ // alloc/copy/new have a conventional meaning for both class and
+ // instance methods, but they require an object return.
+ case OMF_alloc:
+ case OMF_copy:
+ case OMF_mutableCopy:
+ case OMF_new:
+ if (!getResultType()->isObjCObjectPointerType())
+ family = OMF_None;
+ break;
+
+ // These selectors have a conventional meaning only for instance methods.
+ case OMF_dealloc:
+ case OMF_retain:
+ case OMF_release:
+ case OMF_autorelease:
+ case OMF_retainCount:
+ if (!isInstanceMethod())
+ family = OMF_None;
+ break;
+ }
+
+ // Cache the result.
+ Family = static_cast<unsigned>(family);
+ return family;
+}
+
void ObjCMethodDecl::createImplicitParams(ASTContext &Context,
const ObjCInterfaceDecl *OID) {
QualType selfTy;
OpenPOWER on IntegriCloud