зеркало из https://github.com/microsoft/clang-1.git
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
This commit is contained in:
Родитель
2a9d82a740
Коммит
146fbb0c8b
|
@ -298,12 +298,12 @@ void ObjcProtocolDecl::ObjcAddProtoMethods(ObjcMethodDecl **insMethods,
|
|||
unsigned numClsMembers) {
|
||||
NumProtoInsMethods = numInsMembers;
|
||||
if (numInsMembers) {
|
||||
ProtoInsMethods = new ObjcProtoMethodDecl*[numInsMembers];
|
||||
ProtoInsMethods = new ObjcMethodDecl*[numInsMembers];
|
||||
memcpy(ProtoInsMethods, insMethods, numInsMembers*sizeof(ObjcMethodDecl*));
|
||||
}
|
||||
NumProtoClsMethods = numClsMembers;
|
||||
if (numClsMembers) {
|
||||
ProtoClsMethods = new ObjcProtoMethodDecl*[numClsMembers];
|
||||
ProtoClsMethods = new ObjcMethodDecl*[numClsMembers];
|
||||
memcpy(ProtoClsMethods, clsMethods, numClsMembers*sizeof(ObjcMethodDecl*));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -375,7 +375,7 @@ Parser::DeclTy *Parser::ParseObjCMethodPrototype(DeclTy *IDecl,
|
|||
tok::TokenKind methodType = Tok.getKind();
|
||||
SourceLocation methodLoc = ConsumeToken();
|
||||
|
||||
DeclTy *MDecl = ParseObjCMethodDecl(IDecl, pi, methodType, methodLoc);
|
||||
DeclTy *MDecl = ParseObjCMethodDecl(pi, methodType, methodLoc);
|
||||
// Since this rule is used for both method declarations and definitions,
|
||||
// the caller is (optionally) responsible for consuming the ';'.
|
||||
return MDecl;
|
||||
|
@ -484,8 +484,7 @@ Parser::TypeTy *Parser::ParseObjCTypeName() {
|
|||
/// objc-keyword-attributes: [OBJC2]
|
||||
/// __attribute__((unused))
|
||||
///
|
||||
Parser::DeclTy *Parser::ParseObjCMethodDecl(DeclTy *IDecl,
|
||||
tok::ObjCKeywordKind& pi,
|
||||
Parser::DeclTy *Parser::ParseObjCMethodDecl(tok::ObjCKeywordKind& pi,
|
||||
tok::TokenKind mType, SourceLocation mLoc) {
|
||||
|
||||
TypeTy *ReturnType = 0;
|
||||
|
@ -552,7 +551,7 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(DeclTy *IDecl,
|
|||
// If attributes exist after the method, parse them.
|
||||
if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute)
|
||||
methodAttrs = ParseAttributes();
|
||||
return Actions.ObjcBuildMethodDeclaration(IDecl, pi, mLoc, mType,
|
||||
return Actions.ObjcBuildMethodDeclaration(pi, mLoc, mType,
|
||||
ReturnType,
|
||||
&KeyInfo[0], KeyInfo.size(),
|
||||
methodAttrs);
|
||||
|
@ -563,7 +562,7 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(DeclTy *IDecl,
|
|||
if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute)
|
||||
methodAttrs = ParseAttributes();
|
||||
|
||||
return Actions.ObjcBuildMethodDeclaration(IDecl, pi,
|
||||
return Actions.ObjcBuildMethodDeclaration(pi,
|
||||
mLoc, mType, ReturnType,
|
||||
selIdent, methodAttrs);
|
||||
}
|
||||
|
|
|
@ -368,14 +368,12 @@ public:
|
|||
|
||||
virtual void ObjcAddMethodsToClass(DeclTy *ClassDecl,
|
||||
DeclTy **allMethods, unsigned allNum);
|
||||
virtual DeclTy *ObjcBuildMethodDeclaration(DeclTy *InterfaceDecl,
|
||||
tok::ObjCKeywordKind& pi,
|
||||
virtual DeclTy *ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi,
|
||||
SourceLocation MethodLoc,
|
||||
tok::TokenKind MethodType, TypeTy *ReturnType,
|
||||
ObjcKeywordDecl *Keywords, unsigned NumKeywords,
|
||||
AttributeList *AttrList);
|
||||
virtual DeclTy *ObjcBuildMethodDeclaration(DeclTy *InterfaceDecl,
|
||||
tok::ObjCKeywordKind& pi,
|
||||
virtual DeclTy *ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi,
|
||||
SourceLocation MethodLoc,
|
||||
tok::TokenKind MethodType, TypeTy *ReturnType,
|
||||
IdentifierInfo *SelectorName, AttributeList *AttrList);
|
||||
|
|
|
@ -1264,8 +1264,7 @@ void Sema::ObjcAddMethodsToClass(DeclTy *ClassDecl,
|
|||
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 @@ Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(DeclTy *IDecl,
|
|||
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 @@ Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(DeclTy *IDecl,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ class FunctionDecl;
|
|||
class AttributeList;
|
||||
class ObjcIvarDecl;
|
||||
class ObjcMethodDecl;
|
||||
class ObjcProtoMethodDecl;
|
||||
class SelectorInfo;
|
||||
|
||||
|
||||
|
@ -615,6 +614,9 @@ public:
|
|||
/// ObjcMethodDecl - An instance of this class is created to represent an instance
|
||||
/// or class method declaration.
|
||||
class ObjcMethodDecl : public Decl {
|
||||
public:
|
||||
enum ImplementationControl { None, Required, Optional };
|
||||
private:
|
||||
// A unigue name for this method.
|
||||
SelectorInfo &Selector;
|
||||
|
||||
|
@ -630,6 +632,9 @@ class ObjcMethodDecl : public Decl {
|
|||
|
||||
/// instance (true) or class (false) method.
|
||||
bool IsInstance : 1;
|
||||
/// @required/@optional
|
||||
ImplementationControl DeclImplementation : 2;
|
||||
|
||||
public:
|
||||
ObjcMethodDecl(SourceLocation L, SelectorInfo &SelId, QualType T,
|
||||
ParmVarDecl **paramInfo = 0, int numParams=-1,
|
||||
|
@ -658,6 +663,11 @@ public:
|
|||
|
||||
AttributeList *getMethodAttrs() const {return MethodAttrs;}
|
||||
bool isInstance() const { return IsInstance; }
|
||||
// Related to protocols declared in @protocol
|
||||
void setDeclImplementation(ImplementationControl ic)
|
||||
{ DeclImplementation = ic; }
|
||||
ImplementationControl getImplementationControl() const
|
||||
{ return DeclImplementation; }
|
||||
|
||||
// Implement isa/cast/dyncast/etc.
|
||||
static bool classof(const Decl *D) {
|
||||
|
@ -667,39 +677,13 @@ public:
|
|||
static bool classof(const ObjcMethodDecl *D) { return true; }
|
||||
};
|
||||
|
||||
/// ObjcProtoMethodDecl - Each instance represents a method declared
|
||||
/// in a protocol.
|
||||
///
|
||||
class ObjcProtoMethodDecl : public ObjcMethodDecl {
|
||||
public:
|
||||
ObjcProtoMethodDecl(SourceLocation L, SelectorInfo &Id, QualType T,
|
||||
ParmVarDecl **paramInfo = 0, int numParams=-1,
|
||||
AttributeList *M = 0, bool isInstance = true,
|
||||
Decl *PrevDecl = 0) :
|
||||
ObjcMethodDecl(ObjcProtoMethod, L, Id, T, paramInfo, numParams,
|
||||
M, isInstance, PrevDecl) {}
|
||||
|
||||
enum ImplementationControl { None, Required, Optional };
|
||||
|
||||
void setDeclImplementation(ImplementationControl ic)
|
||||
{ DeclImplementation = ic; }
|
||||
ImplementationControl getImplementationControl() const
|
||||
{ return DeclImplementation; }
|
||||
// Implement isa/cast/dyncast/etc.
|
||||
static bool classof(const Decl *D) { return D->getKind() == ObjcProtoMethod; }
|
||||
static bool classof(const ObjcMethodDecl *D) { return true; }
|
||||
|
||||
private:
|
||||
ImplementationControl DeclImplementation : 2;
|
||||
};
|
||||
|
||||
class ObjcProtocolDecl : public TypeDecl {
|
||||
/// protocol instance methods
|
||||
ObjcProtoMethodDecl **ProtoInsMethods; // Null if not defined
|
||||
ObjcMethodDecl **ProtoInsMethods; // Null if not defined
|
||||
int NumProtoInsMethods; // -1 if not defined
|
||||
|
||||
/// protocol class methods
|
||||
ObjcProtoMethodDecl **ProtoClsMethods; // Null if not defined
|
||||
ObjcMethodDecl **ProtoClsMethods; // Null if not defined
|
||||
int NumProtoClsMethods; // -1 if not defined
|
||||
|
||||
bool isForwardProtoDecl; // declared with @protocol.
|
||||
|
|
|
@ -453,15 +453,13 @@ public:
|
|||
IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) {
|
||||
return 0;
|
||||
}
|
||||
virtual DeclTy *ObjcBuildMethodDeclaration(DeclTy *IDecl,
|
||||
tok::ObjCKeywordKind& pi,
|
||||
virtual DeclTy *ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi,
|
||||
SourceLocation MethodLoc, tok::TokenKind MethodType, TypeTy *ReturnType,
|
||||
ObjcKeywordDecl *Keywords, unsigned NumKeywords,
|
||||
AttributeList *AttrList) {
|
||||
return 0;
|
||||
}
|
||||
virtual DeclTy *ObjcBuildMethodDeclaration(DeclTy *IDecl,
|
||||
tok::ObjCKeywordKind& pi,
|
||||
virtual DeclTy *ObjcBuildMethodDeclaration(tok::ObjCKeywordKind& pi,
|
||||
SourceLocation MethodLoc, tok::TokenKind MethodType, TypeTy *ReturnType,
|
||||
IdentifierInfo *SelectorName, AttributeList *AttrList) {
|
||||
return 0;
|
||||
|
|
|
@ -291,7 +291,7 @@ private:
|
|||
void ParseObjCMethodRequirement();
|
||||
DeclTy *ParseObjCMethodPrototype(DeclTy *classOrCat,
|
||||
tok::ObjCKeywordKind& pi);
|
||||
DeclTy *ParseObjCMethodDecl(DeclTy *CDecl, tok::ObjCKeywordKind& pi,
|
||||
DeclTy *ParseObjCMethodDecl(tok::ObjCKeywordKind& pi,
|
||||
tok::TokenKind mType,
|
||||
SourceLocation mLoc);
|
||||
void ParseObjCPropertyAttribute(DeclTy *interfaceDecl);
|
||||
|
|
Загрузка…
Ссылка в новой задаче