diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 20 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 41 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 124 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 58 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 20 | ||||
-rw-r--r-- | clang/lib/Sema/SemaInherit.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 27 | ||||
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 23 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 24 |
14 files changed, 200 insertions, 166 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index a3ddb33eb33..474c1e490e4 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -211,7 +211,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S) { // Add scoped declarations into their context, so that they can be // found later. Declarations without a context won't be inserted // into any context. - CurContext->addDecl(D); + CurContext->addDecl(Context, D); // C++ [basic.scope]p4: // -- exactly one declaration shall declare a class name or @@ -1004,8 +1004,8 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) { bool Sema::InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner, RecordDecl *AnonRecord) { bool Invalid = false; - for (RecordDecl::field_iterator F = AnonRecord->field_begin(), - FEnd = AnonRecord->field_end(); + for (RecordDecl::field_iterator F = AnonRecord->field_begin(Context), + FEnd = AnonRecord->field_end(Context); F != FEnd; ++F) { if ((*F)->getDeclName()) { NamedDecl *PrevDecl = LookupQualifiedName(Owner, (*F)->getDeclName(), @@ -1028,7 +1028,7 @@ bool Sema::InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner, // definition, the members of the anonymous union are // considered to have been defined in the scope in which the // anonymous union is declared. - Owner->makeDeclVisibleInContext(*F); + Owner->makeDeclVisibleInContext(Context, *F); S->AddDecl(DeclPtrTy::make(*F)); IdResolver.AddDecl(*F); } @@ -1094,8 +1094,8 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, // The member-specification of an anonymous union shall only // define non-static data members. [Note: nested types and // functions cannot be declared within an anonymous union. ] - for (DeclContext::decl_iterator Mem = Record->decls_begin(), - MemEnd = Record->decls_end(); + for (DeclContext::decl_iterator Mem = Record->decls_begin(Context), + MemEnd = Record->decls_end(Context); Mem != MemEnd; ++Mem) { if (FieldDecl *FD = dyn_cast<FieldDecl>(*Mem)) { // C++ [class.union]p3: @@ -1183,7 +1183,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, // Add the anonymous struct/union object to the current // context. We'll be referencing this object when we refer to one of // its members. - Owner->addDecl(Anon); + Owner->addDecl(Context, Anon); // Inject the members of the anonymous struct/union into the owning // context and into the identifier resolver chain for name lookup @@ -3473,7 +3473,7 @@ CreateNewDecl: S = getNonFieldDeclScope(S); PushOnScopeChains(New, S); } else { - CurContext->addDecl(New); + CurContext->addDecl(Context, New); } return DeclPtrTy::make(New); @@ -3607,7 +3607,7 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, } else if (II) { PushOnScopeChains(NewFD, S); } else - Record->addDecl(NewFD); + Record->addDecl(Context, NewFD); return NewFD; } @@ -3921,7 +3921,7 @@ void Sema::ActOnFields(Scope* S, ObjCIvarDecl* Ivar = (*IVI); IdentifierInfo *II = Ivar->getIdentifier(); ObjCIvarDecl* prevIvar = - ID->getSuperClass()->lookupInstanceVariable(II); + ID->getSuperClass()->lookupInstanceVariable(Context, II); if (prevIvar) { Diag(Ivar->getLocation(), diag::err_duplicate_member) << II; Diag(prevIvar->getLocation(), diag::note_previous_declaration); diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 7f5909b037f..f3f04f07742 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1178,8 +1178,8 @@ static void HandleTransparentUnionAttr(Decl *d, const AttributeList &Attr, // FIXME: This isn't supposed to be restricted to pointers, but otherwise // we might silently generate incorrect code; see following code - for (RecordDecl::field_iterator Field = RD->field_begin(), - FieldEnd = RD->field_end(); + for (RecordDecl::field_iterator Field = RD->field_begin(S.Context), + FieldEnd = RD->field_end(S.Context); Field != FieldEnd; ++Field) { if (!Field->getType()->isPointerType()) { S.Diag(Attr.getLoc(), diag::warn_transparent_union_nonpointer); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index feb127bcf46..feff707e156 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -633,7 +633,8 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD, // using a qualified name. ] // Look for a member, first. FieldDecl *Member = 0; - DeclContext::lookup_result Result = ClassDecl->lookup(MemberOrBase); + DeclContext::lookup_result Result + = ClassDecl->lookup(Context, MemberOrBase); if (Result.first != Result.second) Member = dyn_cast<FieldDecl>(*Result.first); @@ -772,7 +773,8 @@ namespace { continue; DeclContext::lookup_const_iterator I, E; - for (llvm::tie(I, E) = RD->lookup(VMD->getDeclName()); I != E; ++I) { + for (llvm::tie(I, E) = RD->lookup(Context, VMD->getDeclName()); + I != E; ++I) { if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(*I)) { if (Context.getCanonicalType(MD->getType()) == Context.getCanonicalType(VMD->getType())) { @@ -785,7 +787,8 @@ namespace { } // Finally, add pure virtual methods from this class. - for (RecordDecl::decl_iterator i = RD->decls_begin(), e = RD->decls_end(); + for (RecordDecl::decl_iterator i = RD->decls_begin(Context), + e = RD->decls_end(Context); i != e; ++i) { if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(*i)) { if (MD->isPure()) @@ -863,8 +866,8 @@ namespace { bool VisitDeclContext(const DeclContext *DC) { bool Invalid = false; - for (CXXRecordDecl::decl_iterator I = DC->decls_begin(), - E = DC->decls_end(); I != E; ++I) + for (CXXRecordDecl::decl_iterator I = DC->decls_begin(SemaRef.Context), + E = DC->decls_end(SemaRef.Context); I != E; ++I) Invalid |= Visit(*I); return Invalid; @@ -968,7 +971,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { /*isImplicitlyDeclared=*/true); DefaultCon->setAccess(AS_public); DefaultCon->setImplicit(); - ClassDecl->addDecl(DefaultCon); + ClassDecl->addDecl(Context, DefaultCon); // Notify the class that we've added a constructor. ClassDecl->addedConstructor(Context, DefaultCon); @@ -1003,8 +1006,9 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { // class type M (or array thereof), each such class type // has a copy constructor whose first parameter is of type // const M& or const volatile M&. - for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(); - HasConstCopyConstructor && Field != ClassDecl->field_end(); ++Field) { + for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context); + HasConstCopyConstructor && Field != ClassDecl->field_end(Context); + ++Field) { QualType FieldType = (*Field)->getType(); if (const ArrayType *Array = Context.getAsArrayType(FieldType)) FieldType = Array->getElementType(); @@ -1049,7 +1053,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { CopyConstructor->setParams(Context, &FromParam, 1); ClassDecl->addedConstructor(Context, CopyConstructor); - ClassDecl->addDecl(CopyConstructor); + ClassDecl->addDecl(Context, CopyConstructor); } if (!ClassDecl->hasUserDeclaredCopyAssignment()) { @@ -1083,8 +1087,9 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { // type M (or array thereof), each such class type has a copy // assignment operator whose parameter is of type const M&, // const volatile M& or M. - for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(); - HasConstCopyAssignment && Field != ClassDecl->field_end(); ++Field) { + for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context); + HasConstCopyAssignment && Field != ClassDecl->field_end(Context); + ++Field) { QualType FieldType = (*Field)->getType(); if (const ArrayType *Array = Context.getAsArrayType(FieldType)) FieldType = Array->getElementType(); @@ -1127,7 +1132,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { // Don't call addedAssignmentOperator. There is no way to distinguish an // implicit from an explicit assignment operator. - ClassDecl->addDecl(CopyAssignment); + ClassDecl->addDecl(Context, CopyAssignment); } if (!ClassDecl->hasUserDeclaredDestructor()) { @@ -1146,7 +1151,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { /*isImplicitlyDeclared=*/true); Destructor->setAccess(AS_public); Destructor->setImplicit(); - ClassDecl->addDecl(Destructor); + ClassDecl->addDecl(Context, Destructor); } } @@ -1668,7 +1673,7 @@ void Sema::PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir) { // or translation unit scope. We add UsingDirectiveDecls, into // it's lookup structure. if (DeclContext *Ctx = static_cast<DeclContext*>(S->getEntity())) - Ctx->addDecl(UDir); + Ctx->addDecl(Context, UDir); else // Otherwise it is block-sope. using-directives will affect lookup // only to the end of scope. @@ -1724,7 +1729,7 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S, NamespaceAliasDecl::Create(Context, CurContext, NamespaceLoc, AliasLoc, Alias, IdentLoc, R); - CurContext->addDecl(AliasDecl); + CurContext->addDecl(Context, AliasDecl); return DeclPtrTy::make(AliasDecl); } @@ -1861,7 +1866,7 @@ Sema::PerformInitializationByConstructor(QualType ClassType, = Context.DeclarationNames.getCXXConstructorName( Context.getCanonicalType(ClassType.getUnqualifiedType())); DeclContext::lookup_const_iterator Con, ConEnd; - for (llvm::tie(Con, ConEnd) = ClassDecl->lookup(ConstructorName); + for (llvm::tie(Con, ConEnd) = ClassDecl->lookup(Context, ConstructorName); Con != ConEnd; ++Con) { CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con); if ((Kind == IK_Direct) || @@ -2467,7 +2472,7 @@ Sema::DeclPtrTy Sema::ActOnStartLinkageSpecification(Scope *S, LinkageSpecDecl *D = LinkageSpecDecl::Create(Context, CurContext, LangLoc, Language, LBraceLoc.isValid()); - CurContext->addDecl(D); + CurContext->addDecl(Context, D); PushDeclContext(S, D); return DeclPtrTy::make(D); } @@ -2586,7 +2591,7 @@ Sema::DeclPtrTy Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc, Decl *Decl = StaticAssertDecl::Create(Context, CurContext, AssertLoc, AssertExpr, AssertMessage); - CurContext->addDecl(Decl); + CurContext->addDecl(Context, Decl); return DeclPtrTy::make(Decl); } 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); } } diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index cb7a90fffc6..dda8654b49b 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -58,7 +58,8 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) { if (ObjCImplementationDecl *Impl = dyn_cast<ObjCImplementationDecl>(MD->getParent())) { - MD = Impl->getClassInterface()->getMethod(MD->getSelector(), + MD = Impl->getClassInterface()->getMethod(Context, + MD->getSelector(), MD->isInstanceMethod()); isSilenced |= MD && MD->getAttr<DeprecatedAttr>(); } @@ -449,7 +450,8 @@ Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc, /// getObjectForAnonymousRecordDecl - Retrieve the (unnamed) field or /// variable corresponding to the anonymous union or struct whose type /// is Record. -static Decl *getObjectForAnonymousRecordDecl(RecordDecl *Record) { +static Decl *getObjectForAnonymousRecordDecl(ASTContext &Context, + RecordDecl *Record) { assert(Record->isAnonymousStructOrUnion() && "Record must be an anonymous struct or union!"); @@ -458,8 +460,8 @@ static Decl *getObjectForAnonymousRecordDecl(RecordDecl *Record) { // vector (which itself will be eliminated). DeclGroups might make // this even better. DeclContext *Ctx = Record->getDeclContext(); - for (DeclContext::decl_iterator D = Ctx->decls_begin(), - DEnd = Ctx->decls_end(); + for (DeclContext::decl_iterator D = Ctx->decls_begin(Context), + DEnd = Ctx->decls_end(Context); D != DEnd; ++D) { if (*D == Record) { // The object for the anonymous struct/union directly @@ -495,7 +497,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc, DeclContext *Ctx = Field->getDeclContext(); do { RecordDecl *Record = cast<RecordDecl>(Ctx); - Decl *AnonObject = getObjectForAnonymousRecordDecl(Record); + Decl *AnonObject = getObjectForAnonymousRecordDecl(Context, Record); if (FieldDecl *AnonField = dyn_cast<FieldDecl>(AnonObject)) AnonFields.push_back(AnonField); else { @@ -643,7 +645,8 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, if (D == 0 || D->isDefinedOutsideFunctionOrMethod()) { ObjCInterfaceDecl *IFace = getCurMethodDecl()->getClassInterface(); ObjCInterfaceDecl *ClassDeclared; - if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(II, ClassDeclared)) { + if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(Context, II, + ClassDeclared)) { // Check if referencing a field with __attribute__((deprecated)). if (DiagnoseUseOfDecl(IV, Loc)) return ExprError(); @@ -675,7 +678,8 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, // We should warn if a local variable hides an ivar. ObjCInterfaceDecl *IFace = getCurMethodDecl()->getClassInterface(); ObjCInterfaceDecl *ClassDeclared; - if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(II, ClassDeclared)) { + if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(Context, II, + ClassDeclared)) { if (IV->getAccessControl() != ObjCIvarDecl::Private || IFace == ClassDeclared) Diag(Loc, diag::warn_ivar_use_hidden)<<IV->getDeclName(); @@ -1695,16 +1699,18 @@ CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc, static Decl *FindGetterNameDeclFromProtocolList(const ObjCProtocolDecl*PDecl, IdentifierInfo &Member, - const Selector &Sel) { + const Selector &Sel, + ASTContext &Context) { - if (ObjCPropertyDecl *PD = PDecl->FindPropertyDeclaration(&Member)) + if (ObjCPropertyDecl *PD = PDecl->FindPropertyDeclaration(Context, &Member)) return PD; - if (ObjCMethodDecl *OMD = PDecl->getInstanceMethod(Sel)) + if (ObjCMethodDecl *OMD = PDecl->getInstanceMethod(Context, Sel)) return OMD; for (ObjCProtocolDecl::protocol_iterator I = PDecl->protocol_begin(), E = PDecl->protocol_end(); I != E; ++I) { - if (Decl *D = FindGetterNameDeclFromProtocolList(*I, Member, Sel)) + if (Decl *D = FindGetterNameDeclFromProtocolList(*I, Member, Sel, + Context)) return D; } return 0; @@ -1712,17 +1718,18 @@ static Decl *FindGetterNameDeclFromProtocolList(const ObjCProtocolDecl*PDecl, static Decl *FindGetterNameDecl(const ObjCQualifiedIdType *QIdTy, IdentifierInfo &Member, - const Selector &Sel) { + const Selector &Sel, + ASTContext &Context) { // Check protocols on qualified interfaces. Decl *GDecl = 0; for (ObjCQualifiedIdType::qual_iterator I = QIdTy->qual_begin(), E = QIdTy->qual_end(); I != E; ++I) { - if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(&Member)) { + if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(Context, &Member)) { GDecl = PD; break; } // Also must look for a getter name which uses property syntax. - if (ObjCMethodDecl *OMD = (*I)->getInstanceMethod(Sel)) { + if (ObjCMethodDecl *OMD = (*I)->getInstanceMethod(Context, Sel)) { GDecl = OMD; break; } @@ -1731,7 +1738,7 @@ static Decl *FindGetterNameDecl(const ObjCQualifiedIdType *QIdTy, for (ObjCQualifiedIdType::qual_iterator I = QIdTy->qual_begin(), E = QIdTy->qual_end(); I != E; ++I) { // Search in the protocol-qualifier list of current protocol. - GDecl = FindGetterNameDeclFromProtocolList(*I, Member, Sel); + GDecl = FindGetterNameDeclFromProtocolList(*I, Member, Sel, Context); if (GDecl) return GDecl; } @@ -1875,7 +1882,8 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, // (*Obj).ivar. if (const ObjCInterfaceType *IFTy = BaseType->getAsObjCInterfaceType()) { ObjCInterfaceDecl *ClassDeclared; - if (ObjCIvarDecl *IV = IFTy->getDecl()->lookupInstanceVariable(&Member, + if (ObjCIvarDecl *IV = IFTy->getDecl()->lookupInstanceVariable(Context, + &Member, ClassDeclared)) { // If the decl being referenced had an error, return an error for this // sub-expr without emitting another error, in order to avoid cascading @@ -1937,7 +1945,8 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, ObjCInterfaceDecl *IFace = IFTy->getDecl(); // Search for a declared property first. - if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(&Member)) { + if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(Context, + &Member)) { // Check whether we can reference this property. if (DiagnoseUseOfDecl(PD, MemberLoc)) return ExprError(); @@ -1949,7 +1958,8 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, // Check protocols on qualified interfaces. for (ObjCInterfaceType::qual_iterator I = IFTy->qual_begin(), E = IFTy->qual_end(); I != E; ++I) - if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(&Member)) { + if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(Context, + &Member)) { // Check whether we can reference this property. if (DiagnoseUseOfDecl(PD, MemberLoc)) return ExprError(); @@ -1965,7 +1975,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, // shared with the code in ActOnInstanceMessage. Selector Sel = PP.getSelectorTable().getNullarySelector(&Member); - ObjCMethodDecl *Getter = IFace->lookupInstanceMethod(Sel); + ObjCMethodDecl *Getter = IFace->lookupInstanceMethod(Context, Sel); // If this reference is in an @implementation, check for 'private' methods. if (!Getter) @@ -1988,7 +1998,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, Selector SetterSel = SelectorTable::constructSetterName(PP.getIdentifierTable(), PP.getSelectorTable(), &Member); - ObjCMethodDecl *Setter = IFace->lookupInstanceMethod(SetterSel); + ObjCMethodDecl *Setter = IFace->lookupInstanceMethod(Context, SetterSel); if (!Setter) { // If this reference is in an @implementation, also check for 'private' // methods. @@ -2027,7 +2037,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, if (OpKind == tok::period && (QIdTy = BaseType->getAsObjCQualifiedIdType())) { // Check protocols on qualified interfaces. Selector Sel = PP.getSelectorTable().getNullarySelector(&Member); - if (Decl *PMDecl = FindGetterNameDecl(QIdTy, Member, Sel)) { + if (Decl *PMDecl = FindGetterNameDecl(QIdTy, Member, Sel, Context)) { if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(PMDecl)) { // Check the use of this declaration if (DiagnoseUseOfDecl(PD, MemberLoc)) @@ -2059,7 +2069,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, ObjCInterfaceDecl *IFace = MD->getClassInterface(); ObjCMethodDecl *Getter; // FIXME: need to also look locally in the implementation. - if ((Getter = IFace->lookupClassMethod(Sel))) { + if ((Getter = IFace->lookupClassMethod(Context, Sel))) { // Check the use of this method. if (DiagnoseUseOfDecl(Getter, MemberLoc)) return ExprError(); @@ -2069,7 +2079,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, Selector SetterSel = SelectorTable::constructSetterName(PP.getIdentifierTable(), PP.getSelectorTable(), &Member); - ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel); + ObjCMethodDecl *Setter = IFace->lookupClassMethod(Context, SetterSel); if (!Setter) { // If this reference is in an @implementation, also check for 'private' // methods. @@ -2481,7 +2491,7 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr) { // GCC cast to union extension RecordDecl *RD = castType->getAsRecordType()->getDecl(); RecordDecl::field_iterator Field, FieldEnd; - for (Field = RD->field_begin(), FieldEnd = RD->field_end(); + for (Field = RD->field_begin(Context), FieldEnd = RD->field_end(Context); Field != FieldEnd; ++Field) { if (Context.getCanonicalType(Field->getType()).getUnqualifiedType() == Context.getCanonicalType(castExpr->getType()).getUnqualifiedType()) { diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 361434a0dd9..4a5bfd59ae5 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -454,7 +454,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, bool AllowMissing, FunctionDecl *&Operator) { DeclContext::lookup_iterator Alloc, AllocEnd; - llvm::tie(Alloc, AllocEnd) = Ctx->lookup(Name); + llvm::tie(Alloc, AllocEnd) = Ctx->lookup(Context, Name); if (Alloc == AllocEnd) { if (AllowMissing) return false; @@ -561,7 +561,7 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, // Check if this function is already declared. { DeclContext::lookup_iterator Alloc, AllocEnd; - for (llvm::tie(Alloc, AllocEnd) = GlobalCtx->lookup(Name); + for (llvm::tie(Alloc, AllocEnd) = GlobalCtx->lookup(Context, Name); Alloc != AllocEnd; ++Alloc) { // FIXME: Do we need to check for default arguments here? FunctionDecl *Func = cast<FunctionDecl>(*Alloc); @@ -584,7 +584,7 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, // FIXME: Also add this declaration to the IdentifierResolver, but // make sure it is at the end of the chain to coincide with the // global scope. - ((DeclContext *)TUScope->getEntity())->addDecl(Alloc); + ((DeclContext *)TUScope->getEntity())->addDecl(Context, Alloc); } /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in: diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 54ed709d0f4..54a18ac832a 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -238,7 +238,7 @@ ObjCMethodDecl *Sema::LookupPrivateClassMethod(Selector Sel, // But only in the root. This matches gcc's behaviour and what the // runtime expects. if (!Method && !ClassDecl->getSuperClass()) { - Method = ClassDecl->lookupInstanceMethod(Sel); + Method = ClassDecl->lookupInstanceMethod(Context, Sel); // Look through local category implementations associated // with the root class. if (!Method) @@ -282,7 +282,7 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr( // Search for a declared property first. Selector Sel = PP.getSelectorTable().getNullarySelector(&propertyName); - ObjCMethodDecl *Getter = IFace->lookupClassMethod(Sel); + ObjCMethodDecl *Getter = IFace->lookupClassMethod(Context, Sel); // If this reference is in an @implementation, check for 'private' methods. if (!Getter) @@ -304,7 +304,7 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr( SelectorTable::constructSetterName(PP.getIdentifierTable(), PP.getSelectorTable(), &propertyName); - ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel); + ObjCMethodDecl *Setter = IFace->lookupClassMethod(Context, SetterSel); if (!Setter) { // If this reference is in an @implementation, also check for 'private' // methods. @@ -422,7 +422,7 @@ Sema::ExprResult Sema::ActOnClassMessage( assert(ClassDecl && "missing interface declaration"); ObjCMethodDecl *Method = 0; QualType returnType; - Method = ClassDecl->lookupClassMethod(Sel); + Method = ClassDecl->lookupClassMethod(Context, Sel); // If we have an implementation in scope, check "private" methods. if (!Method) @@ -473,7 +473,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel, // If we have an interface in scope, check 'super' methods. if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) if (ObjCInterfaceDecl *SuperDecl = ClassDecl->getSuperClass()) { - Method = SuperDecl->lookupInstanceMethod(Sel); + Method = SuperDecl->lookupInstanceMethod(Context, Sel); if (!Method) // If we have implementations in scope, check "private" methods. @@ -512,7 +512,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel, if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) { if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) { // First check the public methods in the class interface. - Method = ClassDecl->lookupClassMethod(Sel); + Method = ClassDecl->lookupClassMethod(Context, Sel); if (!Method) Method = LookupPrivateClassMethod(Sel, ClassDecl); @@ -546,10 +546,10 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel, // Search protocols for instance methods. for (unsigned i = 0; i < QIT->getNumProtocols(); i++) { ObjCProtocolDecl *PDecl = QIT->getProtocols(i); - if (PDecl && (Method = PDecl->lookupInstanceMethod(Sel))) + if (PDecl && (Method = PDecl->lookupInstanceMethod(Context, Sel))) break; // Since we aren't supporting "Class<foo>", look for a class method. - if (PDecl && (Method = PDecl->lookupClassMethod(Sel))) + if (PDecl && (Method = PDecl->lookupClassMethod(Context, Sel))) break; } } else if (const ObjCInterfaceType *OCIType = @@ -560,13 +560,13 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel, // FIXME: consider using LookupInstanceMethodInGlobalPool, since it will be // faster than the following method (which can do *many* linear searches). // The idea is to add class info to InstanceMethodPool. - Method = ClassDecl->lookupInstanceMethod(Sel); + Method = ClassDecl->lookupInstanceMethod(Context, Sel); if (!Method) { // Search protocol qualifiers. for (ObjCQualifiedInterfaceType::qual_iterator QI = OCIType->qual_begin(), E = OCIType->qual_end(); QI != E; ++QI) { - if ((Method = (*QI)->lookupInstanceMethod(Sel))) + if ((Method = (*QI)->lookupInstanceMethod(Context, Sel))) break; } } diff --git a/clang/lib/Sema/SemaInherit.cpp b/clang/lib/Sema/SemaInherit.cpp index c01430c9ee5..8239f54d68a 100644 --- a/clang/lib/Sema/SemaInherit.cpp +++ b/clang/lib/Sema/SemaInherit.cpp @@ -179,7 +179,7 @@ bool Sema::LookupInBases(CXXRecordDecl *Class, FoundPathToThisBase = (Context.getCanonicalType(BaseSpec->getType()) == Criteria.Base); } else { - Paths.ScratchPath.Decls = BaseRecord->lookup(Criteria.Name); + Paths.ScratchPath.Decls = BaseRecord->lookup(Context, Criteria.Name); while (Paths.ScratchPath.Decls.first != Paths.ScratchPath.Decls.second) { if (isAcceptableLookupResult(*Paths.ScratchPath.Decls.first, Criteria.NameKind, Criteria.IDNS)) { diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index f8890c389b5..7da1f6bb23f 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -324,8 +324,9 @@ void InitListChecker::FillInValueInitializations(InitListExpr *ILE) { if (const RecordType *RType = ILE->getType()->getAsRecordType()) { unsigned Init = 0, NumInits = ILE->getNumInits(); - for (RecordDecl::field_iterator Field = RType->getDecl()->field_begin(), - FieldEnd = RType->getDecl()->field_end(); + for (RecordDecl::field_iterator + Field = RType->getDecl()->field_begin(SemaRef.Context), + FieldEnd = RType->getDecl()->field_end(SemaRef.Context); Field != FieldEnd; ++Field) { if (Field->isUnnamedBitfield()) continue; @@ -431,8 +432,9 @@ int InitListChecker::numArrayElements(QualType DeclType) { int InitListChecker::numStructUnionElements(QualType DeclType) { RecordDecl *structDecl = DeclType->getAsRecordType()->getDecl(); int InitializableMembers = 0; - for (RecordDecl::field_iterator Field = structDecl->field_begin(), - FieldEnd = structDecl->field_end(); + for (RecordDecl::field_iterator + Field = structDecl->field_begin(SemaRef.Context), + FieldEnd = structDecl->field_end(SemaRef.Context); Field != FieldEnd; ++Field) { if ((*Field)->getIdentifier() || !(*Field)->isBitField()) ++InitializableMembers; @@ -559,7 +561,7 @@ void InitListChecker::CheckListElementTypes(InitListExpr *IList, } else if (DeclType->isAggregateType()) { if (DeclType->isRecordType()) { RecordDecl *RD = DeclType->getAsRecordType()->getDecl(); - CheckStructUnionTypes(IList, DeclType, RD->field_begin(), + CheckStructUnionTypes(IList, DeclType, RD->field_begin(SemaRef.Context), SubobjectIsDesignatorContext, Index, StructuredList, StructuredIndex, TopLevelObject); @@ -927,7 +929,7 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList, if (DeclType->isUnionType() && IList->getNumInits() == 0) { // Value-initialize the first named member of the union. RecordDecl *RD = DeclType->getAsRecordType()->getDecl(); - for (RecordDecl::field_iterator FieldEnd = RD->field_end(); + for (RecordDecl::field_iterator FieldEnd = RD->field_end(SemaRef.Context); Field != FieldEnd; ++Field) { if (Field->getDeclName()) { StructuredList->setInitializedFieldInUnion(*Field); @@ -942,7 +944,7 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList, // because an error should get printed out elsewhere. It might be // worthwhile to skip over the rest of the initializer, though. RecordDecl *RD = DeclType->getAsRecordType()->getDecl(); - RecordDecl::field_iterator FieldEnd = RD->field_end(); + RecordDecl::field_iterator FieldEnd = RD->field_end(SemaRef.Context); bool InitializedSomething = false; while (Index < IList->getNumInits()) { Expr *Init = IList->getInit(Index); @@ -1136,8 +1138,9 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList, // need to compute the field's index. IdentifierInfo *FieldName = D->getFieldName(); unsigned FieldIndex = 0; - RecordDecl::field_iterator Field = RT->getDecl()->field_begin(), - FieldEnd = RT->getDecl()->field_end(); + RecordDecl::field_iterator + Field = RT->getDecl()->field_begin(SemaRef.Context), + FieldEnd = RT->getDecl()->field_end(SemaRef.Context); for (; Field != FieldEnd; ++Field) { if (Field->isUnnamedBitfield()) continue; @@ -1151,7 +1154,8 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList, if (Field == FieldEnd) { // We did not find the field we're looking for. Produce a // suitable diagnostic and return a failure. - DeclContext::lookup_result Lookup = RT->getDecl()->lookup(FieldName); + DeclContext::lookup_result Lookup + = RT->getDecl()->lookup(SemaRef.Context, FieldName); if (Lookup.first == Lookup.second) { // Name lookup didn't find anything. SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_unknown) @@ -1478,7 +1482,8 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index, if (RDecl->isUnion()) NumElements = 1; else - NumElements = std::distance(RDecl->field_begin(), RDecl->field_end()); + NumElements = std::distance(RDecl->field_begin(SemaRef.Context), + RDecl->field_end(SemaRef.Context)); } if (NumElements < NumInits) diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index d85123c8536..0b11d9cf68c 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -57,23 +57,25 @@ struct UsingDirAncestorCompare { /// AddNamespaceUsingDirectives - Adds all UsingDirectiveDecl's to heap UDirs /// (ordered by common ancestors), found in namespace NS, /// including all found (recursively) in their nominated namespaces. -void AddNamespaceUsingDirectives(DeclContext *NS, +void AddNamespaceUsingDirectives(ASTContext &Context, + DeclContext *NS, UsingDirectivesTy &UDirs, NamespaceSet &Visited) { DeclContext::udir_iterator I, End; - for (llvm::tie(I, End) = NS->getUsingDirectives(); I !=End; ++I) { + for (llvm::tie(I, End) = NS->getUsingDirectives(Context); I !=End; ++I) { UDirs.push_back(*I); std::push_heap(UDirs.begin(), UDirs.end(), UsingDirAncestorCompare()); NamespaceDecl *Nominated = (*I)->getNominatedNamespace(); if (Visited.insert(Nominated).second) - AddNamespaceUsingDirectives(Nominated, UDirs, /*ref*/ Visited); + AddNamespaceUsingDirectives(Context, Nominated, UDirs, /*ref*/ Visited); } } /// AddScopeUsingDirectives - Adds all UsingDirectiveDecl's found in Scope S, /// including all found in the namespaces they nominate. -static void AddScopeUsingDirectives(Scope *S, UsingDirectivesTy &UDirs) { +static void AddScopeUsingDirectives(ASTContext &Context, Scope *S, + UsingDirectivesTy &UDirs) { NamespaceSet VisitedNS; if (DeclContext *Ctx = static_cast<DeclContext*>(S->getEntity())) { @@ -81,7 +83,7 @@ static void AddScopeUsingDirectives(Scope *S, UsingDirectivesTy &UDirs) { if (NamespaceDecl *NS = dyn_cast<NamespaceDecl>(Ctx)) VisitedNS.insert(NS); - AddNamespaceUsingDirectives(Ctx, UDirs, /*ref*/ VisitedNS); + AddNamespaceUsingDirectives(Context, Ctx, UDirs, /*ref*/ VisitedNS); } else { Scope::udir_iterator I = S->using_directives_begin(), @@ -95,7 +97,8 @@ static void AddScopeUsingDirectives(Scope *S, UsingDirectivesTy &UDirs) { NamespaceDecl *Nominated = UD->getNominatedNamespace(); if (!VisitedNS.count(Nominated)) { VisitedNS.insert(Nominated); - AddNamespaceUsingDirectives(Nominated, UDirs, /*ref*/ VisitedNS); + AddNamespaceUsingDirectives(Context, Nominated, UDirs, + /*ref*/ VisitedNS); } } } @@ -569,7 +572,7 @@ CppNamespaceLookup(ASTContext &Context, DeclContext *NS, // Perform qualified name lookup into the LookupCtx. DeclContext::lookup_iterator I, E; - for (llvm::tie(I, E) = NS->lookup(Name); I != E; ++I) + for (llvm::tie(I, E) = NS->lookup(Context, Name); I != E; ++I) if (Sema::isAcceptableLookupResult(*I, NameKind, IDNS)) { Results.push_back(Sema::LookupResult::CreateLookupResult(Context, I, E)); break; @@ -682,7 +685,7 @@ Sema::CppLookupName(Scope *S, DeclarationName Name, UsingDirectivesTy UDirs; for (Scope *SC = Initial; SC; SC = SC->getParent()) if (SC->getFlags() & Scope::DeclScope) - AddScopeUsingDirectives(SC, UDirs); + AddScopeUsingDirectives(Context, SC, UDirs); // Sort heapified UsingDirectiveDecls. std::sort_heap(UDirs.begin(), UDirs.end()); @@ -967,7 +970,7 @@ Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name, // Perform qualified name lookup into the LookupCtx. DeclContext::lookup_iterator I, E; - for (llvm::tie(I, E) = LookupCtx->lookup(Name); I != E; ++I) + for (llvm::tie(I, E) = LookupCtx->lookup(Context, Name); I != E; ++I) if (isAcceptableLookupResult(*I, NameKind, IDNS)) return LookupResult::CreateLookupResult(Context, I, E); @@ -1544,7 +1547,7 @@ void Sema::ArgumentDependentLookup(DeclarationName Name, // namespaces even if they are not visible during an ordinary // lookup (11.4). DeclContext::lookup_iterator I, E; - for (llvm::tie(I, E) = (*NS)->lookup(Name); I != E; ++I) { + for (llvm::tie(I, E) = (*NS)->lookup(Context, Name); I != E; ++I) { FunctionDecl *Func = dyn_cast<FunctionDecl>(*I); if (!Func) break; diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 3afd454f1ba..0a12a71bb74 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1334,7 +1334,8 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType, = Context.DeclarationNames.getCXXConstructorName( Context.getCanonicalType(ToType).getUnqualifiedType()); DeclContext::lookup_iterator Con, ConEnd; - for (llvm::tie(Con, ConEnd) = ToRecordDecl->lookup(ConstructorName); + for (llvm::tie(Con, ConEnd) + = ToRecordDecl->lookup(Context, ConstructorName); Con != ConEnd; ++Con) { CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con); if (Constructor->isConvertingConstructor()) @@ -2395,7 +2396,7 @@ void Sema::AddMemberOperatorCandidates(OverloadedOperatorKind Op, // FIXME: Lookup in base classes, too! if (const RecordType *T1Rec = T1->getAsRecordType()) { DeclContext::lookup_const_iterator Oper, OperEnd; - for (llvm::tie(Oper, OperEnd) = T1Rec->getDecl()->lookup(OpName); + for (llvm::tie(Oper, OperEnd) = T1Rec->getDecl()->lookup(Context, OpName); Oper != OperEnd; ++Oper) AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Args[0], Args+1, NumArgs - 1, CandidateSet, @@ -4033,7 +4034,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, OverloadCandidateSet CandidateSet; DeclarationName OpName = Context.DeclarationNames.getCXXOperatorName(OO_Call); DeclContext::lookup_const_iterator Oper, OperEnd; - for (llvm::tie(Oper, OperEnd) = Record->getDecl()->lookup(OpName); + for (llvm::tie(Oper, OperEnd) = Record->getDecl()->lookup(Context, OpName); Oper != OperEnd; ++Oper) AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Object, Args, NumArgs, CandidateSet, /*SuppressUserConversions=*/false); @@ -4234,7 +4235,8 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, const RecordType *BaseRecord = Base->getType()->getAsRecordType(); DeclContext::lookup_const_iterator Oper, OperEnd; - for (llvm::tie(Oper, OperEnd) = BaseRecord->getDecl()->lookup(OpName); + for (llvm::tie(Oper, OperEnd) + = BaseRecord->getDecl()->lookup(Context, OpName); Oper != OperEnd; ++Oper) AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Base, 0, 0, CandidateSet, /*SuppressUserConversions=*/false); diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index d30726c766a..6e6021ae948 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -2097,7 +2097,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK, // Add the specialization into its lexical context, so that it can // be seen when iterating through the list of declarations in that // context. However, specializations are not found by name lookup. - CurContext->addDecl(Specialization); + CurContext->addDecl(Context, Specialization); return DeclPtrTy::make(Specialization); } diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index a041d06bf20..1a67fd12484 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -728,8 +728,9 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation, Invalid = true; llvm::SmallVector<DeclPtrTy, 32> Fields; - for (RecordDecl::decl_iterator Member = Pattern->decls_begin(), - MemberEnd = Pattern->decls_end(); Member != MemberEnd; ++Member) { + for (RecordDecl::decl_iterator Member = Pattern->decls_begin(Context), + MemberEnd = Pattern->decls_end(Context); + Member != MemberEnd; ++Member) { Decl *NewMember = InstantiateDecl(*Member, Instantiation, TemplateArgs, NumTemplateArgs); if (NewMember) { diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index e7210b3431b..4639511023c 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -99,7 +99,7 @@ Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) { if (Invalid) Typedef->setInvalidDecl(); - Owner->addDecl(Typedef); + Owner->addDecl(SemaRef.Context, Typedef); return Typedef; } @@ -127,7 +127,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { if (SemaRef.CheckVariableDeclaration(Var, 0, Redeclaration)) Var->setInvalidDecl(); - Owner->addDecl(Var); + Owner->addDecl(SemaRef.Context, Var); if (D->getInit()) { OwningExprResult Init @@ -187,7 +187,7 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { if (Invalid) Field->setInvalidDecl(); - Owner->addDecl(Field); + Owner->addDecl(SemaRef.Context, Field); } return Field; @@ -214,14 +214,14 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { D->getLocation(), D->getIdentifier(), /*PrevDecl=*/0); Enum->setAccess(D->getAccess()); - Owner->addDecl(Enum); + Owner->addDecl(SemaRef.Context, Enum); Enum->startDefinition(); llvm::SmallVector<Sema::DeclPtrTy, 16> Enumerators; EnumConstantDecl *LastEnumConst = 0; - for (EnumDecl::enumerator_iterator EC = D->enumerator_begin(), - ECEnd = D->enumerator_end(); + for (EnumDecl::enumerator_iterator EC = D->enumerator_begin(SemaRef.Context), + ECEnd = D->enumerator_end(SemaRef.Context); EC != ECEnd; ++EC) { // The specified value for the enumerator. OwningExprResult Value = SemaRef.Owned((Expr *)0); @@ -248,7 +248,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { } if (EnumConst) { - Enum->addDecl(EnumConst); + Enum->addDecl(SemaRef.Context, EnumConst); Enumerators.push_back(Sema::DeclPtrTy::make(EnumConst)); LastEnumConst = EnumConst; } @@ -281,7 +281,7 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) { else Record->setDescribedClassTemplate(D->getDescribedClassTemplate()); - Owner->addDecl(Record); + Owner->addDecl(SemaRef.Context, Record); return Record; } @@ -327,7 +327,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) { Method->setInvalidDecl(); if (!Method->isInvalidDecl() || !PrevDecl) - Owner->addDecl(Method); + Owner->addDecl(SemaRef.Context, Method); return Method; } @@ -371,7 +371,7 @@ Decl *TemplateDeclInstantiator::VisitCXXConstructorDecl(CXXConstructorDecl *D) { Constructor->setInvalidDecl(); if (!Constructor->isInvalidDecl()) - Owner->addDecl(Constructor); + Owner->addDecl(SemaRef.Context, Constructor); return Constructor; } @@ -399,7 +399,7 @@ Decl *TemplateDeclInstantiator::VisitCXXDestructorDecl(CXXDestructorDecl *D) { if (SemaRef.CheckFunctionDeclaration(Destructor, PrevDecl, Redeclaration, /*FIXME:*/OverloadableAttrRequired)) Destructor->setInvalidDecl(); - Owner->addDecl(Destructor); + Owner->addDecl(SemaRef.Context, Destructor); return Destructor; } @@ -429,7 +429,7 @@ Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) { if (SemaRef.CheckFunctionDeclaration(Conversion, PrevDecl, Redeclaration, /*FIXME:*/OverloadableAttrRequired)) Conversion->setInvalidDecl(); - Owner->addDecl(Conversion); + Owner->addDecl(SemaRef.Context, Conversion); return Conversion; } |