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 | f327e89dabc34946f0086961b30813d4e25d22a5 (patch) | |
tree | 496f31158d1abae748194fc51ab809a842342c82 /clang/lib/AST/DeclObjC.cpp | |
parent | 3d1f552643159f6b9514d21e96b6de23bd3bbd70 (diff) | |
download | bcm5719-llvm-f327e89dabc34946f0086961b30813d4e25d22a5.tar.gz bcm5719-llvm-f327e89dabc34946f0086961b30813d4e25d22a5.zip |
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.
llvm-svn: 61154
Diffstat (limited to 'clang/lib/AST/DeclObjC.cpp')
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 45 |
1 files changed, 3 insertions, 42 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index a7e878fc24f..ec8a1ff044b 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/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. |