diff options
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 124 |
1 files changed, 66 insertions, 58 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index e1583d75b40..edbb018a223 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -98,7 +98,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc, ObjCInterfaceDecls[ClassName] = IDecl; // FIXME: PushOnScopeChains - CurContext->addDecl(IDecl); + CurContext->addDecl(Context, IDecl); // Remember that this needs to be removed when the scope is popped. TUScope->AddDecl(DeclPtrTy::make(IDecl)); } @@ -206,7 +206,7 @@ Sema::DeclPtrTy Sema::ActOnCompatiblityAlias(SourceLocation AtLoc, ObjCAliasDecls[AliasName] = AliasDecl; // FIXME: PushOnScopeChains? - CurContext->addDecl(AliasDecl); + CurContext->addDecl(Context, AliasDecl); if (!CheckObjCDeclScope(AliasDecl)) TUScope->AddDecl(DeclPtrTy::make(AliasDecl)); @@ -265,7 +265,7 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, PDecl = ObjCProtocolDecl::Create(Context, CurContext, AtProtoInterfaceLoc,ProtocolName); // FIXME: PushOnScopeChains? - CurContext->addDecl(PDecl); + CurContext->addDecl(Context, PDecl); PDecl->setForwardDecl(false); ObjCProtocols[ProtocolName] = PDecl; } @@ -367,12 +367,12 @@ void Sema::ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl) { if (!SDecl) return; // FIXME: O(N^2) - for (ObjCInterfaceDecl::prop_iterator S = SDecl->prop_begin(), - E = SDecl->prop_end(); S != E; ++S) { + for (ObjCInterfaceDecl::prop_iterator S = SDecl->prop_begin(Context), + E = SDecl->prop_end(Context); S != E; ++S) { ObjCPropertyDecl *SuperPDecl = (*S); // Does property in super class has declaration in current class? - for (ObjCInterfaceDecl::prop_iterator I = IDecl->prop_begin(), - E = IDecl->prop_end(); I != E; ++I) { + for (ObjCInterfaceDecl::prop_iterator I = IDecl->prop_begin(Context), + E = IDecl->prop_end(Context); I != E; ++I) { ObjCPropertyDecl *PDecl = (*I); if (SuperPDecl->getIdentifier() == PDecl->getIdentifier()) DiagnosePropertyMismatch(PDecl, SuperPDecl, @@ -392,12 +392,12 @@ Sema::MergeOneProtocolPropertiesIntoClass(Decl *CDecl, // Category ObjCCategoryDecl *CatDecl = static_cast<ObjCCategoryDecl*>(CDecl); assert (CatDecl && "MergeOneProtocolPropertiesIntoClass"); - for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(), - E = PDecl->prop_end(); P != E; ++P) { + for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(Context), + E = PDecl->prop_end(Context); P != E; ++P) { ObjCPropertyDecl *Pr = (*P); ObjCCategoryDecl::prop_iterator CP, CE; // Is this property already in category's list of properties? - for (CP = CatDecl->prop_begin(), CE = CatDecl->prop_end(); + for (CP = CatDecl->prop_begin(Context), CE = CatDecl->prop_end(Context); CP != CE; ++CP) if ((*CP)->getIdentifier() == Pr->getIdentifier()) break; @@ -407,12 +407,12 @@ Sema::MergeOneProtocolPropertiesIntoClass(Decl *CDecl, } return; } - for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(), - E = PDecl->prop_end(); P != E; ++P) { + for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(Context), + E = PDecl->prop_end(Context); P != E; ++P) { ObjCPropertyDecl *Pr = (*P); ObjCInterfaceDecl::prop_iterator CP, CE; // Is this property already in class's list of properties? - for (CP = IDecl->prop_begin(), CE = IDecl->prop_end(); + for (CP = IDecl->prop_begin(Context), CE = IDecl->prop_end(Context); CP != CE; ++CP) if ((*CP)->getIdentifier() == Pr->getIdentifier()) break; @@ -483,16 +483,16 @@ void Sema::DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, return; // Possibly due to previous error llvm::DenseMap<Selector, const ObjCMethodDecl*> MethodMap; - for (ObjCInterfaceDecl::method_iterator i = ID->meth_begin(), - e = ID->meth_end(); i != e; ++i) { + for (ObjCInterfaceDecl::method_iterator i = ID->meth_begin(Context), + e = ID->meth_end(Context); i != e; ++i) { ObjCMethodDecl *MD = *i; MethodMap[MD->getSelector()] = MD; } if (MethodMap.empty()) return; - for (ObjCCategoryDecl::method_iterator i = CAT->meth_begin(), - e = CAT->meth_end(); i != e; ++i) { + for (ObjCCategoryDecl::method_iterator i = CAT->meth_begin(Context), + e = CAT->meth_end(Context); i != e; ++i) { ObjCMethodDecl *Method = *i; const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()]; if (PrevMethod && !MatchTwoMethodDeclarations(Method, PrevMethod)) { @@ -518,7 +518,7 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, PDecl = ObjCProtocolDecl::Create(Context, CurContext, IdentList[i].second, Ident); // FIXME: PushOnScopeChains? - CurContext->addDecl(PDecl); + CurContext->addDecl(Context, PDecl); } if (attrList) ProcessDeclAttributeList(PDecl, attrList); @@ -528,7 +528,7 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, ObjCForwardProtocolDecl *PDecl = ObjCForwardProtocolDecl::Create(Context, CurContext, AtProtocolLoc, &Protocols[0], Protocols.size()); - CurContext->addDecl(PDecl); + CurContext->addDecl(Context, PDecl); CheckObjCDeclScope(PDecl); return DeclPtrTy::make(PDecl); } @@ -544,7 +544,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, ObjCCategoryDecl *CDecl = ObjCCategoryDecl::Create(Context, CurContext, AtInterfaceLoc, CategoryName); // FIXME: PushOnScopeChains? - CurContext->addDecl(CDecl); + CurContext->addDecl(Context, CDecl); ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName); /// Check that class of this category is already completely declared. @@ -598,7 +598,7 @@ Sema::DeclPtrTy Sema::ActOnStartCategoryImplementation( Diag(ClassLoc, diag::err_undef_interface) << ClassName; // FIXME: PushOnScopeChains? - CurContext->addDecl(CDecl); + CurContext->addDecl(Context, CDecl); /// TODO: Check that CatName, category name, is not used in another // implementation. @@ -663,7 +663,7 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation( IDecl->setLocEnd(ClassLoc); // FIXME: PushOnScopeChains? - CurContext->addDecl(IDecl); + CurContext->addDecl(Context, IDecl); // Remember that this needs to be removed when the scope is popped. TUScope->AddDecl(DeclPtrTy::make(IDecl)); } @@ -673,7 +673,7 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation( IDecl, SDecl); // FIXME: PushOnScopeChains? - CurContext->addDecl(IMPDecl); + CurContext->addDecl(Context, IMPDecl); if (CheckObjCDeclScope(IMPDecl)) return DeclPtrTy::make(IMPDecl); @@ -797,7 +797,7 @@ bool Sema::isPropertyReadonly(ObjCPropertyDecl *PDecl, return false; // Even if property is ready only, if interface has a user defined setter, // it is not considered read only. - if (IDecl->getInstanceMethod(PDecl->getSetterName())) + if (IDecl->getInstanceMethod(Context, PDecl->getSetterName())) return false; // Main class has the property as 'readonly'. Must search @@ -807,10 +807,10 @@ bool Sema::isPropertyReadonly(ObjCPropertyDecl *PDecl, Category; Category = Category->getNextClassCategory()) { // Even if property is ready only, if a category has a user defined setter, // it is not considered read only. - if (Category->getInstanceMethod(PDecl->getSetterName())) + if (Category->getInstanceMethod(Context, PDecl->getSetterName())) return false; ObjCPropertyDecl *P = - Category->FindPropertyDeclaration(PDecl->getIdentifier()); + Category->FindPropertyDeclaration(Context, PDecl->getIdentifier()); if (P && !P->isReadOnly()) return false; } @@ -863,28 +863,31 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, // and otherwise would terminate in a warning. // check unimplemented instance methods. - for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(), - E = PDecl->instmeth_end(); I != E; ++I) { + for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(Context), + E = PDecl->instmeth_end(Context); I != E; ++I) { ObjCMethodDecl *method = *I; if (method->getImplementationControl() != ObjCMethodDecl::Optional && !method->isSynthesized() && !InsMap.count(method->getSelector()) && - (!Super || !Super->lookupInstanceMethod(method->getSelector()))) { + (!Super || + !Super->lookupInstanceMethod(Context, method->getSelector()))) { // Ugly, but necessary. Method declared in protcol might have // have been synthesized due to a property declared in the class which // uses the protocol. ObjCMethodDecl *MethodInClass = - IDecl->lookupInstanceMethod(method->getSelector()); + IDecl->lookupInstanceMethod(Context, method->getSelector()); if (!MethodInClass || !MethodInClass->isSynthesized()) WarnUndefinedMethod(ImpLoc, method, IncompleteImpl); } } // check unimplemented class methods - for (ObjCProtocolDecl::classmeth_iterator I = PDecl->classmeth_begin(), - E = PDecl->classmeth_end(); I != E; ++I) { + for (ObjCProtocolDecl::classmeth_iterator + I = PDecl->classmeth_begin(Context), + E = PDecl->classmeth_end(Context); + I != E; ++I) { ObjCMethodDecl *method = *I; if (method->getImplementationControl() != ObjCMethodDecl::Optional && !ClsMap.count(method->getSelector()) && - (!Super || !Super->lookupClassMethod(method->getSelector()))) + (!Super || !Super->lookupClassMethod(Context, method->getSelector()))) WarnUndefinedMethod(ImpLoc, method, IncompleteImpl); } // Check on this protocols's referenced protocols, recursively. @@ -900,11 +903,11 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, // 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) + E = IMPDecl->instmeth_end(); I != E; ++I) InsMap.insert((*I)->getSelector()); - for (ObjCInterfaceDecl::instmeth_iterator I = CDecl->instmeth_begin(), - E = CDecl->instmeth_end(); I != E; ++I) { + for (ObjCInterfaceDecl::instmeth_iterator I = CDecl->instmeth_begin(Context), + E = CDecl->instmeth_end(Context); I != E; ++I) { if (!(*I)->isSynthesized() && !InsMap.count((*I)->getSelector())) { WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl); continue; @@ -913,7 +916,7 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, ObjCMethodDecl *ImpMethodDecl = IMPDecl->getInstanceMethod((*I)->getSelector()); ObjCMethodDecl *IntfMethodDecl = - CDecl->getInstanceMethod((*I)->getSelector()); + CDecl->getInstanceMethod(Context, (*I)->getSelector()); assert(IntfMethodDecl && "IntfMethodDecl is null in ImplMethodsVsClassMethods"); // ImpMethodDecl may be null as in a @dynamic property. @@ -928,15 +931,17 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, E = IMPDecl->classmeth_end(); I != E; ++I) ClsMap.insert((*I)->getSelector()); - for (ObjCInterfaceDecl::classmeth_iterator I = CDecl->classmeth_begin(), - E = CDecl->classmeth_end(); I != E; ++I) + for (ObjCInterfaceDecl::classmeth_iterator + I = CDecl->classmeth_begin(Context), + E = CDecl->classmeth_end(Context); + I != E; ++I) if (!ClsMap.count((*I)->getSelector())) WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl); else { ObjCMethodDecl *ImpMethodDecl = IMPDecl->getClassMethod((*I)->getSelector()); ObjCMethodDecl *IntfMethodDecl = - CDecl->getClassMethod((*I)->getSelector()); + CDecl->getClassMethod(Context, (*I)->getSelector()); WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl); } @@ -1002,7 +1007,7 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, ObjCInterfaceDecls[IdentList[i]] = IDecl; // FIXME: PushOnScopeChains? - CurContext->addDecl(IDecl); + CurContext->addDecl(Context, IDecl); // Remember that this needs to be removed when the scope is popped. TUScope->AddDecl(DeclPtrTy::make(IDecl)); } @@ -1013,7 +1018,7 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, ObjCClassDecl *CDecl = ObjCClassDecl::Create(Context, CurContext, AtClassLoc, &Interfaces[0], Interfaces.size()); - CurContext->addDecl(CDecl); + CurContext->addDecl(Context, CDecl); CheckObjCDeclScope(CDecl); return DeclPtrTy::make(CDecl); } @@ -1138,8 +1143,8 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *CD) { ObjCMethodDecl *GetterMethod, *SetterMethod; - GetterMethod = CD->getInstanceMethod(property->getGetterName()); - SetterMethod = CD->getInstanceMethod(property->getSetterName()); + GetterMethod = CD->getInstanceMethod(Context, property->getGetterName()); + SetterMethod = CD->getInstanceMethod(Context, property->getSetterName()); if (GetterMethod && GetterMethod->getResultType() != property->getType()) { @@ -1182,7 +1187,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCPropertyDecl::Optional) ? ObjCMethodDecl::Optional : ObjCMethodDecl::Required); - CD->addDecl(GetterMethod); + CD->addDecl(Context, GetterMethod); } else // A user declared getter will be synthesize when @synthesize of // the property with the same name is seen in the @implementation @@ -1213,7 +1218,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, VarDecl::None, 0); SetterMethod->setMethodParams(&Argument, 1, Context); - CD->addDecl(SetterMethod); + CD->addDecl(Context, SetterMethod); } else // A user declared setter will be synthesize when @synthesize of // the property with the same name is seen in the @implementation @@ -1279,7 +1284,7 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl, << Method->getDeclName(); Diag(PrevMethod->getLocation(), diag::note_previous_declaration); } else { - DC->addDecl(Method); + DC->addDecl(Context, Method); InsMap[Method->getSelector()] = Method; /// The following allows us to typecheck messages to "id". AddInstanceMethodToGlobalPool(Method); @@ -1296,7 +1301,7 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl, << Method->getDeclName(); Diag(PrevMethod->getLocation(), diag::note_previous_declaration); } else { - DC->addDecl(Method); + DC->addDecl(Context, Method); ClsMap[Method->getSelector()] = Method; /// The following allows us to typecheck messages to "Class". AddFactoryMethodToGlobalPool(Method); @@ -1322,8 +1327,9 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl, // ProcessPropertyDecl is responsible for diagnosing conflicts with any // user-defined setter/getter. It also synthesizes setter/getter methods // and adds them to the DeclContext and global method pools. - for (ObjCContainerDecl::prop_iterator I = CDecl->prop_begin(), - E = CDecl->prop_end(); I != E; ++I) + for (ObjCContainerDecl::prop_iterator I = CDecl->prop_begin(Context), + E = CDecl->prop_end(Context); + I != E; ++I) ProcessPropertyDecl(*I, CDecl); CDecl->setAtEndLoc(AtEndLoc); } @@ -1612,8 +1618,10 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, // Find the property in continuation class's primary class only. ObjCPropertyDecl *PIDecl = 0; IdentifierInfo *PropertyId = FD.D.getIdentifier(); - for (ObjCInterfaceDecl::prop_iterator I = CCPrimary->prop_begin(), - E = CCPrimary->prop_end(); I != E; ++I) + for (ObjCInterfaceDecl::prop_iterator + I = CCPrimary->prop_begin(Context), + E = CCPrimary->prop_end(Context); + I != E; ++I) if ((*I)->getIdentifier() == PropertyId) { PIDecl = *I; break; @@ -1671,7 +1679,7 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, assert(DC && "ClassDecl is not a DeclContext"); ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC, AtLoc, FD.D.getIdentifier(), T); - DC->addDecl(PDecl); + DC->addDecl(Context, PDecl); ProcessDeclAttributes(PDecl, FD.D); @@ -1747,7 +1755,7 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, "ActOnPropertyImplDecl - @implementation without @interface"); // Look for this property declaration in the @implementation's @interface - property = IDecl->FindPropertyDeclaration(PropertyId); + property = IDecl->FindPropertyDeclaration(Context, PropertyId); if (!property) { Diag(PropertyLoc, diag::error_bad_property_decl) << IDecl->getDeclName(); return DeclPtrTy(); @@ -1771,7 +1779,7 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, if (!Category) return DeclPtrTy(); // Look for this property declaration in @implementation's category - property = Category->FindPropertyDeclaration(PropertyId); + property = Category->FindPropertyDeclaration(Context, PropertyId); if (!property) { Diag(PropertyLoc, diag::error_bad_category_property_decl) << Category->getDeclName(); @@ -1789,7 +1797,7 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, PropertyIvar = PropertyId; QualType PropType = Context.getCanonicalType(property->getType()); // Check that this is a previously declared 'ivar' in 'IDecl' interface - Ivar = IDecl->lookupInstanceVariable(PropertyIvar); + Ivar = IDecl->lookupInstanceVariable(Context, PropertyIvar); if (!Ivar) { if (getLangOptions().ObjCNonFragileABI) { Ivar = ObjCIvarDecl::Create(Context, CurContext, PropertyLoc, @@ -1851,7 +1859,7 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, ObjCPropertyImplDecl::Synthesize : ObjCPropertyImplDecl::Dynamic), Ivar); - CurContext->addDecl(PIDecl); + CurContext->addDecl(Context, PIDecl); if (IC) { if (Synthesize) if (ObjCPropertyImplDecl *PPIDecl = @@ -1943,7 +1951,7 @@ void Sema::ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart, if (getLangOptions().CPlusPlus) PushOnScopeChains(cast<FieldDecl>(FD), S); else if (RecordDecl *Record = dyn_cast<RecordDecl>(TagD.getAs<Decl>())) - Record->addDecl(FD); + Record->addDecl(Context, FD); } } |