Patch to remove ObjcProtoMethodDecl and use ObjcMethodDecl
instead for @protocol method decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42070 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 24b6309..53efacf 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -1264,8 +1264,7 @@
return;
}
-Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(DeclTy *IDecl,
- tok::ObjCKeywordKind& pi,
+Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi,
SourceLocation MethodLoc,
tok::TokenKind MethodType, TypeTy *ReturnType,
ObjcKeywordDecl *Keywords, unsigned NumKeywords,
@@ -1303,31 +1302,18 @@
Params.push_back(Param);
}
QualType resultDeclType = QualType::getFromOpaquePtr(ReturnType);
- ObjcMethodDecl* ObjcMethod;
-// FIXME: Added !IDecl for now to handle @implementation
- if (!IDecl || isa<ObjcInterfaceDecl>(static_cast<Decl *>(IDecl))) {
- ObjcMethod = new ObjcMethodDecl(MethodLoc, SelName, resultDeclType,
- 0, -1, AttrList, MethodType == tok::minus);
- ObjcMethod->setMethodParams(&Params[0], NumKeywords);
- }
- else if (isa<ObjcProtocolDecl>(static_cast<Decl *>(IDecl))) {
- ObjcMethod = new ObjcProtoMethodDecl(MethodLoc, SelName, resultDeclType,
- 0, -1, AttrList, MethodType == tok::minus);
- ObjcMethod->setMethodParams(&Params[0], NumKeywords);
- if (pi == tok::objc_optional)
- dyn_cast<ObjcProtoMethodDecl>(ObjcMethod)->
- setDeclImplementation(ObjcProtoMethodDecl::Optional);
- else
- dyn_cast<ObjcProtoMethodDecl>(ObjcMethod)->
- setDeclImplementation(ObjcProtoMethodDecl::Required);
- }
+ ObjcMethodDecl* ObjcMethod = new ObjcMethodDecl(MethodLoc,
+ SelName, resultDeclType,
+ 0, -1, AttrList, MethodType == tok::minus);
+ ObjcMethod->setMethodParams(&Params[0], NumKeywords);
+ if (pi == tok::objc_optional)
+ ObjcMethod->setDeclImplementation(ObjcMethodDecl::Optional);
else
- assert(0 && "Sema::ObjcBuildMethodDeclaration(): Unknown DeclTy");
+ ObjcMethod->setDeclImplementation(ObjcMethodDecl::Required);
return ObjcMethod;
}
-Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(DeclTy *IDecl,
- tok::ObjCKeywordKind& pi,
+Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi,
SourceLocation MethodLoc,
tok::TokenKind MethodType, TypeTy *ReturnType,
IdentifierInfo *SelectorName, AttributeList *AttrList) {
@@ -1335,25 +1321,13 @@
SelectorInfo &SelName = Context.getSelectorInfo(methodName,
methodName+strlen(methodName));
QualType resultDeclType = QualType::getFromOpaquePtr(ReturnType);
- ObjcMethodDecl* ObjcMethod;
-// FIXME: Remove after IDecl is always non-null
- if (!IDecl || isa<ObjcInterfaceDecl>(static_cast<Decl *>(IDecl))) {
- ObjcMethod = new ObjcMethodDecl(MethodLoc, SelName, resultDeclType, 0, -1,
- AttrList, MethodType == tok::minus);
- }
- else if (isa<ObjcProtocolDecl>(static_cast<Decl *>(IDecl))) {
- ObjcMethod = new ObjcProtoMethodDecl(MethodLoc, SelName, resultDeclType,
- 0, -1,
- AttrList, MethodType == tok::minus);
- if (pi == tok::objc_optional)
- dyn_cast<ObjcProtoMethodDecl>(ObjcMethod)->
- setDeclImplementation(ObjcProtoMethodDecl::Optional);
- else
- dyn_cast<ObjcProtoMethodDecl>(ObjcMethod)->
- setDeclImplementation(ObjcProtoMethodDecl::Required);
- }
+ ObjcMethodDecl* ObjcMethod = new ObjcMethodDecl(MethodLoc,
+ SelName, resultDeclType, 0, -1,
+ AttrList, MethodType == tok::minus);
+ if (pi == tok::objc_optional)
+ ObjcMethod->setDeclImplementation(ObjcMethodDecl::Optional);
else
- assert(0 && "Sema::ObjcBuildMethodDeclaration(): Unknown DeclTy");
+ ObjcMethod->setDeclImplementation(ObjcMethodDecl::Required);
return ObjcMethod;
}