forked from OSchip/llvm-project
clean up property memory allocation to move it into the ast classes
like the rest of the classes. llvm-svn: 48434
This commit is contained in:
parent
41eec3d097
commit
ed0e16404c
|
@ -311,12 +311,12 @@ void DeclPrinter::PrintObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
|
|||
Out << " )";
|
||||
}
|
||||
|
||||
ObjCIvarDecl **IDecl = PDecl->getPropertyDecls();
|
||||
ObjCIvarDecl *const *IDecl = PDecl->getPropertyDecls();
|
||||
|
||||
Out << ' ' << IDecl[0]->getType().getAsString()
|
||||
<< ' ' << IDecl[0]->getName();
|
||||
|
||||
for (int j = 1; j < PDecl->getNumPropertyDecls(); j++)
|
||||
for (unsigned j = 1; j < PDecl->getNumPropertyDecls(); j++)
|
||||
Out << ", " << IDecl[j]->getName();
|
||||
|
||||
Out << ";\n";
|
||||
|
|
|
@ -232,7 +232,7 @@ class ObjCInterfaceDecl : public TypeDecl {
|
|||
NumIvars(0),
|
||||
InstanceMethods(0), NumInstanceMethods(-1),
|
||||
ClassMethods(0), NumClassMethods(0),
|
||||
CategoryList(0), PropertyDecl(0), NumPropertyDecl(-1),
|
||||
CategoryList(0), PropertyDecl(0), NumPropertyDecl(0),
|
||||
ForwardDecl(FD), InternalInterface(isInternal) {
|
||||
AllocIntfRefProtocols(numRefProtos);
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ public:
|
|||
// We also need to record the @end location.
|
||||
SourceLocation getAtEndLoc() const { return AtEndLoc; }
|
||||
|
||||
int getNumPropertyDecl() const { return NumPropertyDecl; }
|
||||
unsigned getNumPropertyDecl() const { return NumPropertyDecl; }
|
||||
|
||||
ObjCPropertyDecl * const * getPropertyDecl() const { return PropertyDecl; }
|
||||
ObjCPropertyDecl **getPropertyDecl() { return PropertyDecl; }
|
||||
|
@ -908,31 +908,28 @@ private:
|
|||
// List of property name declarations
|
||||
// FIXME: Property is not an ivar.
|
||||
ObjCIvarDecl **PropertyDecls;
|
||||
int NumPropertyDecls;
|
||||
|
||||
// NOTE: VC++ treats enums as signed, avoid using PropertyAttributeKind enum
|
||||
unsigned NumPropertyDecls;
|
||||
unsigned PropertyAttributes : 8;
|
||||
|
||||
IdentifierInfo *GetterName; // getter name of NULL if no getter
|
||||
IdentifierInfo *SetterName; // setter name of NULL if no setter
|
||||
|
||||
ObjCPropertyDecl(SourceLocation L)
|
||||
: Decl(PropertyDecl, L), PropertyDecls(0), NumPropertyDecls(-1),
|
||||
: Decl(PropertyDecl, L), PropertyDecls(0), NumPropertyDecls(0),
|
||||
PropertyAttributes(OBJC_PR_noattr), GetterName(0), SetterName(0) {}
|
||||
public:
|
||||
static ObjCPropertyDecl *Create(ASTContext &C, SourceLocation L);
|
||||
|
||||
ObjCIvarDecl **const getPropertyDecls() const { return PropertyDecls; }
|
||||
void setPropertyDecls(ObjCIvarDecl **property) { PropertyDecls = property; }
|
||||
ObjCIvarDecl *const* getPropertyDecls() const { return PropertyDecls; }
|
||||
unsigned getNumPropertyDecls() const { return NumPropertyDecls; }
|
||||
|
||||
void setPropertyDeclLists(ObjCIvarDecl **Properties, unsigned NumProp);
|
||||
|
||||
const int getNumPropertyDecls() const { return NumPropertyDecls; }
|
||||
void setNumPropertyDecls(int num) { NumPropertyDecls = num; }
|
||||
|
||||
const PropertyAttributeKind getPropertyAttributes() const
|
||||
{ return PropertyAttributeKind(PropertyAttributes); }
|
||||
const PropertyAttributeKind getPropertyAttributes() const {
|
||||
return PropertyAttributeKind(PropertyAttributes);
|
||||
}
|
||||
void setPropertyAttributes(PropertyAttributeKind PRVal) {
|
||||
PropertyAttributes =
|
||||
(PropertyAttributeKind) (PropertyAttributes | PRVal);
|
||||
PropertyAttributes = (PropertyAttributeKind) (PropertyAttributes | PRVal);
|
||||
}
|
||||
|
||||
const IdentifierInfo *getGetterName() const { return GetterName; }
|
||||
|
|
|
@ -419,3 +419,15 @@ ObjCInterfaceDecl *const ObjCMethodDecl::getClassInterface() const {
|
|||
assert(false && "unknown method context");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ObjCPropertyDecl::setPropertyDeclLists(ObjCIvarDecl **Properties,
|
||||
unsigned NumProp) {
|
||||
assert(PropertyDecls == 0 && "Properties already set");
|
||||
if (NumProp == 0) return;
|
||||
NumPropertyDecls = NumProp;
|
||||
|
||||
PropertyDecls = new ObjCIvarDecl*[NumProp];
|
||||
memcpy(PropertyDecls, Properties, NumProp*sizeof(ObjCIvarDecl*));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -394,8 +394,8 @@ Parser::DeclTy *Parser::ParseObjCPropertyDecl(DeclTy *interfaceDecl,
|
|||
Diag(Tok, diag::err_expected_semi_decl_list);
|
||||
SkipUntil(tok::r_brace, true, true);
|
||||
}
|
||||
return Actions.ActOnAddObjCProperties(AtLoc,
|
||||
&PropertyDecls[0], PropertyDecls.size(), DS);
|
||||
return Actions.ActOnAddObjCProperties(AtLoc, &PropertyDecls[0],
|
||||
PropertyDecls.size(), DS);
|
||||
}
|
||||
|
||||
/// objc-method-proto:
|
||||
|
|
|
@ -893,43 +893,42 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration(
|
|||
}
|
||||
|
||||
Sema::DeclTy *Sema::ActOnAddObjCProperties(SourceLocation AtLoc,
|
||||
DeclTy **allProperties, unsigned NumProperties, ObjCDeclSpec &DS) {
|
||||
DeclTy **allProperties,
|
||||
unsigned NumProperties,
|
||||
ObjCDeclSpec &DS) {
|
||||
ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, AtLoc);
|
||||
|
||||
if(DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_readonly)
|
||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_readonly)
|
||||
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readonly);
|
||||
|
||||
if(DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_getter) {
|
||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_getter) {
|
||||
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_getter);
|
||||
PDecl->setGetterName(DS.getGetterName());
|
||||
}
|
||||
|
||||
if(DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_setter) {
|
||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_setter) {
|
||||
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_setter);
|
||||
PDecl->setSetterName(DS.getSetterName());
|
||||
}
|
||||
|
||||
if(DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_assign)
|
||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_assign)
|
||||
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_assign);
|
||||
|
||||
if(DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_readwrite)
|
||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_readwrite)
|
||||
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readwrite);
|
||||
|
||||
if(DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_retain)
|
||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_retain)
|
||||
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_retain);
|
||||
|
||||
if(DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_copy)
|
||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_copy)
|
||||
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_copy);
|
||||
|
||||
if(DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_nonatomic)
|
||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_nonatomic)
|
||||
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_nonatomic);
|
||||
|
||||
PDecl->setNumPropertyDecls(NumProperties);
|
||||
if (NumProperties != 0) {
|
||||
ObjCIvarDecl **properties = new ObjCIvarDecl*[NumProperties];
|
||||
memcpy(properties, allProperties, NumProperties*sizeof(ObjCIvarDecl*));
|
||||
PDecl->setPropertyDecls(properties);
|
||||
}
|
||||
if (NumProperties != 0)
|
||||
PDecl->setPropertyDeclLists((ObjCIvarDecl**)allProperties, NumProperties);
|
||||
|
||||
return PDecl;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue