diff options
Diffstat (limited to 'clang/lib')
32 files changed, 420 insertions, 334 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index aaec98830e5..e976ccf967a 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -603,7 +603,7 @@ void ASTRecordLayout::LayoutField(const FieldDecl *FD, unsigned FieldNo, } void ASTContext::CollectObjCIvars(const ObjCInterfaceDecl *OI, - llvm::SmallVectorImpl<FieldDecl*> &Fields) const { + llvm::SmallVectorImpl<FieldDecl*> &Fields) { const ObjCInterfaceDecl *SuperClass = OI->getSuperClass(); if (SuperClass) CollectObjCIvars(SuperClass, Fields); @@ -614,8 +614,8 @@ void ASTContext::CollectObjCIvars(const ObjCInterfaceDecl *OI, Fields.push_back(cast<FieldDecl>(IVDecl)); } // look into properties. - for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(), - E = OI->prop_end(); I != E; ++I) { + for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(*this), + E = OI->prop_end(*this); I != E; ++I) { if (ObjCIvarDecl *IV = (*I)->getPropertyIvarDecl()) Fields.push_back(cast<FieldDecl>(IV)); } @@ -648,7 +648,8 @@ const RecordDecl *ASTContext::addRecordToClass(const ObjCInterfaceDecl *D) { /// FIXME! Can do collection of ivars and adding to the record while /// doing it. for (unsigned i = 0, e = RecFields.size(); i != e; ++i) { - RD->addDecl(FieldDecl::Create(*this, RD, + RD->addDecl(*this, + FieldDecl::Create(*this, RD, RecFields[i]->getLocation(), RecFields[i]->getIdentifier(), RecFields[i]->getType(), @@ -682,7 +683,7 @@ ASTContext::getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) { // FIXME. Add actual count of synthesized ivars, instead of count // of properties which is the upper bound, but is safe. unsigned FieldCount = - D->ivar_size() + std::distance(D->prop_begin(), D->prop_end()); + D->ivar_size() + std::distance(D->prop_begin(*this), D->prop_end(*this)); if (ObjCInterfaceDecl *SD = D->getSuperClass()) { FieldCount++; const ASTRecordLayout &SL = getASTObjCInterfaceLayout(SD); @@ -714,8 +715,8 @@ ASTContext::getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) { NewEntry->LayoutField(Ivar, i++, false, StructPacking, *this); } // Also synthesized ivars - for (ObjCInterfaceDecl::prop_iterator I = D->prop_begin(), - E = D->prop_end(); I != E; ++I) { + for (ObjCInterfaceDecl::prop_iterator I = D->prop_begin(*this), + E = D->prop_end(*this); I != E; ++I) { if (ObjCIvarDecl *Ivar = (*I)->getPropertyIvarDecl()) NewEntry->LayoutField(Ivar, i++, false, StructPacking, *this); } @@ -743,7 +744,8 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) { Entry = NewEntry; // FIXME: Avoid linear walk through the fields, if possible. - NewEntry->InitializeLayout(std::distance(D->field_begin(), D->field_end())); + NewEntry->InitializeLayout(std::distance(D->field_begin(*this), + D->field_end(*this))); bool IsUnion = D->isUnion(); unsigned StructPacking = 0; @@ -757,8 +759,8 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) { // Layout each field, for now, just sequentially, respecting alignment. In // the future, this will need to be tweakable by targets. unsigned FieldIdx = 0; - for (RecordDecl::field_iterator Field = D->field_begin(), - FieldEnd = D->field_end(); + for (RecordDecl::field_iterator Field = D->field_begin(*this), + FieldEnd = D->field_end(*this); Field != FieldEnd; (void)++Field, ++FieldIdx) NewEntry->LayoutField(*Field, FieldIdx, IsUnion, StructPacking, *this); @@ -1962,7 +1964,7 @@ QualType ASTContext::getCFConstantStringType() { SourceLocation(), 0, FieldTypes[i], /*BitWidth=*/0, /*Mutable=*/false); - CFConstantStringTypeDecl->addDecl(Field); + CFConstantStringTypeDecl->addDecl(*this, Field); } CFConstantStringTypeDecl->completeDefinition(*this); @@ -1992,7 +1994,7 @@ QualType ASTContext::getObjCFastEnumerationStateType() SourceLocation(), 0, FieldTypes[i], /*BitWidth=*/0, /*Mutable=*/false); - ObjCFastEnumerationStateTypeDecl->addDecl(Field); + ObjCFastEnumerationStateTypeDecl->addDecl(*this, Field); } ObjCFastEnumerationStateTypeDecl->completeDefinition(*this); @@ -2204,7 +2206,7 @@ void ASTContext::getLegacyIntegralTypeEncoding (QualType &PointeeTy) const { } void ASTContext::getObjCEncodingForType(QualType T, std::string& S, - FieldDecl *Field) const { + FieldDecl *Field) { // We follow the behavior of gcc, expanding structures which are // directly pointed to, and expanding embedded structures. Note that // these rules are sufficient to prevent recursive encoding of the @@ -2228,7 +2230,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, bool ExpandStructures, FieldDecl *FD, bool OutermostType, - bool EncodingProperty) const { + bool EncodingProperty) { if (const BuiltinType *BT = T->getAsBuiltinType()) { if (FD && FD->isBitField()) { EncodeBitField(this, S, FD); @@ -2409,8 +2411,8 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, } if (ExpandStructures) { S += '='; - for (RecordDecl::field_iterator Field = RDecl->field_begin(), - FieldEnd = RDecl->field_end(); + for (RecordDecl::field_iterator Field = RDecl->field_begin(*this), + FieldEnd = RDecl->field_end(*this); Field != FieldEnd; ++Field) { if (FD) { S += '"'; diff --git a/clang/lib/AST/Builtins.cpp b/clang/lib/AST/Builtins.cpp index 7eab2679e80..97a40a4dd0b 100644 --- a/clang/lib/AST/Builtins.cpp +++ b/clang/lib/AST/Builtins.cpp @@ -201,7 +201,7 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context, case 'P': { IdentifierInfo *II = &Context.Idents.get("FILE"); DeclContext::lookup_result Lookup - = Context.getTranslationUnitDecl()->lookup(II); + = Context.getTranslationUnitDecl()->lookup(Context, II); if (Lookup.first != Lookup.second && isa<TypeDecl>(*Lookup.first)) { Type = Context.getTypeDeclType(cast<TypeDecl>(*Lookup.first)); break; diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index f3cf7814e52..763998e852e 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -369,7 +369,7 @@ DeclContext::~DeclContext() { } void DeclContext::DestroyDecls(ASTContext &C) { - for (decl_iterator D = decls_begin(); D != decls_end(); ) + for (decl_iterator D = decls_begin(C); D != decls_end(C); ) (*D++)->Destroy(C); } @@ -439,7 +439,15 @@ DeclContext *DeclContext::getNextContext() { } } -void DeclContext::addDecl(Decl *D) { +DeclContext::decl_iterator DeclContext::decls_begin(ASTContext &Context) const { + return decl_iterator(FirstDecl); +} + +DeclContext::decl_iterator DeclContext::decls_end(ASTContext &Context) const { + return decl_iterator(); +} + +void DeclContext::addDecl(ASTContext &Context, Decl *D) { assert(D->getLexicalDeclContext() == this && "Decl inserted into wrong lexical context"); assert(!D->getNextDeclInContext() && D != LastDecl && @@ -453,40 +461,41 @@ void DeclContext::addDecl(Decl *D) { } if (NamedDecl *ND = dyn_cast<NamedDecl>(D)) - ND->getDeclContext()->makeDeclVisibleInContext(ND); + ND->getDeclContext()->makeDeclVisibleInContext(Context, ND); } /// buildLookup - Build the lookup data structure with all of the /// declarations in DCtx (and any other contexts linked to it or /// transparent contexts nested within it). -void DeclContext::buildLookup(DeclContext *DCtx) { +void DeclContext::buildLookup(ASTContext &Context, DeclContext *DCtx) { for (; DCtx; DCtx = DCtx->getNextContext()) { - for (decl_iterator D = DCtx->decls_begin(), DEnd = DCtx->decls_end(); + for (decl_iterator D = DCtx->decls_begin(Context), + DEnd = DCtx->decls_end(Context); D != DEnd; ++D) { // Insert this declaration into the lookup structure if (NamedDecl *ND = dyn_cast<NamedDecl>(*D)) - makeDeclVisibleInContextImpl(ND); + makeDeclVisibleInContextImpl(Context, ND); // If this declaration is itself a transparent declaration context, // add its members (recursively). if (DeclContext *InnerCtx = dyn_cast<DeclContext>(*D)) if (InnerCtx->isTransparentContext()) - buildLookup(InnerCtx->getPrimaryContext()); + buildLookup(Context, InnerCtx->getPrimaryContext()); } } } DeclContext::lookup_result -DeclContext::lookup(DeclarationName Name) { +DeclContext::lookup(ASTContext &Context, DeclarationName Name) { DeclContext *PrimaryContext = getPrimaryContext(); if (PrimaryContext != this) - return PrimaryContext->lookup(Name); + return PrimaryContext->lookup(Context, Name); /// If there is no lookup data structure, build one now by walking /// all of the linked DeclContexts (in declaration order!) and /// inserting their values. if (!LookupPtr) { - buildLookup(this); + buildLookup(Context, this); if (!LookupPtr) return lookup_result(0, 0); @@ -496,12 +505,12 @@ DeclContext::lookup(DeclarationName Name) { StoredDeclsMap::iterator Pos = Map->find(Name); if (Pos == Map->end()) return lookup_result(0, 0); - return Pos->second.getLookupResult(); + return Pos->second.getLookupResult(Context); } DeclContext::lookup_const_result -DeclContext::lookup(DeclarationName Name) const { - return const_cast<DeclContext*>(this)->lookup(Name); +DeclContext::lookup(ASTContext &Context, DeclarationName Name) const { + return const_cast<DeclContext*>(this)->lookup(Context, Name); } DeclContext *DeclContext::getLookupContext() { @@ -520,7 +529,7 @@ DeclContext *DeclContext::getEnclosingNamespaceContext() { return Ctx->getPrimaryContext(); } -void DeclContext::makeDeclVisibleInContext(NamedDecl *D) { +void DeclContext::makeDeclVisibleInContext(ASTContext &Context, NamedDecl *D) { // FIXME: This feels like a hack. Should DeclarationName support // template-ids, or is there a better way to keep specializations // from being visible? @@ -529,7 +538,7 @@ void DeclContext::makeDeclVisibleInContext(NamedDecl *D) { DeclContext *PrimaryContext = getPrimaryContext(); if (PrimaryContext != this) { - PrimaryContext->makeDeclVisibleInContext(D); + PrimaryContext->makeDeclVisibleInContext(Context, D); return; } @@ -537,15 +546,16 @@ void DeclContext::makeDeclVisibleInContext(NamedDecl *D) { // into it. Otherwise, be lazy and don't build that structure until // someone asks for it. if (LookupPtr) - makeDeclVisibleInContextImpl(D); + makeDeclVisibleInContextImpl(Context, D); // If we are a transparent context, insert into our parent context, // too. This operation is recursive. if (isTransparentContext()) - getParent()->makeDeclVisibleInContext(D); + getParent()->makeDeclVisibleInContext(Context, D); } -void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) { +void DeclContext::makeDeclVisibleInContextImpl(ASTContext &Context, + NamedDecl *D) { // Skip unnamed declarations. if (!D->getDeclName()) return; @@ -570,7 +580,7 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) { // If it is possible that this is a redeclaration, check to see if there is // already a decl for which declarationReplaces returns true. If there is // one, just replace it and return. - if (DeclNameEntries.HandleRedeclaration(D)) + if (DeclNameEntries.HandleRedeclaration(Context, D)) return; // Put this declaration into the appropriate slot. @@ -579,9 +589,9 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) { /// Returns iterator range [First, Last) of UsingDirectiveDecls stored within /// this context. -DeclContext::udir_iterator_range DeclContext::getUsingDirectives() const { - lookup_const_result Result = lookup(UsingDirectiveDecl::getName()); +DeclContext::udir_iterator_range +DeclContext::getUsingDirectives(ASTContext &Context) const { + lookup_const_result Result = lookup(Context, UsingDirectiveDecl::getName()); return udir_iterator_range(reinterpret_cast<udir_iterator>(Result.first), reinterpret_cast<udir_iterator>(Result.second)); } - diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 0fd83efa20a..ffc35fe1f74 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -70,7 +70,7 @@ bool CXXRecordDecl::hasConstCopyConstructor(ASTContext &Context) const { Context.getCanonicalType(ClassType)); unsigned TypeQuals; DeclContext::lookup_const_iterator Con, ConEnd; - for (llvm::tie(Con, ConEnd) = this->lookup(ConstructorName); + for (llvm::tie(Con, ConEnd) = this->lookup(Context, ConstructorName); Con != ConEnd; ++Con) { if (cast<CXXConstructorDecl>(*Con)->isCopyConstructor(Context, TypeQuals) && (TypeQuals & QualType::Const) != 0) @@ -86,7 +86,7 @@ bool CXXRecordDecl::hasConstCopyAssignment(ASTContext &Context) const { DeclarationName OpName =Context.DeclarationNames.getCXXOperatorName(OO_Equal); DeclContext::lookup_const_iterator Op, OpEnd; - for (llvm::tie(Op, OpEnd) = this->lookup(OpName); + for (llvm::tie(Op, OpEnd) = this->lookup(Context, OpName); Op != OpEnd; ++Op) { // C++ [class.copy]p9: // A user-declared copy assignment operator is a non-static non-template diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index cd1b979dcb0..4bc7cd461cb 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -43,7 +43,8 @@ void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) { //===----------------------------------------------------------------------===// // Get the local instance method declared in this interface. -ObjCMethodDecl *ObjCContainerDecl::getInstanceMethod(Selector Sel) const { +ObjCMethodDecl * +ObjCContainerDecl::getInstanceMethod(ASTContext &Context, Selector Sel) const { // Since instance & class methods can have the same name, the loop below // ensures we get the correct method. // @@ -53,7 +54,7 @@ ObjCMethodDecl *ObjCContainerDecl::getInstanceMethod(Selector Sel) const { // @end // lookup_const_iterator Meth, MethEnd; - for (llvm::tie(Meth, MethEnd) = lookup(Sel); + for (llvm::tie(Meth, MethEnd) = lookup(Context, Sel); Meth != MethEnd; ++Meth) { ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth); if (MD && MD->isInstanceMethod()) @@ -63,7 +64,8 @@ ObjCMethodDecl *ObjCContainerDecl::getInstanceMethod(Selector Sel) const { } // Get the local class method declared in this interface. -ObjCMethodDecl *ObjCContainerDecl::getClassMethod(Selector Sel) const { +ObjCMethodDecl * +ObjCContainerDecl::getClassMethod(ASTContext &Context, Selector Sel) const { // Since instance & class methods can have the same name, the loop below // ensures we get the correct method. // @@ -73,7 +75,7 @@ ObjCMethodDecl *ObjCContainerDecl::getClassMethod(Selector Sel) const { // @end // lookup_const_iterator Meth, MethEnd; - for (llvm::tie(Meth, MethEnd) = lookup(Sel); + for (llvm::tie(Meth, MethEnd) = lookup(Context, Sel); Meth != MethEnd; ++Meth) { ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth); if (MD && MD->isClassMethod()) @@ -87,8 +89,10 @@ ObjCMethodDecl *ObjCContainerDecl::getClassMethod(Selector Sel) const { /// FIXME: Convert to DeclContext lookup... /// ObjCPropertyDecl * -ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { - for (prop_iterator I = prop_begin(), E = prop_end(); I != E; ++I) +ObjCContainerDecl::FindPropertyDeclaration(ASTContext &Context, + IdentifierInfo *PropertyId) const { + for (prop_iterator I = prop_begin(Context), E = prop_end(Context); + I != E; ++I) if ((*I)->getIdentifier() == PropertyId) return *I; @@ -96,7 +100,8 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { if (PID) { for (ObjCProtocolDecl::protocol_iterator I = PID->protocol_begin(), E = PID->protocol_end(); I != E; ++I) - if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId)) + if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(Context, + PropertyId)) return P; } @@ -104,22 +109,26 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { // Look through categories. for (ObjCCategoryDecl *Category = OID->getCategoryList(); Category; Category = Category->getNextClassCategory()) { - if (ObjCPropertyDecl *P = Category->FindPropertyDeclaration(PropertyId)) + if (ObjCPropertyDecl *P = Category->FindPropertyDeclaration(Context, + PropertyId)) return P; } // Look through protocols. for (ObjCInterfaceDecl::protocol_iterator I = OID->protocol_begin(), E = OID->protocol_end(); I != E; ++I) { - if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId)) + if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(Context, + PropertyId)) return P; } if (OID->getSuperClass()) - return OID->getSuperClass()->FindPropertyDeclaration(PropertyId); + return OID->getSuperClass()->FindPropertyDeclaration(Context, + PropertyId); } else if (const ObjCCategoryDecl *OCD = dyn_cast<ObjCCategoryDecl>(this)) { // Look through protocols. for (ObjCInterfaceDecl::protocol_iterator I = OCD->protocol_begin(), E = OCD->protocol_end(); I != E; ++I) { - if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId)) + if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(Context, + PropertyId)) return P; } } @@ -127,7 +136,7 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { } ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable( - IdentifierInfo *ID, ObjCInterfaceDecl *&clsDeclared) { + ASTContext &Context, IdentifierInfo *ID, ObjCInterfaceDecl *&clsDeclared) { ObjCInterfaceDecl* ClassDecl = this; while (ClassDecl != NULL) { for (ivar_iterator I = ClassDecl->ivar_begin(), E = ClassDecl->ivar_end(); @@ -138,8 +147,8 @@ ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable( } } // look into properties. - for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(), - E = ClassDecl->prop_end(); I != E; ++I) { + for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(Context), + E = ClassDecl->prop_end(Context); I != E; ++I) { ObjCPropertyDecl *PDecl = (*I); if (ObjCIvarDecl *IV = PDecl->getPropertyIvarDecl()) if (IV->getIdentifier() == ID) { @@ -154,12 +163,13 @@ ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable( /// lookupInstanceMethod - This method returns an instance method by looking in /// the class, its categories, and its super classes (using a linear search). -ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(Selector Sel) { +ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(ASTContext &Context, + Selector Sel) { ObjCInterfaceDecl* ClassDecl = this; ObjCMethodDecl *MethodDecl = 0; while (ClassDecl != NULL) { - if ((MethodDecl = ClassDecl->getInstanceMethod(Sel))) + if ((MethodDecl = ClassDecl->getInstanceMethod(Context, Sel))) return MethodDecl; // Didn't find one yet - look through protocols. @@ -167,13 +177,13 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(Selector Sel) { ClassDecl->getReferencedProtocols(); for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(), E = Protocols.end(); I != E; ++I) - if ((MethodDecl = (*I)->lookupInstanceMethod(Sel))) + if ((MethodDecl = (*I)->lookupInstanceMethod(Context, Sel))) return MethodDecl; // Didn't find one yet - now look through categories. ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList(); while (CatDecl) { - if ((MethodDecl = CatDecl->getInstanceMethod(Sel))) + if ((MethodDecl = CatDecl->getInstanceMethod(Context, Sel))) return MethodDecl; // Didn't find one yet - look through protocols. @@ -181,7 +191,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(Selector Sel) { CatDecl->getReferencedProtocols(); for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(), E = Protocols.end(); I != E; ++I) - if ((MethodDecl = (*I)->lookupInstanceMethod(Sel))) + if ((MethodDecl = (*I)->lookupInstanceMethod(Context, Sel))) return MethodDecl; CatDecl = CatDecl->getNextClassCategory(); } @@ -192,24 +202,25 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(Selector Sel) { // lookupClassMethod - This method returns a class method by looking in the // class, its categories, and its super classes (using a linear search). -ObjCMethodDecl *ObjCInterfaceDecl::lookupClassMethod(Selector Sel) { +ObjCMethodDecl *ObjCInterfaceDecl::lookupClassMethod(ASTContext &Context, + Selector Sel) { ObjCInterfaceDecl* ClassDecl = this; ObjCMethodDecl *MethodDecl = 0; while (ClassDecl != NULL) { - if ((MethodDecl = ClassDecl->getClassMethod(Sel))) + if ((MethodDecl = ClassDecl->getClassMethod(Context, Sel))) return MethodDecl; // Didn't find one yet - look through protocols. for (ObjCInterfaceDecl::protocol_iterator I = ClassDecl->protocol_begin(), E = ClassDecl->protocol_end(); I != E; ++I) - if ((MethodDecl = (*I)->lookupClassMethod(Sel))) + if ((MethodDecl = (*I)->lookupClassMethod(Context, Sel))) return MethodDecl; // Didn't find one yet - now look through categories. ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList(); while (CatDecl) { - if ((MethodDecl = CatDecl->getClassMethod(Sel))) + if ((MethodDecl = CatDecl->getClassMethod(Context, Sel))) return MethodDecl; // Didn't find one yet - look through protocols. @@ -217,7 +228,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupClassMethod(Selector Sel) { CatDecl->getReferencedProtocols(); for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(), E = Protocols.end(); I != E; ++I) - if ((MethodDecl = (*I)->lookupClassMethod(Sel))) + if ((MethodDecl = (*I)->lookupClassMethod(Context, Sel))) return MethodDecl; CatDecl = CatDecl->getNextClassCategory(); } @@ -372,7 +383,7 @@ FieldDecl *ObjCInterfaceDecl::lookupFieldDeclForIvar(ASTContext &Context, const RecordDecl *RecordForDecl = Context.addRecordToClass(this); assert(RecordForDecl && "lookupFieldDeclForIvar no storage for class"); DeclContext::lookup_const_result Lookup = - RecordForDecl->lookup(IVar->getDeclName()); + RecordForDecl->lookup(Context, IVar->getDeclName()); assert((Lookup.first != Lookup.second) && "field decl not found"); return cast<FieldDecl>(*Lookup.first); } @@ -434,28 +445,30 @@ ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) { // lookupInstanceMethod - Lookup a instance method in the protocol and protocols // it inherited. -ObjCMethodDecl *ObjCProtocolDecl::lookupInstanceMethod(Selector Sel) { +ObjCMethodDecl *ObjCProtocolDecl::lookupInstanceMethod(ASTContext &Context, + Selector Sel) { ObjCMethodDecl *MethodDecl = NULL; - if ((MethodDecl = getInstanceMethod(Sel))) + if ((MethodDecl = getInstanceMethod(Context, Sel))) return MethodDecl; for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I) - if ((MethodDecl = (*I)->lookupInstanceMethod(Sel))) + if ((MethodDecl = (*I)->lookupInstanceMethod(Context, Sel))) return MethodDecl; return NULL; } // lookupInstanceMethod - Lookup a class method in the protocol and protocols // it inherited. -ObjCMethodDecl *ObjCProtocolDecl::lookupClassMethod(Selector Sel) { +ObjCMethodDecl *ObjCProtocolDecl::lookupClassMethod(ASTContext &Context, + Selector Sel) { ObjCMethodDecl *MethodDecl = NULL; - if ((MethodDecl = getClassMethod(Sel))) + if ((MethodDecl = getClassMethod(Context, Sel))) return MethodDecl; for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I) - if ((MethodDecl = (*I)->lookupClassMethod(Sel))) + if ((MethodDecl = (*I)->lookupClassMethod(Context, Sel))) return MethodDecl; return NULL; } diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 645811319a4..643e066c7b4 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -213,8 +213,8 @@ APValue LValueExprEvaluator::VisitMemberExpr(MemberExpr *E) { // FIXME: This is linear time. unsigned i = 0; - for (RecordDecl::field_iterator Field = RD->field_begin(), - FieldEnd = RD->field_end(); + for (RecordDecl::field_iterator Field = RD->field_begin(Info.Ctx), + FieldEnd = RD->field_end(Info.Ctx); Field != FieldEnd; (void)++Field, ++i) { if (*Field == FD) break; diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index cd0e8822a8a..b55bddfed09 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -148,7 +148,11 @@ void StmtPrinter::PrintRawDecl(Decl *D) { if (RecordDecl *RD = dyn_cast<RecordDecl>(TD)) { OS << "{\n"; IndentLevel += 1; - for (RecordDecl::field_iterator i = RD->field_begin(); i != RD->field_end(); ++i) { + // FIXME: The context passed to field_begin/field_end should + // never be NULL! + ASTContext *Context = 0; + for (RecordDecl::field_iterator i = RD->field_begin(*Context); + i != RD->field_end(*Context); ++i) { PrintFieldDecl(*i); IndentLevel -= 1; } diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp index 267fc0be1a2..0a68ee49de2 100644 --- a/clang/lib/Analysis/CFRefCount.cpp +++ b/clang/lib/Analysis/CFRefCount.cpp @@ -1779,8 +1779,8 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst, MemRegionManager &MRMgr = state.getManager().getRegionManager(); // Iterate through the fields and construct new symbols. - for (RecordDecl::field_iterator FI=RD->field_begin(), - FE=RD->field_end(); FI!=FE; ++FI) { + for (RecordDecl::field_iterator FI=RD->field_begin(Ctx), + FE=RD->field_end(Ctx); FI!=FE; ++FI) { // For now just handle scalar fields. FieldDecl *FD = *FI; diff --git a/clang/lib/Analysis/CheckObjCInstMethSignature.cpp b/clang/lib/Analysis/CheckObjCInstMethSignature.cpp index a59ed884d49..97e77cc50da 100644 --- a/clang/lib/Analysis/CheckObjCInstMethSignature.cpp +++ b/clang/lib/Analysis/CheckObjCInstMethSignature.cpp @@ -97,8 +97,8 @@ void clang::CheckObjCInstMethSignature(ObjCImplementationDecl* ID, ASTContext& Ctx = BR.getContext(); while (C && NumMethods) { - for (ObjCInterfaceDecl::instmeth_iterator I=C->instmeth_begin(), - E=C->instmeth_end(); I!=E; ++I) { + for (ObjCInterfaceDecl::instmeth_iterator I=C->instmeth_begin(Ctx), + E=C->instmeth_end(Ctx); I!=E; ++I) { ObjCMethodDecl* M = *I; Selector S = M->getSelector(); diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index a1267928063..5e60363573c 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/lib/Analysis/RegionStore.cpp @@ -814,7 +814,8 @@ SVal RegionStoreManager::RetrieveStruct(const GRState* St,const TypedRegion* R){ llvm::ImmutableList<SVal> StructVal = getBasicVals().getEmptySValList(); - std::vector<FieldDecl *> Fields(RD->field_begin(), RD->field_end()); + std::vector<FieldDecl *> Fields(RD->field_begin(getContext()), + RD->field_end(getContext())); for (std::vector<FieldDecl *>::reverse_iterator Field = Fields.rbegin(), FieldEnd = Fields.rend(); @@ -1166,7 +1167,8 @@ RegionStoreManager::BindStruct(const GRState* St, const TypedRegion* R, SVal V){ nonloc::CompoundVal& CV = cast<nonloc::CompoundVal>(V); nonloc::CompoundVal::iterator VI = CV.begin(), VE = CV.end(); - RecordDecl::field_iterator FI = RD->field_begin(), FE = RD->field_end(); + RecordDecl::field_iterator FI = RD->field_begin(getContext()), + FE = RD->field_end(getContext()); for (; FI != FE; ++FI, ++VI) { diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 2edf3bd104a..f3021dce43c 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -160,17 +160,17 @@ void ABIArgInfo::dump() const { /// isEmptyRecord - Return true iff a structure has no non-empty /// members. Note that a structure with a flexible array member is not /// considered empty. -static bool isEmptyRecord(QualType T) { +static bool isEmptyRecord(ASTContext &Context, QualType T) { const RecordType *RT = T->getAsRecordType(); if (!RT) return 0; const RecordDecl *RD = RT->getDecl(); if (RD->hasFlexibleArrayMember()) return false; - for (RecordDecl::field_iterator i = RD->field_begin(), - e = RD->field_end(); i != e; ++i) { + for (RecordDecl::field_iterator i = RD->field_begin(Context), + e = RD->field_end(Context); i != e; ++i) { const FieldDecl *FD = *i; - if (!isEmptyRecord(FD->getType())) + if (!isEmptyRecord(Context, FD->getType())) return false; } return true; @@ -194,8 +194,8 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) { return 0; const Type *Found = 0; - for (RecordDecl::field_iterator i = RD->field_begin(), - e = RD->field_end(); i != e; ++i) { + for (RecordDecl::field_iterator i = RD->field_begin(Context), + e = RD->field_end(Context); i != e; ++i) { const FieldDecl *FD = *i; QualType FT = FD->getType(); @@ -204,7 +204,7 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) { if (AT->getSize().getZExtValue() == 1) FT = AT->getElementType(); - if (isEmptyRecord(FT)) { + if (isEmptyRecord(Context, FT)) { // Ignore } else if (Found) { return 0; @@ -230,8 +230,8 @@ static bool is32Or64BitBasicType(QualType Ty, ASTContext &Context) { static bool areAllFields32Or64BitBasicType(const RecordDecl *RD, ASTContext &Context) { - for (RecordDecl::field_iterator i = RD->field_begin(), - e = RD->field_end(); i != e; ++i) { + for (RecordDecl::field_iterator i = RD->field_begin(Context), + e = RD->field_end(Context); i != e; ++i) { const FieldDecl *FD = *i; if (!is32Or64BitBasicType(FD->getType(), Context)) @@ -273,6 +273,7 @@ class DefaultABIInfo : public ABIInfo { /// X86_32ABIInfo - The X86-32 ABI information. class X86_32ABIInfo : public ABIInfo { + ASTContext &Context; bool IsDarwin; static bool isRegisterSize(unsigned Size) { @@ -298,7 +299,8 @@ public: virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty, CodeGenFunction &CGF) const; - X86_32ABIInfo(bool d) : ABIInfo(), IsDarwin(d) {} + X86_32ABIInfo(ASTContext &Context, bool d) + : ABIInfo(), Context(Context), IsDarwin(d) {} }; } @@ -336,8 +338,8 @@ bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty, // Structure types are passed in register if all fields would be // passed in a register. - for (RecordDecl::field_iterator i = RT->getDecl()->field_begin(), - e = RT->getDecl()->field_end(); i != e; ++i) { + for (RecordDecl::field_iterator i = RT->getDecl()->field_begin(Context), + e = RT->getDecl()->field_end(Context); i != e; ++i) { const FieldDecl *FD = *i; // FIXME: Reject bitfields wholesale for now; this is incorrect. @@ -345,7 +347,7 @@ bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty, return false; // Empty structures are ignored. - if (isEmptyRecord(FD->getType())) + if (isEmptyRecord(Context, FD->getType())) continue; // Check fields recursively. @@ -756,8 +758,8 @@ void X86_64ABIInfo::classify(QualType Ty, // Reset Lo class, this will be recomputed. Current = NoClass; unsigned idx = 0; - for (RecordDecl::field_iterator i = RD->field_begin(), - e = RD->field_end(); i != e; ++i, ++idx) { + for (RecordDecl::field_iterator i = RD->field_begin(Context), + e = RD->field_end(Context); i != e; ++i, ++idx) { uint64_t Offset = OffsetBase + Layout.getFieldOffset(idx); bool BitField = i->isBitField(); @@ -1391,7 +1393,7 @@ const ABIInfo &CodeGenTypes::getABIInfo() const { bool IsDarwin = strstr(getContext().Target.getTargetTriple(), "darwin"); switch (getContext().Target.getPointerWidth(0)) { case 32: - return *(TheABIInfo = new X86_32ABIInfo(IsDarwin)); + return *(TheABIInfo = new X86_32ABIInfo(Context, IsDarwin)); case 64: return *(TheABIInfo = new X86_64ABIInfo()); } @@ -1424,8 +1426,8 @@ void CodeGenTypes::GetExpandedTypes(QualType Ty, assert(!RD->hasFlexibleArrayMember() && "Cannot expand structure with flexible array."); - for (RecordDecl::field_iterator i = RD->field_begin(), - e = RD->field_end(); i != e; ++i) { + for (RecordDecl::field_iterator i = RD->field_begin(Context), + e = RD->field_end(Context); i != e; ++i) { const FieldDecl *FD = *i; assert(!FD->isBitField() && "Cannot expand structure with bit-field members."); @@ -1449,8 +1451,8 @@ CodeGenFunction::ExpandTypeFromArgs(QualType Ty, LValue LV, assert(LV.isSimple() && "Unexpected non-simple lvalue during struct expansion."); llvm::Value *Addr = LV.getAddress(); - for (RecordDecl::field_iterator i = RD->field_begin(), - e = RD->field_end(); i != e; ++i) { + for (RecordDecl::field_iterator i = RD->field_begin(getContext()), + e = RD->field_end(getContext()); i != e; ++i) { FieldDecl *FD = *i; QualType FT = FD->getType(); @@ -1476,8 +1478,8 @@ CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV, RecordDecl *RD = RT->getDecl(); assert(RV.isAggregate() && "Unexpected rvalue during struct expansion"); llvm::Value *Addr = RV.getAggregateAddr(); - for (RecordDecl::field_iterator i = RD->field_begin(), - e = RD->field_end(); i != e; ++i) { + for (RecordDecl::field_iterator i = RD->field_begin(getContext()), + e = RD->field_end(getContext()); i != e; ++i) { FieldDecl *FD = *i; QualType FT = FD->getType(); diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 0d13299574b..f2fc90c6cfb 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -269,8 +269,8 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, const ASTRecordLayout &RL = M->getContext().getASTRecordLayout(Decl); unsigned FieldNo = 0; - for (RecordDecl::field_iterator I = Decl->field_begin(), - E = Decl->field_end(); + for (RecordDecl::field_iterator I = Decl->field_begin(M->getContext()), + E = Decl->field_end(M->getContext()); I != E; ++I, ++FieldNo) { FieldDecl *Field = *I; llvm::DIType FieldTy = getOrCreateType(Field->getType(), Unit); @@ -450,8 +450,9 @@ llvm::DIType CGDebugInfo::CreateType(const EnumType *Ty, llvm::SmallVector<llvm::DIDescriptor, 32> Enumerators; // Create DIEnumerator elements for each enumerator. - for (EnumDecl::enumerator_iterator Enum = Decl->enumerator_begin(), - EnumEnd = Decl->enumerator_end(); + for (EnumDecl::enumerator_iterator + Enum = Decl->enumerator_begin(M->getContext()), + EnumEnd = Decl->enumerator_end(M->getContext()); Enum != EnumEnd; ++Enum) { Enumerators.push_back(DebugFactory.CreateEnumerator(Enum->getNameAsString(), Enum->getInitVal().getZExtValue())); diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 095e2240cf6..3b1580cc136 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -133,7 +133,9 @@ void AggExprEmitter::VisitCStyleCastExpr(CStyleCastExpr *E) { // GCC union extension if (E->getType()->isUnionType()) { RecordDecl *SD = E->getType()->getAsRecordType()->getDecl(); - LValue FieldLoc = CGF.EmitLValueForField(DestPtr, *SD->field_begin(), true, 0); + LValue FieldLoc = CGF.EmitLValueForField(DestPtr, + *SD->field_begin(CGF.getContext()), + true, 0); EmitInitializationToLValue(E->getSubExpr(), FieldLoc); return; } @@ -398,8 +400,8 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) { #ifndef NDEBUG // Make sure that it's really an empty and not a failure of // semantic analysis. - for (RecordDecl::field_iterator Field = SD->field_begin(), - FieldEnd = SD->field_end(); + for (RecordDecl::field_iterator Field = SD->field_begin(CGF.getContext()), + FieldEnd = SD->field_end(CGF.getContext()); Field != FieldEnd; ++Field) assert(Field->isUnnamedBitfield() && "Only unnamed bitfields allowed"); #endif @@ -423,8 +425,8 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) { // Here we iterate over the fields; this makes it simpler to both // default-initialize fields and skip over unnamed fields. - for (RecordDecl::field_iterator Field = SD->field_begin(), - FieldEnd = SD->field_end(); + for (RecordDecl::field_iterator Field = SD->field_begin(CGF.getContext()), + FieldEnd = SD->field_end(CGF.getContext()); Field != FieldEnd; ++Field) { // We're done once we hit the flexible array member if (Field->getType()->isIncompleteArrayType()) diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 35b3a3750a3..c5f22023d37 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -196,8 +196,8 @@ public: unsigned EltNo = 0; // Element no in ILE int FieldNo = 0; // Field no in RecordDecl bool RewriteType = false; - for (RecordDecl::field_iterator Field = RD->field_begin(), - FieldEnd = RD->field_end(); + for (RecordDecl::field_iterator Field = RD->field_begin(CGM.getContext()), + FieldEnd = RD->field_end(CGM.getContext()); EltNo < ILE->getNumInits() && Field != FieldEnd; ++Field) { FieldNo++; if (!Field->getIdentifier()) @@ -267,8 +267,8 @@ public: // Make sure that it's really an empty and not a failure of // semantic analysis. RecordDecl *RD = ILE->getType()->getAsRecordType()->getDecl(); - for (RecordDecl::field_iterator Field = RD->field_begin(), - FieldEnd = RD->field_end(); + for (RecordDecl::field_iterator Field = RD->field_begin(CGM.getContext()), + FieldEnd = RD->field_end(CGM.getContext()); Field != FieldEnd; ++Field) assert(Field->isUnnamedBitfield() && "Only unnamed bitfields allowed"); #endif diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index fc77c805f42..cd94290000d 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -618,8 +618,8 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) { Protocols.push_back((*PI)->getNameAsString()); llvm::SmallVector<llvm::Constant*, 16> InstanceMethodNames; llvm::SmallVector<llvm::Constant*, 16> InstanceMethodTypes; - for (ObjCProtocolDecl::instmeth_iterator iter = PD->instmeth_begin(), - E = PD->instmeth_end(); iter != E; iter++) { + for (ObjCProtocolDecl::instmeth_iterator iter = PD->instmeth_begin(Context), + E = PD->instmeth_end(Context); iter != E; iter++) { std::string TypeStr; Context.getObjCEncodingForMethodDecl(*iter, TypeStr); InstanceMethodNames.push_back( @@ -629,8 +629,9 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) { // Collect information about class methods: llvm::SmallVector<llvm::Constant*, 16> ClassMethodNames; llvm::SmallVector<llvm::Constant*, 16> ClassMethodTypes; - for (ObjCProtocolDecl::classmeth_iterator iter = PD->classmeth_begin(), - endIter = PD->classmeth_end() ; iter != endIter ; iter++) { + for (ObjCProtocolDecl::classmeth_iterator + iter = PD->classmeth_begin(Context), + endIter = PD->classmeth_end(Context) ; iter != endIter ; iter++) { std::string TypeStr; Context.getObjCEncodingForMethodDecl((*iter),TypeStr); ClassMethodNames.push_back( diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 116d8b010fe..a06959f1de7 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -1100,8 +1100,9 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) { // Construct method lists. std::vector<llvm::Constant*> InstanceMethods, ClassMethods; std::vector<llvm::Constant*> OptInstanceMethods, OptClassMethods; - for (ObjCProtocolDecl::instmeth_iterator i = PD->instmeth_begin(), - e = PD->instmeth_end(); i != e; ++i) { + for (ObjCProtocolDecl::instmeth_iterator + i = PD->instmeth_begin(CGM.getContext()), + e = PD->instmeth_end(CGM.getContext()); i != e; ++i) { ObjCMethodDecl *MD = *i; llvm::Constant *C = GetMethodDescriptionConstant(MD); if (MD->getImplementationControl() == ObjCMethodDecl::Optional) { @@ -1111,8 +1112,9 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) { } } - for (ObjCProtocolDecl::classmeth_iterator i = PD->classmeth_begin(), - e = PD->classmeth_end(); i != e; ++i) { + for (ObjCProtocolDecl::classmeth_iterator + i = PD->classmeth_begin(CGM.getContext()), + e = PD->classmeth_end(CGM.getContext()); i != e; ++i) { ObjCMethodDecl *MD = *i; llvm::Constant *C = GetMethodDescriptionConstant(MD); if (MD->getImplementationControl() == ObjCMethodDecl::Optional) { @@ -1286,8 +1288,8 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(const std::string &Name, const ObjCContainerDecl *OCD, const ObjCCommonTypesHelper &ObjCTypes) { std::vector<llvm::Constant*> Properties, Prop(2); - for (ObjCContainerDecl::prop_iterator I = OCD->prop_begin(), - E = OCD->prop_end(); I != E; ++I) { + for (ObjCContainerDecl::prop_iterator I = OCD->prop_begin(CGM.getContext()), + E = OCD->prop_end(CGM.getContext()); I != E; ++I) { const ObjCPropertyDecl *PD = *I; Prop[0] = GetPropertyName(PD->getIdentifier()); Prop[1] = GetPropertyTypeString(PD, Container); @@ -1691,19 +1693,20 @@ CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID) { /// countInheritedIvars - count number of ivars in class and its super class(s) /// -static int countInheritedIvars(const ObjCInterfaceDecl *OI) { +static int countInheritedIvars(const ObjCInterfaceDecl *OI, + ASTContext &Context) { int count = 0; if (!OI) return 0; const ObjCInterfaceDecl *SuperClass = OI->getSuperClass(); if (SuperClass) - count += countInheritedIvars(SuperClass); + count += countInheritedIvars(SuperClass, Context); for (ObjCInterfaceDecl::ivar_iterator I = OI->ivar_begin(), E = OI->ivar_end(); I != E; ++I) ++count; // look into properties. - for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(), - E = OI->prop_end(); I != E; ++I) { + for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(Context), + E = OI->prop_end(Context); I != E; ++I) { if ((*I)->getPropertyIvarDecl()) ++count; } @@ -1719,7 +1722,8 @@ static int countInheritedIvars(const ObjCInterfaceDecl *OI) { /// static const ObjCInterfaceDecl *getInterfaceDeclForIvar( const ObjCInterfaceDecl *OI, - const ObjCIvarDecl *IVD) { + const ObjCIvarDecl *IVD, + ASTContext &Context) { if (!OI) return 0; assert(isa<ObjCInterfaceDecl>(OI) && "OI is not an interface"); @@ -1728,14 +1732,14 @@ static const ObjCInterfaceDecl *getInterfaceDeclForIvar( if ((*I)->getIdentifier() == IVD->getIdentifier()) return OI; // look into properties. - for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(), - E = OI->prop_end(); I != E; ++I) { + for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(Context), + E = OI->prop_end(Context); I != E; ++I) { ObjCPropertyDecl *PDecl = (*I); if (ObjCIvarDecl *IV = PDecl->getPropertyIvarDecl()) if (IV->getIdentifier() == IVD->getIdentifier()) return OI; } - return getInterfaceDeclForIvar(OI->getSuperClass(), IVD); + return getInterfaceDeclForIvar(OI->getSuperClass(), IVD, Context); } /* @@ -1768,7 +1772,8 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID, RecordDecl::field_iterator ifield, pfield; const RecordDecl *RD = GetFirstIvarInRecord(OID, ifield, pfield); - for (RecordDecl::field_iterator e = RD->field_end(); ifield != e; ++ifield) { + for (RecordDecl::field_iterator e = RD->field_end(CGM.getContext()); + ifield != e; ++ifield) { FieldDecl *Field = *ifield; uint64_t Offset = GetIvarBaseOffset(Layout, Field); if (Field->getIdentifier()) @@ -2611,7 +2616,8 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI, const RecordType *RT = FQT->getAsRecordType(); const RecordDecl *RD = RT->getDecl(); // FIXME - Find a more efficiant way of passing records down. - TmpRecFields.append(RD->field_begin(), RD->field_end()); + TmpRecFields.append(RD->field_begin(CGM.getContext()), + RD->field_end(CGM.getContext())); // FIXME - Is Layout correct? BuildAggrIvarLayout(OI, Layout, RD, TmpRecFields, BytePos + GetFieldBaseOffset(OI, Layout, Field), @@ -2643,7 +2649,8 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI, const RecordType *RT = FQT->getAsRecordType(); const RecordDecl *RD = RT->getDecl(); // FIXME - Find a more efficiant way of passing records down. - TmpRecFields.append(RD->field_begin(), RD->field_end()); + TmpRecFields.append(RD->field_begin(CGM.getContext()), + RD->field_end(CGM.getContext())); BuildAggrIvarLayout(OI, Layout, RD, TmpRecFields, @@ -3075,10 +3082,11 @@ const RecordDecl *CGObjCCommonMac::GetFirstIvarInRecord( const ObjCInterfaceDecl *OID, RecordDecl::field_iterator &FIV, RecordDecl::field_iterator &PIV) { - int countSuperClassIvars = countInheritedIvars(OID->getSuperClass()); + int countSuperClassIvars = countInheritedIvars(OID->getSuperClass(), + CGM.getContext()); const RecordDecl *RD = CGM.getContext().addRecordToClass(OID); - RecordDecl::field_iterator ifield = RD->field_begin(); - RecordDecl::field_iterator pfield = RD->field_end(); + RecordDecl::field_iterator ifield = RD->field_begin(CGM.getContext()); + RecordDecl::field_iterator pfield = RD->field_end(CGM.getContext()); while (countSuperClassIvars-- > 0) { pfield = ifield; ++ifield; @@ -3194,10 +3202,10 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) RecordDecl *RD = RecordDecl::Create(Ctx, TagDecl::TK_struct, 0, SourceLocation(), &Ctx.Idents.get("_objc_super")); - RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), 0, - Ctx.getObjCIdType(), 0, false)); - RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), 0, - Ctx.getObjCClassType(), 0, false)); + RD->addDecl(Ctx, FieldDecl::Create(Ctx, RD, SourceLocation(), 0, + Ctx.getObjCIdType(), 0, false)); + RD->addDecl(Ctx, FieldDecl::Create(Ctx, RD, SourceLocation(), 0, + Ctx.getObjCClassType(), 0, false)); RD->completeDefinition(Ctx); SuperCTy = Ctx.getTagDeclType(RD); @@ -3819,10 +3827,10 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul RecordDecl *RD = RecordDecl::Create(Ctx, TagDecl::TK_struct, 0, SourceLocation(), &Ctx.Idents.get("_message_ref_t")); - RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), 0, - Ctx.VoidPtrTy, 0, false)); - RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), 0, - Ctx.getObjCSelType(), 0, false)); + RD->addDecl(Ctx, FieldDecl::Create(Ctx, RD, SourceLocation(), 0, + Ctx.VoidPtrTy, 0, false)); + RD->addDecl(Ctx, FieldDecl::Create(Ctx, RD, SourceLocation(), 0, + Ctx.getObjCSelType(), 0, false)); RD->completeDefinition(Ctx); MessageRefCTy = Ctx.getTagDeclType(RD); @@ -4273,17 +4281,17 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { RecordDecl::field_iterator firstField, lastField; const RecordDecl *RD = GetFirstIvarInRecord(OID, firstField, lastField); - for (RecordDecl::field_iterator e = RD->field_end(), + for (RecordDecl::field_iterator e = RD->field_end(CGM.getContext()), ifield = firstField; ifield != e; ++ifield) lastField = ifield; - if (lastField != RD->field_end()) { + if (lastField != RD->field_end(CGM.getContext())) { FieldDecl *Field = *lastField; const llvm::Type *FieldTy = CGM.getTypes().ConvertTypeForMem(Field->getType()); unsigned Size = CGM.getTargetData().getTypePaddedSize(FieldTy); InstanceSize = GetIvarBaseOffset(Layout, Field) + Size; - if (firstField == RD->field_end()) + if (firstField == RD->field_end(CGM.getContext())) InstanceStart = InstanceSize; else { Field = *firstField; @@ -4495,8 +4503,8 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::ObjCIvarOffsetVariable( const ObjCInterfaceDecl *ID, const ObjCIvarDecl *Ivar) { Name += "\01_OBJC_IVAR_$_" + - getInterfaceDeclForIvar(ID, Ivar)->getNameAsString() + '.' - + Ivar->getNameAsString(); + getInterfaceDeclForIvar(ID, Ivar, CGM.getContext())->getNameAsString() + + '.' + Ivar->getNameAsString(); llvm::GlobalVariable *IvarOffsetGV = CGM.getModule().getGlobalVariable(Name); if (!IvarOffsetGV) @@ -4585,13 +4593,14 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList( for (ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin(), E = OID->ivar_end(); I != E; ++I) OIvars.push_back(*I); - for (ObjCInterfaceDecl::prop_iterator I = OID->prop_begin(), - E = OID->prop_end(); I != E; ++I) + for (ObjCInterfaceDecl::prop_iterator I = OID->prop_begin(CGM.getContext()), + E = OID->prop_end(CGM.getContext()); I != E; ++I) if (ObjCIvarDecl *IV = (*I)->getPropertyIvarDecl()) OIvars.push_back(IV); unsigned iv = 0; - for (RecordDecl::field_iterator e = RD->field_end(); i != e; ++i) { + for (RecordDecl::field_iterator e = RD->field_end(CGM.getContext()); + i != e; ++i) { FieldDecl *Field = *i; uint64_t offset = GetIvarBaseOffset(Layout, Field); Ivar[0] = EmitIvarOffsetVar(ID->getClassInterface(), OIvars[iv++], offset); @@ -4693,8 +4702,10 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( // Construct method lists. std::vector<llvm::Constant*> InstanceMethods, ClassMethods; std::vector<llvm::Constant*> OptInstanceMethods, OptClassMethods; - for (ObjCProtocolDecl::instmeth_iterator i = PD->instmeth_begin(), - e = PD->instmeth_end(); i != e; ++i) { + for (ObjCProtocolDecl::instmeth_iterator + i = PD->instmeth_begin(CGM.getContext()), + e = PD->instmeth_end(CGM.getContext()); + i != e; ++i) { ObjCMethodDecl *MD = *i; llvm::Constant *C = GetMethodDescriptionConstant(MD); if (MD->getImplementationControl() == ObjCMethodDecl::Optional) { @@ -4704,8 +4715,10 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( } } - for (ObjCProtocolDecl::classmeth_iterator i = PD->classmeth_begin(), - e = PD->classmeth_end(); i != e; ++i) { + for (ObjCProtocolDecl::classmeth_iterator + i = PD->classmeth_begin(CGM.getContext()), + e = PD->classmeth_end(CGM.getContext()); + i != e; ++i) { ObjCMethodDecl *MD = *i; llvm::Constant *C = GetMethodDescriptionConstant(MD); if (MD->getImplementationControl() == ObjCMethodDecl::Optional) { diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 2c1ab1f8b59..eb190c79e1c 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1102,7 +1102,7 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) { cast<llvm::StructType>(getTypes().ConvertType(CFTy)); std::vector<llvm::Constant*> Fields; - RecordDecl::field_iterator Field = CFRD->field_begin(); + RecordDecl::field_iterator Field = CFRD->field_begin(getContext()); // Class pointer. FieldDecl *CurField = *Field++; @@ -1297,7 +1297,8 @@ void CodeGenModule::EmitObjCPropertyImplementations(const /// EmitNamespace - Emit all declarations in a namespace. void CodeGenModule::EmitNamespace(const NamespaceDecl *ND) { - for (RecordDecl::decl_iterator I = ND->decls_begin(), E = ND->decls_end(); + for (RecordDecl::decl_iterator I = ND->decls_begin(getContext()), + E = ND->decls_end(getContext()); I != E; ++I) EmitTopLevelDecl(*I); } @@ -1309,7 +1310,8 @@ void CodeGenModule::EmitLinkageSpec(const LinkageSpecDecl *LSD) { return; } - for (RecordDecl::decl_iterator I = LSD->decls_begin(), E = LSD->decls_end(); + for (RecordDecl::decl_iterator I = LSD->decls_begin(getContext()), + E = LSD->decls_end(getContext()); I != E; ++I) EmitTopLevelDecl(*I); } diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index e13a4bc65d2..984e49e1209 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -482,7 +482,7 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) { } else if (TD->isUnion()) { // Just use the largest element of the union, breaking ties with the // highest aligned member. - if (!RD->field_empty()) { + if (!RD->field_empty(getContext())) { RecordOrganizer RO(*this, *RD); RO.layoutUnionFields(Context.getASTRecordLayout(RD)); @@ -563,8 +563,8 @@ void RecordOrganizer::layoutStructFields(const ASTRecordLayout &RL) { std::vector<const llvm::Type*> LLVMFields; unsigned curField = 0; - for (RecordDecl::field_iterator Field = RD.field_begin(), - FieldEnd = RD.field_end(); + for (RecordDecl::field_iterator Field = RD.field_begin(CGT.getContext()), + FieldEnd = RD.field_end(CGT.getContext()); Field != FieldEnd; ++Field) { uint64_t offset = RL.getFieldOffset(curField); const llvm::Type *Ty = CGT.ConvertTypeForMemRecursive(Field->getType()); @@ -614,8 +614,8 @@ void RecordOrganizer::layoutStructFields(const ASTRecordLayout &RL) { /// all fields are added. void RecordOrganizer::layoutUnionFields(const ASTRecordLayout &RL) { unsigned curField = 0; - for (RecordDecl::field_iterator Field = RD.field_begin(), - FieldEnd = RD.field_end(); + for (RecordDecl::field_iterator Field = RD.field_begin(CGT.getContext()), + FieldEnd = RD.field_end(CGT.getContext()); Field != FieldEnd; ++Field) { // The offset should usually be zero, but bitfields could be strange uint64_t offset = RL.getFieldOffset(curField); 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; } |