forked from OSchip/llvm-project
Fix attributes on Obj-C interfaces & methods.
- Drop MethodAttrs parameter to ObjCMethodDecl - Call ProcessDeclAttributeList for interface & method decls. llvm-svn: 55068
This commit is contained in:
parent
7b9cd58596
commit
73a73f52fd
|
@ -126,8 +126,6 @@ private:
|
||||||
unsigned NumMethodParams;
|
unsigned NumMethodParams;
|
||||||
|
|
||||||
/// List of attributes for this method declaration.
|
/// List of attributes for this method declaration.
|
||||||
AttributeList *MethodAttrs;
|
|
||||||
|
|
||||||
SourceLocation EndLoc; // the location of the ';' or '{'.
|
SourceLocation EndLoc; // the location of the ';' or '{'.
|
||||||
|
|
||||||
// The following are only used for method definitions, null otherwise.
|
// The following are only used for method definitions, null otherwise.
|
||||||
|
@ -140,7 +138,7 @@ private:
|
||||||
ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
|
ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
|
||||||
Selector SelInfo, QualType T,
|
Selector SelInfo, QualType T,
|
||||||
Decl *contextDecl,
|
Decl *contextDecl,
|
||||||
AttributeList *M = 0, bool isInstance = true,
|
bool isInstance = true,
|
||||||
bool isVariadic = false,
|
bool isVariadic = false,
|
||||||
bool isSynthesized = false,
|
bool isSynthesized = false,
|
||||||
ImplementationControl impControl = None)
|
ImplementationControl impControl = None)
|
||||||
|
@ -151,7 +149,7 @@ private:
|
||||||
DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
|
DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
|
||||||
MethodContext(static_cast<NamedDecl*>(contextDecl)),
|
MethodContext(static_cast<NamedDecl*>(contextDecl)),
|
||||||
SelName(SelInfo), MethodDeclType(T),
|
SelName(SelInfo), MethodDeclType(T),
|
||||||
ParamInfo(0), NumMethodParams(0), MethodAttrs(M),
|
ParamInfo(0), NumMethodParams(0),
|
||||||
EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {}
|
EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {}
|
||||||
|
|
||||||
virtual ~ObjCMethodDecl();
|
virtual ~ObjCMethodDecl();
|
||||||
|
@ -165,7 +163,7 @@ public:
|
||||||
SourceLocation beginLoc,
|
SourceLocation beginLoc,
|
||||||
SourceLocation endLoc, Selector SelInfo,
|
SourceLocation endLoc, Selector SelInfo,
|
||||||
QualType T, Decl *contextDecl,
|
QualType T, Decl *contextDecl,
|
||||||
AttributeList *M = 0, bool isInstance = true,
|
bool isInstance = true,
|
||||||
bool isVariadic = false,
|
bool isVariadic = false,
|
||||||
bool isSynthesized = false,
|
bool isSynthesized = false,
|
||||||
ImplementationControl impControl = None);
|
ImplementationControl impControl = None);
|
||||||
|
@ -214,7 +212,6 @@ public:
|
||||||
ImplicitParamDecl * getCmdDecl() const { return CmdDecl; }
|
ImplicitParamDecl * getCmdDecl() const { return CmdDecl; }
|
||||||
void setCmdDecl(ImplicitParamDecl *decl) { CmdDecl = decl; }
|
void setCmdDecl(ImplicitParamDecl *decl) { CmdDecl = decl; }
|
||||||
|
|
||||||
AttributeList *getMethodAttrs() const {return MethodAttrs;}
|
|
||||||
bool isInstance() const { return IsInstance; }
|
bool isInstance() const { return IsInstance; }
|
||||||
bool isVariadic() const { return IsVariadic; }
|
bool isVariadic() const { return IsVariadic; }
|
||||||
|
|
||||||
|
|
|
@ -25,20 +25,19 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C,
|
||||||
SourceLocation endLoc,
|
SourceLocation endLoc,
|
||||||
Selector SelInfo, QualType T,
|
Selector SelInfo, QualType T,
|
||||||
Decl *contextDecl,
|
Decl *contextDecl,
|
||||||
AttributeList *M, bool isInstance,
|
bool isInstance,
|
||||||
bool isVariadic,
|
bool isVariadic,
|
||||||
bool isSynthesized,
|
bool isSynthesized,
|
||||||
ImplementationControl impControl) {
|
ImplementationControl impControl) {
|
||||||
void *Mem = C.getAllocator().Allocate<ObjCMethodDecl>();
|
void *Mem = C.getAllocator().Allocate<ObjCMethodDecl>();
|
||||||
return new (Mem) ObjCMethodDecl(beginLoc, endLoc,
|
return new (Mem) ObjCMethodDecl(beginLoc, endLoc,
|
||||||
SelInfo, T, contextDecl,
|
SelInfo, T, contextDecl,
|
||||||
M, isInstance,
|
isInstance,
|
||||||
isVariadic, isSynthesized, impControl);
|
isVariadic, isSynthesized, impControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCMethodDecl::~ObjCMethodDecl() {
|
ObjCMethodDecl::~ObjCMethodDecl() {
|
||||||
delete [] ParamInfo;
|
delete [] ParamInfo;
|
||||||
//delete [] MethodAttrs; // FIXME: Also destroy the stored Expr*.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjCMethodDecl::Destroy(ASTContext& C) {
|
void ObjCMethodDecl::Destroy(ASTContext& C) {
|
||||||
|
@ -401,7 +400,7 @@ void ObjCInterfaceDecl::addPropertyMethods(
|
||||||
ObjCMethodDecl::Create(Context, property->getLocation(),
|
ObjCMethodDecl::Create(Context, property->getLocation(),
|
||||||
property->getLocation(),
|
property->getLocation(),
|
||||||
property->getGetterName(), resultDeclType,
|
property->getGetterName(), resultDeclType,
|
||||||
this, 0,
|
this,
|
||||||
true, false, true, ObjCMethodDecl::Required);
|
true, false, true, ObjCMethodDecl::Required);
|
||||||
property->setGetterMethodDecl(ObjCMethod);
|
property->setGetterMethodDecl(ObjCMethod);
|
||||||
insMethods.push_back(ObjCMethod);
|
insMethods.push_back(ObjCMethod);
|
||||||
|
|
|
@ -98,8 +98,10 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
|
||||||
IDecl->setForwardDecl(false);
|
IDecl->setForwardDecl(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IDecl = ObjCInterfaceDecl::Create(Context, AtInterfaceLoc,
|
IDecl = ObjCInterfaceDecl::Create(Context, AtInterfaceLoc,
|
||||||
ClassName, ClassLoc);
|
ClassName, ClassLoc);
|
||||||
|
if (AttrList)
|
||||||
|
ProcessDeclAttributeList(IDecl, AttrList);
|
||||||
|
|
||||||
ObjCInterfaceDecls[ClassName] = IDecl;
|
ObjCInterfaceDecls[ClassName] = IDecl;
|
||||||
// Remember that this needs to be removed when the scope is popped.
|
// Remember that this needs to be removed when the scope is popped.
|
||||||
|
@ -491,6 +493,9 @@ Sema::DeclTy *Sema::ActOnStartClassImplementation(
|
||||||
if (!IDecl) {
|
if (!IDecl) {
|
||||||
// Legacy case of @implementation with no corresponding @interface.
|
// Legacy case of @implementation with no corresponding @interface.
|
||||||
// Build, chain & install the interface decl into the identifier.
|
// Build, chain & install the interface decl into the identifier.
|
||||||
|
|
||||||
|
// FIXME: Do we support attributes on the @implementation? If so
|
||||||
|
// we should copy them over.
|
||||||
IDecl = ObjCInterfaceDecl::Create(Context, AtClassImplLoc, ClassName,
|
IDecl = ObjCInterfaceDecl::Create(Context, AtClassImplLoc, ClassName,
|
||||||
ClassLoc, false, true);
|
ClassLoc, false, true);
|
||||||
ObjCInterfaceDecls[ClassName] = IDecl;
|
ObjCInterfaceDecls[ClassName] = IDecl;
|
||||||
|
@ -960,12 +965,14 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration(
|
||||||
|
|
||||||
ObjCMethodDecl* ObjCMethod =
|
ObjCMethodDecl* ObjCMethod =
|
||||||
ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, resultDeclType,
|
ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, resultDeclType,
|
||||||
ClassDecl, AttrList,
|
ClassDecl,
|
||||||
MethodType == tok::minus, isVariadic,
|
MethodType == tok::minus, isVariadic,
|
||||||
false,
|
false,
|
||||||
MethodDeclKind == tok::objc_optional ?
|
MethodDeclKind == tok::objc_optional ?
|
||||||
ObjCMethodDecl::Optional :
|
ObjCMethodDecl::Optional :
|
||||||
ObjCMethodDecl::Required);
|
ObjCMethodDecl::Required);
|
||||||
|
if (AttrList)
|
||||||
|
ProcessDeclAttributeList(ObjCMethod, AttrList);
|
||||||
|
|
||||||
llvm::SmallVector<ParmVarDecl*, 16> Params;
|
llvm::SmallVector<ParmVarDecl*, 16> Params;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue