diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2008-12-17 21:40:49 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2008-12-17 21:40:49 +0000 |
commit | a769c004a2874504c17ea8afccbc4ad35fc33c9f (patch) | |
tree | 8b99e51cf54df41037797a650475ecd17322fa53 /lib/AST/DeclObjC.cpp | |
parent | b60d7999d621fce608e03d39e82c0e7eda750054 (diff) |
This patch will build the Records lazily per Steve's comments.
Note that one test duplicate-ivar-check.m will fail because I
need to re-implement duplicate ivar checking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61154 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r-- | lib/AST/DeclObjC.cpp | 45 |
1 files changed, 3 insertions, 42 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index a7e878fc24..ec8a1ff044 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -338,18 +338,6 @@ ObjCIvarDecl * return 0; } -void ObjCInterfaceDecl::CollectObjCIvars(std::vector<FieldDecl*> &Fields) { - ObjCInterfaceDecl *SuperClass = getSuperClass(); - if (SuperClass) - SuperClass->CollectObjCIvars(Fields); - for (ObjCInterfaceDecl::ivar_iterator I = ivar_begin(), - E = ivar_end(); I != E; ++I) { - ObjCIvarDecl *IVDecl = (*I); - if (!IVDecl->isInvalidDecl()) - Fields.push_back(cast<FieldDecl>(IVDecl)); - } -} - /// ObjCAddInstanceVariablesToClass - Inserts instance variables /// into ObjCInterfaceDecl's fields. /// @@ -369,44 +357,17 @@ void ObjCInterfaceDecl::addInstanceVariablesToClass(ObjCIvarDecl **ivars, /// FieldDecl *ObjCInterfaceDecl::lookupFieldDeclForIvar(ASTContext &Context, const ObjCIvarDecl *ivar) { - /* When a super class's ivar is referenced in the subclass method with no ivar - of its own, record for the sub-class is not built yet. Build it lazily - here. */ - if (!RecordForDecl) - addRecordToClass(Context); + const RecordDecl *RecordForDecl = Context.addRecordToClass(this); assert(RecordForDecl && "lookupFieldDeclForIvar no storage for class"); DeclarationName Member = ivar->getDeclName(); - DeclContext::lookup_result Lookup = RecordForDecl->lookup(Context, Member); + DeclContext::lookup_result Lookup = (const_cast< RecordDecl *>(RecordForDecl)) + ->lookup(Context, Member); assert((Lookup.first != Lookup.second) && "field decl not found"); FieldDecl *MemberDecl = dyn_cast<FieldDecl>(*Lookup.first); assert(MemberDecl && "field decl not found"); return MemberDecl; } -/// addRecordToClass - produces record info. for the class for its -/// ivars and all those inherited. -/// -void ObjCInterfaceDecl::addRecordToClass(ASTContext &Context) -{ - std::vector<FieldDecl*> RecFields; - CollectObjCIvars(RecFields); - RecordDecl *RD = RecordDecl::Create(Context, TagDecl::TK_struct, 0, - getLocation(), - getIdentifier()); - /// FIXME! Can do collection of ivars and adding to the record while - /// doing it. - for (unsigned int i = 0; i != RecFields.size(); i++) { - FieldDecl *Field = FieldDecl::Create(Context, RD, - RecFields[i]->getLocation(), - RecFields[i]->getIdentifier(), - RecFields[i]->getType(), - RecFields[i]->getBitWidth(), false, 0); - RD->addDecl(Context, Field); - } - RD->completeDefinition(Context); - RecordForDecl = RD; -} - /// ObjCAddInstanceVariablesToClassImpl - Checks for correctness of Instance /// Variables (Ivars) relative to what declared in @implementation;s class. /// Ivars into ObjCImplementationDecl's fields. |