More refactoring/cleanup of objc ivars.

llvm-svn: 72871
This commit is contained in:
Fariborz Jahanian 2009-06-04 17:08:55 +00:00
parent c2eed3b0f8
commit 7dae11446f
1 changed files with 11 additions and 22 deletions

View File

@ -2113,27 +2113,6 @@ bool Sema::CheckObjCDeclScope(Decl *D) {
return true;
}
/// Collect the instance variables declared in an Objective-C object. Used in
/// the creation of structures from objects using the @defs directive.
/// FIXME: This should be consolidated with CollectObjCIvars as it is also
/// part of the AST generation logic of @defs.
static void CollectIvars(ObjCInterfaceDecl *Class, RecordDecl *Record,
ASTContext& Ctx,
llvm::SmallVectorImpl<Sema::DeclPtrTy> &ivars) {
if (Class->getSuperClass())
CollectIvars(Class->getSuperClass(), Record, Ctx, ivars);
// For each ivar, create a fresh ObjCAtDefsFieldDecl.
for (ObjCInterfaceDecl::ivar_iterator I = Class->ivar_begin(),
E = Class->ivar_end(); I != E; ++I) {
ObjCIvarDecl* ID = *I;
Decl *FD = ObjCAtDefsFieldDecl::Create(Ctx, Record, ID->getLocation(),
ID->getIdentifier(), ID->getType(),
ID->getBitWidth());
ivars.push_back(Sema::DeclPtrTy::make(FD));
}
}
/// Called whenever @defs(ClassName) is encountered in the source. Inserts the
/// instance variables of ClassName into Decls.
void Sema::ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
@ -2151,7 +2130,17 @@ void Sema::ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
}
// Collect the instance variables
CollectIvars(Class, dyn_cast<RecordDecl>(TagD.getAs<Decl>()), Context, Decls);
llvm::SmallVector<FieldDecl*, 32> RecFields;
Context.CollectObjCIvars(Class, RecFields);
// For each ivar, create a fresh ObjCAtDefsFieldDecl.
for (unsigned i = 0; i < RecFields.size(); i++) {
FieldDecl* ID = RecFields[i];
RecordDecl *Record = dyn_cast<RecordDecl>(TagD.getAs<Decl>());
Decl *FD = ObjCAtDefsFieldDecl::Create(Context, Record, ID->getLocation(),
ID->getIdentifier(), ID->getType(),
ID->getBitWidth());
Decls.push_back(Sema::DeclPtrTy::make(FD));
}
// Introduce all of these fields into the appropriate scope.
for (llvm::SmallVectorImpl<DeclPtrTy>::iterator D = Decls.begin();