diff options
Diffstat (limited to 'lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 8f58034..2500a8f 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -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(); |