diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-23 01:02:12 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-23 01:02:12 +0000 |
commit | 29bd76fd040dea09fe65ee9eabd0fd7d5149e916 (patch) | |
tree | aea633ad9960193a30f3e7bf41cea3326a4837ec /clang/lib/Sema | |
parent | 14efb90fcfb683045e3457790a7b6ed76edfecd4 (diff) | |
download | bcm5719-llvm-29bd76fd040dea09fe65ee9eabd0fd7d5149e916.tar.gz bcm5719-llvm-29bd76fd040dea09fe65ee9eabd0fd7d5149e916.zip |
Eliminate the three SmallVectors in ObjCImplDecl (for instance
methods, class methods, and property implementations) and instead
place all of these entities into the DeclContext.
This eliminates more linear walks when looking for class or instance
methods and should make PCH (de-)serialization of ObjCDecls trivial
(and lazy).
llvm-svn: 69849
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 55 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 14 |
3 files changed, 40 insertions, 37 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 2874f27cd3b..c65b1402be3 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -824,19 +824,19 @@ bool Sema::isPropertyReadonly(ObjCPropertyDecl *PDecl, if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(CurContext)) { if (ObjCImplementationDecl *IMD = dyn_cast<ObjCImplementationDecl>(OMD->getDeclContext())) { - if (IMD->getInstanceMethod(PDecl->getSetterName())) + if (IMD->getInstanceMethod(Context, PDecl->getSetterName())) return false; } else if (ObjCCategoryImplDecl *CIMD = dyn_cast<ObjCCategoryImplDecl>(OMD->getDeclContext())) { - if (CIMD->getInstanceMethod(PDecl->getSetterName())) + if (CIMD->getInstanceMethod(Context, PDecl->getSetterName())) return false; } } // Lastly, look through the implementation (if one is in scope). if (ObjCImplementationDecl *ImpDecl = ObjCImplementations[IDecl->getIdentifier()]) - if (ImpDecl->getInstanceMethod(PDecl->getSetterName())) + if (ImpDecl->getInstanceMethod(Context, PDecl->getSetterName())) return false; // If all fails, look at the super class. if (ObjCInterfaceDecl *SIDecl = IDecl->getSuperClass()) @@ -906,8 +906,9 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, llvm::DenseSet<Selector> InsMap; // Check and see if instance methods in class interface have been // implemented in the implementation class. - for (ObjCImplementationDecl::instmeth_iterator I = IMPDecl->instmeth_begin(), - E = IMPDecl->instmeth_end(); I != E; ++I) + for (ObjCImplementationDecl::instmeth_iterator + I = IMPDecl->instmeth_begin(Context), + E = IMPDecl->instmeth_end(Context); I != E; ++I) InsMap.insert((*I)->getSelector()); // Check and see if properties declared in the interface have either 1) @@ -921,8 +922,9 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, continue; ObjCPropertyImplDecl *PI = 0; // Is there a matching propery synthesize/dynamic? - for (ObjCImplDecl::propimpl_iterator I = IMPDecl->propimpl_begin(), - EI = IMPDecl->propimpl_end(); I != EI; ++I) + for (ObjCImplDecl::propimpl_iterator + I = IMPDecl->propimpl_begin(Context), + EI = IMPDecl->propimpl_end(Context); I != EI; ++I) if ((*I)->getPropertyDecl() == Prop) { PI = (*I); break; @@ -954,7 +956,7 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, } ObjCMethodDecl *ImpMethodDecl = - IMPDecl->getInstanceMethod((*I)->getSelector()); + IMPDecl->getInstanceMethod(Context, (*I)->getSelector()); ObjCMethodDecl *IntfMethodDecl = CDecl->getInstanceMethod(Context, (*I)->getSelector()); assert(IntfMethodDecl && @@ -967,8 +969,9 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, llvm::DenseSet<Selector> ClsMap; // Check and see if class methods in class interface have been // implemented in the implementation class. - for (ObjCImplementationDecl::classmeth_iterator I =IMPDecl->classmeth_begin(), - E = IMPDecl->classmeth_end(); I != E; ++I) + for (ObjCImplementationDecl::classmeth_iterator + I = IMPDecl->classmeth_begin(Context), + E = IMPDecl->classmeth_end(Context); I != E; ++I) ClsMap.insert((*I)->getSelector()); for (ObjCInterfaceDecl::classmeth_iterator @@ -979,7 +982,7 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl); else { ObjCMethodDecl *ImpMethodDecl = - IMPDecl->getClassMethod((*I)->getSelector()); + IMPDecl->getClassMethod(Context, (*I)->getSelector()); ObjCMethodDecl *IntfMethodDecl = CDecl->getClassMethod(Context, (*I)->getSelector()); WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl); @@ -1526,21 +1529,21 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration( if (ObjCImplementationDecl *ImpDecl = dyn_cast<ObjCImplementationDecl>(ClassDecl)) { if (MethodType == tok::minus) { - PrevMethod = ImpDecl->getInstanceMethod(Sel); - ImpDecl->addInstanceMethod(ObjCMethod); + PrevMethod = ImpDecl->getInstanceMethod(Context, Sel); + ImpDecl->addInstanceMethod(Context, ObjCMethod); } else { - PrevMethod = ImpDecl->getClassMethod(Sel); - ImpDecl->addClassMethod(ObjCMethod); + PrevMethod = ImpDecl->getClassMethod(Context, Sel); + ImpDecl->addClassMethod(Context, ObjCMethod); } } else if (ObjCCategoryImplDecl *CatImpDecl = dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) { if (MethodType == tok::minus) { - PrevMethod = CatImpDecl->getInstanceMethod(Sel); - CatImpDecl->addInstanceMethod(ObjCMethod); + PrevMethod = CatImpDecl->getInstanceMethod(Context, Sel); + CatImpDecl->addInstanceMethod(Context, ObjCMethod); } else { - PrevMethod = CatImpDecl->getClassMethod(Sel); - CatImpDecl->addClassMethod(ObjCMethod); + PrevMethod = CatImpDecl->getClassMethod(Context, Sel); + CatImpDecl->addClassMethod(Context, ObjCMethod); } } if (PrevMethod) { @@ -1898,28 +1901,28 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, ObjCPropertyImplDecl::Synthesize : ObjCPropertyImplDecl::Dynamic), Ivar); - CurContext->addDecl(Context, PIDecl); if (IC) { if (Synthesize) if (ObjCPropertyImplDecl *PPIDecl = - IC->FindPropertyImplIvarDecl(PropertyIvar)) { + IC->FindPropertyImplIvarDecl(Context, PropertyIvar)) { Diag(PropertyLoc, diag::error_duplicate_ivar_use) << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier() << PropertyIvar; Diag(PPIDecl->getLocation(), diag::note_previous_use); } - if (ObjCPropertyImplDecl *PPIDecl = IC->FindPropertyImplDecl(PropertyId)) { + if (ObjCPropertyImplDecl *PPIDecl + = IC->FindPropertyImplDecl(Context, PropertyId)) { Diag(PropertyLoc, diag::error_property_implemented) << PropertyId; Diag(PPIDecl->getLocation(), diag::note_previous_declaration); return DeclPtrTy(); } - IC->addPropertyImplementation(PIDecl); + IC->addPropertyImplementation(Context, PIDecl); } else { if (Synthesize) if (ObjCPropertyImplDecl *PPIDecl = - CatImplClass->FindPropertyImplIvarDecl(PropertyIvar)) { + CatImplClass->FindPropertyImplIvarDecl(Context, PropertyIvar)) { Diag(PropertyLoc, diag::error_duplicate_ivar_use) << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier() << PropertyIvar; @@ -1927,12 +1930,12 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, } if (ObjCPropertyImplDecl *PPIDecl = - CatImplClass->FindPropertyImplDecl(PropertyId)) { + CatImplClass->FindPropertyImplDecl(Context, PropertyId)) { Diag(PropertyLoc, diag::error_property_implemented) << PropertyId; Diag(PPIDecl->getLocation(), diag::note_previous_declaration); return DeclPtrTy(); } - CatImplClass->addPropertyImplementation(PIDecl); + CatImplClass->addPropertyImplementation(Context, PIDecl); } return DeclPtrTy::make(PIDecl); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 81bac6631ce..8490672f4bf 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1809,7 +1809,7 @@ ObjCMethodDecl *Sema::FindMethodInNestedImplementations( ObjCMethodDecl *Method = 0; if (ObjCImplementationDecl *ImpDecl = Sema::ObjCImplementations[IFace->getIdentifier()]) - Method = ImpDecl->getInstanceMethod(Sel); + Method = ImpDecl->getInstanceMethod(Context, Sel); if (!Method && IFace->getSuperClass()) return FindMethodInNestedImplementations(IFace->getSuperClass(), Sel); @@ -2037,7 +2037,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, if (!Getter) { for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Getter; i++) { if (ObjCCategoryImpls[i]->getClassInterface() == IFace) - Getter = ObjCCategoryImpls[i]->getInstanceMethod(Sel); + Getter = ObjCCategoryImpls[i]->getInstanceMethod(Context, Sel); } } if (Getter) { @@ -2060,7 +2060,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, if (!Setter) { for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Setter; i++) { if (ObjCCategoryImpls[i]->getClassInterface() == IFace) - Setter = ObjCCategoryImpls[i]->getInstanceMethod(SetterSel); + Setter = ObjCCategoryImpls[i]->getInstanceMethod(Context, SetterSel); } } @@ -2141,7 +2141,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, if (!Setter) { for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Setter; i++) { if (ObjCCategoryImpls[i]->getClassInterface() == IFace) - Setter = ObjCCategoryImpls[i]->getClassMethod(SetterSel); + Setter = ObjCCategoryImpls[i]->getClassMethod(Context, SetterSel); } } diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 0c1f1448028..23f6f94dc06 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -224,13 +224,13 @@ ObjCMethodDecl *Sema::LookupPrivateClassMethod(Selector Sel, while (ClassDecl && !Method) { if (ObjCImplementationDecl *ImpDecl = ObjCImplementations[ClassDecl->getIdentifier()]) - Method = ImpDecl->getClassMethod(Sel); + Method = ImpDecl->getClassMethod(Context, Sel); // Look through local category implementations associated with the class. if (!Method) { for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Method; i++) { if (ObjCCategoryImpls[i]->getClassInterface() == ClassDecl) - Method = ObjCCategoryImpls[i]->getClassMethod(Sel); + Method = ObjCCategoryImpls[i]->getClassMethod(Context, Sel); } } @@ -257,13 +257,13 @@ ObjCMethodDecl *Sema::LookupPrivateInstanceMethod(Selector Sel, // If we have implementations in scope, check "private" methods. if (ObjCImplementationDecl *ImpDecl = ObjCImplementations[ClassDecl->getIdentifier()]) - Method = ImpDecl->getInstanceMethod(Sel); + Method = ImpDecl->getInstanceMethod(Context, Sel); // Look through local category implementations associated with the class. if (!Method) { for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Method; i++) { if (ObjCCategoryImpls[i]->getClassInterface() == ClassDecl) - Method = ObjCCategoryImpls[i]->getInstanceMethod(Sel); + Method = ObjCCategoryImpls[i]->getInstanceMethod(Context, Sel); } } ClassDecl = ClassDecl->getSuperClass(); @@ -290,7 +290,7 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr( if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) if (ObjCImplementationDecl *ImpDecl = ObjCImplementations[ClassDecl->getIdentifier()]) - Getter = ImpDecl->getClassMethod(Sel); + Getter = ImpDecl->getClassMethod(Context, Sel); if (Getter) { // FIXME: refactor/share with ActOnMemberReference(). @@ -312,13 +312,13 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr( if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) if (ObjCImplementationDecl *ImpDecl = ObjCImplementations[ClassDecl->getIdentifier()]) - Setter = ImpDecl->getClassMethod(SetterSel); + Setter = ImpDecl->getClassMethod(Context, SetterSel); } // Look through local category implementations associated with the class. if (!Setter) { for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Setter; i++) { if (ObjCCategoryImpls[i]->getClassInterface() == IFace) - Setter = ObjCCategoryImpls[i]->getClassMethod(SetterSel); + Setter = ObjCCategoryImpls[i]->getClassMethod(Context, SetterSel); } } |