make property addition work list all other "add" methods. Do
the allocation in the class, not in sema. llvm-svn: 48433
This commit is contained in:
parent
219b3e9c6c
commit
41eec3d097
|
@ -146,7 +146,7 @@ namespace {
|
||||||
void RewriteProtocolDecl(ObjCProtocolDecl *Dcl);
|
void RewriteProtocolDecl(ObjCProtocolDecl *Dcl);
|
||||||
void RewriteForwardProtocolDecl(ObjCForwardProtocolDecl *Dcl);
|
void RewriteForwardProtocolDecl(ObjCForwardProtocolDecl *Dcl);
|
||||||
void RewriteMethodDeclaration(ObjCMethodDecl *Method);
|
void RewriteMethodDeclaration(ObjCMethodDecl *Method);
|
||||||
void RewriteProperties(int nProperties, ObjCPropertyDecl **Properties);
|
void RewriteProperties(unsigned nProperties, ObjCPropertyDecl **Properties);
|
||||||
void RewriteFunctionDecl(FunctionDecl *FD);
|
void RewriteFunctionDecl(FunctionDecl *FD);
|
||||||
void RewriteObjCQualifiedInterfaceTypes(Decl *Dcl);
|
void RewriteObjCQualifiedInterfaceTypes(Decl *Dcl);
|
||||||
bool needToScanForQualifiers(QualType T);
|
bool needToScanForQualifiers(QualType T);
|
||||||
|
@ -549,9 +549,9 @@ void RewriteTest::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RewriteTest::RewriteProperties(int nProperties, ObjCPropertyDecl **Properties)
|
void RewriteTest::RewriteProperties(unsigned nProperties, ObjCPropertyDecl **Properties)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < nProperties; i++) {
|
for (unsigned i = 0; i < nProperties; i++) {
|
||||||
ObjCPropertyDecl *Property = Properties[i];
|
ObjCPropertyDecl *Property = Properties[i];
|
||||||
SourceLocation Loc = Property->getLocation();
|
SourceLocation Loc = Property->getLocation();
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ class ObjCInterfaceDecl : public TypeDecl {
|
||||||
|
|
||||||
/// class properties
|
/// class properties
|
||||||
ObjCPropertyDecl **PropertyDecl; // Null if no property
|
ObjCPropertyDecl **PropertyDecl; // Null if no property
|
||||||
int NumPropertyDecl; // -1 if no property
|
unsigned NumPropertyDecl; // 0 if none.
|
||||||
|
|
||||||
bool ForwardDecl:1; // declared with @class.
|
bool ForwardDecl:1; // declared with @class.
|
||||||
bool InternalInterface:1; // true - no @interface for @implementation
|
bool InternalInterface:1; // true - no @interface for @implementation
|
||||||
|
@ -285,6 +285,9 @@ public:
|
||||||
ObjCMethodDecl **clsMethods, unsigned numClsMembers,
|
ObjCMethodDecl **clsMethods, unsigned numClsMembers,
|
||||||
SourceLocation AtEnd);
|
SourceLocation AtEnd);
|
||||||
|
|
||||||
|
void addProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
|
||||||
|
|
||||||
|
|
||||||
bool isForwardDecl() const { return ForwardDecl; }
|
bool isForwardDecl() const { return ForwardDecl; }
|
||||||
void setForwardDecl(bool val) { ForwardDecl = val; }
|
void setForwardDecl(bool val) { ForwardDecl = val; }
|
||||||
|
|
||||||
|
@ -335,13 +338,9 @@ public:
|
||||||
SourceLocation getAtEndLoc() const { return AtEndLoc; }
|
SourceLocation getAtEndLoc() const { return AtEndLoc; }
|
||||||
|
|
||||||
int getNumPropertyDecl() const { return NumPropertyDecl; }
|
int getNumPropertyDecl() const { return NumPropertyDecl; }
|
||||||
void setNumPropertyDecl(int num) { NumPropertyDecl = num; }
|
|
||||||
|
|
||||||
ObjCPropertyDecl **const getPropertyDecl() const { return PropertyDecl; }
|
ObjCPropertyDecl * const * getPropertyDecl() const { return PropertyDecl; }
|
||||||
ObjCPropertyDecl **getPropertyDecl() { return PropertyDecl; }
|
ObjCPropertyDecl **getPropertyDecl() { return PropertyDecl; }
|
||||||
void setPropertyDecls(ObjCPropertyDecl **properties) {
|
|
||||||
PropertyDecl = properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ImplicitInterfaceDecl - check that this is an implicitely declared
|
/// ImplicitInterfaceDecl - check that this is an implicitely declared
|
||||||
/// ObjCInterfaceDecl node. This is for legacy objective-c @implementation
|
/// ObjCInterfaceDecl node. This is for legacy objective-c @implementation
|
||||||
|
|
|
@ -170,6 +170,18 @@ void ObjCInterfaceDecl::addMethods(ObjCMethodDecl **insMethods,
|
||||||
AtEndLoc = endLoc;
|
AtEndLoc = endLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// addMethods - Insert instance and methods declarations into
|
||||||
|
/// ObjCInterfaceDecl's InsMethods and ClsMethods fields.
|
||||||
|
///
|
||||||
|
void ObjCInterfaceDecl::addProperties(ObjCPropertyDecl **Properties,
|
||||||
|
unsigned NumProperties) {
|
||||||
|
if (NumProperties == 0) return;
|
||||||
|
|
||||||
|
NumPropertyDecl = NumProperties;
|
||||||
|
PropertyDecl = new ObjCPropertyDecl*[NumProperties];
|
||||||
|
memcpy(PropertyDecl, Properties, NumProperties*sizeof(ObjCPropertyDecl*));
|
||||||
|
}
|
||||||
|
|
||||||
/// addMethods - Insert instance and methods declarations into
|
/// addMethods - Insert instance and methods declarations into
|
||||||
/// ObjCProtocolDecl's ProtoInsMethods and ProtoClsMethods fields.
|
/// ObjCProtocolDecl's ProtoInsMethods and ProtoClsMethods fields.
|
||||||
///
|
///
|
||||||
|
|
|
@ -705,13 +705,8 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
|
||||||
|
|
||||||
// TODO: property declaration in category and protocols.
|
// TODO: property declaration in category and protocols.
|
||||||
if (pNum != 0)
|
if (pNum != 0)
|
||||||
if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) {
|
if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(ClassDecl))
|
||||||
// FIXME: Move the memory allocation into setPropertyDecls!
|
IDecl->addProperties((ObjCPropertyDecl**)allProperties, pNum);
|
||||||
ObjCPropertyDecl **properties = new ObjCPropertyDecl*[pNum];
|
|
||||||
memcpy(properties, allProperties, pNum*sizeof(ObjCPropertyDecl*));
|
|
||||||
IDecl->setPropertyDecls(properties);
|
|
||||||
IDecl->setNumPropertyDecl(pNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < allNum; i++ ) {
|
for (unsigned i = 0; i < allNum; i++ ) {
|
||||||
ObjCMethodDecl *Method =
|
ObjCMethodDecl *Method =
|
||||||
|
|
Loading…
Reference in New Issue