diff options
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 46 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 9 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 12 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 8 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGObjCGNU.cpp | 9 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 93 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 8 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenTypes.cpp | 10 |
8 files changed, 108 insertions, 87 deletions
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); |