From 5ee6d5a29d28414a1fbca54472258f45845ba7a9 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 4 Mar 2014 22:57:32 +0000 Subject: [PATCH] Objective-C. Return 0 as class of methods in protocols. This simplifies my last patch a bit. No change in functionality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202906 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/DeclObjC.cpp | 4 ++-- lib/CodeGen/CGObjCMac.cpp | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index ce0845681a..94c4d5187a 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -950,8 +950,8 @@ ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() { return CD->getClassInterface(); if (ObjCImplDecl *IMD = dyn_cast(getDeclContext())) return IMD->getClassInterface(); - - assert(!isa(getDeclContext()) && "It's a protocol method"); + if (isa(getDeclContext())) + return 0; llvm_unreachable("unknown method context"); } diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index ebbd7007c1..d0419ec163 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1455,8 +1455,7 @@ private: // interface, we cannot perform this check. if (const ObjCMethodDecl *MD = dyn_cast_or_null(CGF.CurFuncDecl)) - if (MD->isInstanceMethod() && - !isa(MD->getDeclContext())) + if (MD->isInstanceMethod()) if (const ObjCInterfaceDecl *ID = MD->getClassInterface()) return IV->getContainingInterface()->isSuperClassOf(ID); return false; -- 2.40.0