/// Implementation Class's super class.
ObjCInterfaceDecl *SuperClass;
- /// Instance variables declared in the @implementation.
- ObjCList<ObjCIvarDecl> IVars;
-
ObjCImplementationDecl(DeclContext *DC, SourceLocation L,
ObjCInterfaceDecl *classInterface,
ObjCInterfaceDecl *superDecl)
ObjCInterfaceDecl *classInterface,
ObjCInterfaceDecl *superDecl);
- /// Destroy - Call destructors and release memory.
- virtual void Destroy(ASTContext& C);
-
- void setIVarList(ObjCIvarDecl *const *InArray, unsigned Num, ASTContext &C) {
- IVars.set(InArray, Num, C);
- }
-
/// getIdentifier - Get the identifier that names the class
/// interface associated with this implementation.
IdentifierInfo *getIdentifier() const {
void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
- 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(); }
+ typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
+ ivar_iterator ivar_begin(ASTContext &Context) const {
+ return ivar_iterator(decls_begin(Context));
+ }
+ ivar_iterator ivar_end(ASTContext &Context) const {
+ return ivar_iterator(decls_end(Context));
+ }
+ unsigned ivar_size(ASTContext &Context) const {
+ return std::distance(ivar_begin(Context), ivar_end(Context));
+ }
+ bool ivar_empty(ASTContext &Context) const {
+ return ivar_begin(Context) == ivar_end(Context);
+ }
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.Destroy(C);
- Decl::Destroy(C);
-}
-
//===----------------------------------------------------------------------===//
// ObjCCompatibleAliasDecl
//===----------------------------------------------------------------------===//
void PCHDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
VisitObjCImplDecl(D);
- // FIXME: Implement.
+ D->setSuperClass(
+ cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
}
}
case pch::DECL_OBJC_IMPLEMENTATION: {
- // FIXME: Implement.
+ D = ObjCImplementationDecl::Create(Context, 0, SourceLocation(), 0, 0);
break;
}
void PCHDeclWriter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
VisitObjCImplDecl(D);
- // FIXME: Implement.
+ Writer.AddDeclRef(D->getSuperClass(), Record);
Code = pch::DECL_OBJC_IMPLEMENTATION;
}
} else if (ObjCImplementationDecl *IMPDecl =
dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl");
- IMPDecl->setIVarList(ClsFields, RecFields.size(), Context);
+ for (unsigned I = 0, N = RecFields.size(); I != N; ++I) {
+ // FIXME: Set the DeclContext correctly when we build the
+ // declarations.
+ ClsFields[I]->setLexicalDeclContext(IMPDecl);
+ IMPDecl->addDecl(Context, ClsFields[I]);
+ }
CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
}
}
}
// Build _objc_ivar_list metadata for classes ivars if needed
- unsigned NumIvars = !IDecl->ivar_empty()
- ? IDecl->ivar_size()
+ unsigned NumIvars = !IDecl->ivar_empty(*Context)
+ ? IDecl->ivar_size(*Context)
: (CDecl ? CDecl->ivar_size() : 0);
if (NumIvars > 0) {
static bool objc_ivar = false;
Result += "\n";
ObjCInterfaceDecl::ivar_iterator IVI, IVE;
- if (!IDecl->ivar_empty()) {
- IVI = IDecl->ivar_begin();
- IVE = IDecl->ivar_end();
+ llvm::SmallVector<ObjCIvarDecl *, 8> IVars;
+ if (!IDecl->ivar_empty(*Context)) {
+ for (ObjCImplementationDecl::ivar_iterator
+ IV = IDecl->ivar_begin(*Context),
+ IVEnd = IDecl->ivar_end(*Context);
+ IV != IVEnd; ++IV)
+ IVars.push_back(*IV);
+ IVI = IVars.begin();
+ IVE = IVars.end();
} else {
IVI = CDecl->ivar_begin();
IVE = CDecl->ivar_end();