/// Implementation Class's super class.
ObjCInterfaceDecl *SuperClass;
- /// Optional Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
- ObjCIvarDecl **Ivars; // Null if not specified
- unsigned NumIvars; // 0 if none.
+ /// Instance variables declared in the @implementation.
+ ObjCList<ObjCIvarDecl> IVars;
/// implemented instance methods
llvm::SmallVector<ObjCMethodDecl*, 32> InstanceMethods;
ObjCInterfaceDecl *classInterface,
ObjCInterfaceDecl *superDecl)
: Decl(ObjCImplementation, DC, L), DeclContext(ObjCImplementation),
- ClassInterface(classInterface), SuperClass(superDecl),
- Ivars(0), NumIvars(0) {}
+ ClassInterface(classInterface), SuperClass(superDecl){}
public:
static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
ObjCInterfaceDecl *classInterface,
ObjCInterfaceDecl *superDecl);
+ /// Destroy - Call destructors and release memory.
+ virtual void Destroy(ASTContext& C);
+
+ void setIVarList(ObjCIvarDecl *const *InArray, unsigned Num) {
+ IVars.set(InArray, Num);
+ }
- void ObjCAddInstanceVariablesToClassImpl(ObjCIvarDecl **ivars,
- unsigned numIvars);
-
void addInstanceMethod(ObjCMethodDecl *method) {
InstanceMethods.push_back(method);
}
return isInstance ? getInstanceMethod(Sel) : getClassMethod(Sel);
}
- typedef ObjCIvarDecl * const *ivar_iterator;
- ivar_iterator ivar_begin() const { return Ivars; }
- ivar_iterator ivar_end() const { return Ivars+NumIvars; }
- unsigned ivar_size() const { return NumIvars; }
- bool ivar_empty() const { return NumIvars == 0; }
+ typedef ObjCList<ObjCIvarDecl>::iterator ivar_iterator;
+ ivar_iterator ivar_begin() const { return IVars.begin(); }
+ ivar_iterator ivar_end() const { return IVars.end(); }
+ unsigned ivar_size() const { return IVars.size(); }
+ bool ivar_empty() const { return IVars.empty(); }
static bool classof(const Decl *D) {
return D->getKind() == ObjCImplementation;
return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl);
}
+/// Destroy - Call destructors and release memory.
+void ObjCImplementationDecl::Destroy(ASTContext& C) {
+ IVars.clear();
+}
+
+
ObjCCompatibleAliasDecl *
ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
return MemberDecl;
}
-/// ObjCAddInstanceVariablesToClassImpl - Checks for correctness of Instance
-/// Variables (Ivars) relative to what declared in @implementation;s class.
-/// Ivars into ObjCImplementationDecl's fields.
-///
-void ObjCImplementationDecl::ObjCAddInstanceVariablesToClassImpl(
- ObjCIvarDecl **ivars, unsigned numIvars) {
- NumIvars = numIvars;
- if (numIvars) {
- Ivars = new ObjCIvarDecl*[numIvars];
- memcpy(Ivars, ivars, numIvars*sizeof(ObjCIvarDecl*));
- }
-}
// Get the local instance method declared in this interface.
// FIXME: handle overloading, instance & class methods can have the same name.
}
- // FIXME: Chain fielddecls together.
- FieldDecl *NewFD;
-
- NewFD = FieldDecl::Create(Context, Record,
- Loc, II, T, BitWidth,
- D.getDeclSpec().getStorageClassSpec() ==
- DeclSpec::SCS_mutable);
+ FieldDecl *NewFD = FieldDecl::Create(Context, Record,
+ Loc, II, T, BitWidth,
+ D.getDeclSpec().getStorageClassSpec() ==
+ DeclSpec::SCS_mutable);
if (II) {
NamedDecl *PrevDecl = LookupName(S, II, LookupMemberName, true);
else if (ObjCImplementationDecl *IMPDecl =
dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl");
- IMPDecl->ObjCAddInstanceVariablesToClassImpl(ClsFields, RecFields.size());
+ IMPDecl->setIVarList(ClsFields, RecFields.size());
CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
}
}