ObjCMethodDecl *GetterMethodDecl; // Declaration of getter instance method
ObjCMethodDecl *SetterMethodDecl; // Declaration of setter instance method
+ ObjCIvarDecl *PropertyIvarDecl; // Synthesize ivar for this property
ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
QualType T)
PropertyAttributes(OBJC_PR_noattr), PropertyImplementation(None),
GetterName(Selector()),
SetterName(Selector()),
- GetterMethodDecl(0), SetterMethodDecl(0) {}
+ GetterMethodDecl(0), SetterMethodDecl(0) , PropertyIvarDecl(0) {}
public:
static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
return PropertyControl(PropertyImplementation);
}
+ void setPropertyIvarDecl(ObjCIvarDecl *Ivar) {
+ PropertyIvarDecl = Ivar;
+ }
+ ObjCIvarDecl *getPropertyIvarDecl() const {
+ return PropertyIvarDecl;
+ }
+
static bool classof(const Decl *D) {
return D->getKind() == ObjCProperty;
}
Dynamic
};
private:
- unsigned IvarKind : 1;
SourceLocation AtLoc; // location of @synthesize or @dynamic
/// Property declaration being implemented
ObjCPropertyDecl *PropertyDecl;
ObjCPropertyDecl *property,
Kind PK,
ObjCIvarDecl *ivarDecl)
- : Decl(ObjCPropertyImpl, DC, L), IvarKind(false), AtLoc(atLoc),
+ : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc),
PropertyDecl(property), PropertyIvarDecl(ivarDecl) {
assert (PK == Dynamic || PropertyIvarDecl);
}
ObjCIvarDecl *getPropertyIvarDecl() const {
return PropertyIvarDecl;
}
- void SetPropertyIvarDecl(ObjCIvarDecl *Ivar) {
- assert(PropertyIvarDecl && "PropertyIvarDecl is already defined");
- PropertyIvarDecl = Ivar;
- }
- void SetIvarSynthesized() {
- IvarKind = true;
- }
- bool IsIvarSynthesized() const {
- return IvarKind;
- }
static bool classof(const Decl *D) {
return D->getKind() == ObjCPropertyImpl;
if (!IVDecl->isInvalidDecl())
Fields.push_back(cast<FieldDecl>(IVDecl));
}
+ // look into properties.
+ for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(),
+ E = OI->prop_end(); I != E; ++I) {
+ ObjCPropertyDecl *PDecl = (*I);
+ if (ObjCIvarDecl *IV = PDecl->getPropertyIvarDecl())
+ Fields.push_back(cast<FieldDecl>(IV));
+ }
}
/// addRecordToClass - produces record info. for the class for its
return *I;
}
}
+ // look into properties.
+ for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(),
+ E = ClassDecl->prop_end(); I != E; ++I) {
+ ObjCPropertyDecl *PDecl = (*I);
+ if (ObjCIvarDecl *IV = PDecl->getPropertyIvarDecl())
+ if (IV->getIdentifier() == ID) {
+ clsDeclared = ClassDecl;
+ return IV;
+ }
+ }
ClassDecl = ClassDecl->getSuperClass();
}
return NULL;
// @synthesize
if (!PropertyIvar)
PropertyIvar = PropertyId;
+ QualType PropType = Context.getCanonicalType(property->getType());
// Check that this is a previously declared 'ivar' in 'IDecl' interface
Ivar = IDecl->lookupInstanceVariable(PropertyIvar);
if (!Ivar) {
- if (getLangOptions().ObjCNonFragileABI)
- Diag(PropertyLoc, diag::error_synthesized_ivar_yet_not_supported)
- << PropertyId;
- else
+ if (getLangOptions().ObjCNonFragileABI) {
+ Ivar = ObjCIvarDecl::Create(Context, CurContext, PropertyLoc,
+ PropertyIvar, PropType,
+ ObjCIvarDecl::Private,
+ (Expr *)0);
+ property->setPropertyIvarDecl(Ivar);
+ }
+ else {
Diag(PropertyLoc, diag::error_missing_property_ivar_decl) << PropertyId;
- return DeclPtrTy();
+ return DeclPtrTy();
+ }
}
- QualType PropType = Context.getCanonicalType(property->getType());
QualType IvarType = Context.getCanonicalType(Ivar->getType());
// Check that type of property and its ivar are type compatible.