@@ -775,7 +775,7 @@ class CGObjCCommonMac : public CodeGen::CGObjCRuntime {
775
775
void BuildAggrIvarLayout(const ObjCImplementationDecl *OI,
776
776
const llvm::StructLayout *Layout,
777
777
const RecordDecl *RD,
778
- const llvm:: SmallVectorImpl<FieldDecl*> &RecFields,
778
+ const SmallVectorImpl<const FieldDecl*> &RecFields,
779
779
unsigned int BytePos, bool ForStrongLayout,
780
780
bool &HasUnion);
781
781
@@ -2407,10 +2407,9 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID,
2407
2407
if (ForClass)
2408
2408
return llvm::Constant::getNullValue(ObjCTypes.IvarListPtrTy);
2409
2409
2410
- ObjCInterfaceDecl *OID =
2411
- const_cast <ObjCInterfaceDecl*>(ID->getClassInterface ());
2410
+ const ObjCInterfaceDecl *OID = ID->getClassInterface();
2412
2411
2413
- for (ObjCIvarDecl *IVD = OID->all_declared_ivar_begin ();
2412
+ for (const ObjCIvarDecl *IVD = OID->all_declared_ivar_begin();
2414
2413
IVD; IVD = IVD->getNextIvar()) {
2415
2414
// Ignore unnamed bit-fields.
2416
2415
if (!IVD->getDeclName())
@@ -3574,7 +3573,7 @@ void CGObjCCommonMac::BuildAggrIvarRecordLayout(const RecordType *RT,
3574
3573
bool &HasUnion) {
3575
3574
const RecordDecl *RD = RT->getDecl();
3576
3575
// FIXME - Use iterator.
3577
- llvm:: SmallVector<FieldDecl*, 16 > Fields (RD->field_begin (), RD->field_end ());
3576
+ SmallVector<const FieldDecl*, 16> Fields(RD->field_begin(), RD->field_end());
3578
3577
llvm::Type *Ty = CGM.getTypes().ConvertType(QualType(RT, 0));
3579
3578
const llvm::StructLayout *RecLayout =
3580
3579
CGM.getTargetData().getStructLayout(cast<llvm::StructType>(Ty));
@@ -3586,15 +3585,15 @@ void CGObjCCommonMac::BuildAggrIvarRecordLayout(const RecordType *RT,
3586
3585
void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI,
3587
3586
const llvm::StructLayout *Layout,
3588
3587
const RecordDecl *RD,
3589
- const llvm:: SmallVectorImpl<FieldDecl*> &RecFields,
3588
+ const SmallVectorImpl<const FieldDecl*> &RecFields,
3590
3589
unsigned int BytePos, bool ForStrongLayout,
3591
3590
bool &HasUnion) {
3592
3591
bool IsUnion = (RD && RD->isUnion());
3593
3592
uint64_t MaxUnionIvarSize = 0;
3594
3593
uint64_t MaxSkippedUnionIvarSize = 0;
3595
- FieldDecl *MaxField = 0 ;
3596
- FieldDecl *MaxSkippedField = 0 ;
3597
- FieldDecl *LastFieldBitfieldOrUnnamed = 0 ;
3594
+ const FieldDecl *MaxField = 0;
3595
+ const FieldDecl *MaxSkippedField = 0;
3596
+ const FieldDecl *LastFieldBitfieldOrUnnamed = 0;
3598
3597
uint64_t MaxFieldOffset = 0;
3599
3598
uint64_t MaxSkippedFieldOffset = 0;
3600
3599
uint64_t LastBitfieldOrUnnamedOffset = 0;
@@ -3605,13 +3604,13 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI,
3605
3604
unsigned WordSizeInBits = CGM.getContext().Target.getPointerWidth(0);
3606
3605
unsigned ByteSizeInBits = CGM.getContext().Target.getCharWidth();
3607
3606
if (!RD && CGM.getLangOptions().ObjCAutoRefCount) {
3608
- FieldDecl *FirstField = RecFields[0 ];
3607
+ const FieldDecl *FirstField = RecFields[0];
3609
3608
FirstFieldDelta =
3610
3609
ComputeIvarBaseOffset(CGM, OI, cast<ObjCIvarDecl>(FirstField));
3611
3610
}
3612
3611
3613
3612
for (unsigned i = 0, e = RecFields.size(); i != e; ++i) {
3614
- FieldDecl *Field = RecFields[i];
3613
+ const FieldDecl *Field = RecFields[i];
3615
3614
uint64_t FieldOffset;
3616
3615
if (RD) {
3617
3616
// Note that 'i' here is actually the field index inside RD of Field,
@@ -3903,20 +3902,19 @@ llvm::Constant *CGObjCCommonMac::BuildIvarLayout(
3903
3902
!CGM.getLangOptions().ObjCAutoRefCount)
3904
3903
return llvm::Constant::getNullValue(PtrTy);
3905
3904
3906
- ObjCInterfaceDecl *OI =
3907
- const_cast <ObjCInterfaceDecl*>(OMD->getClassInterface ());
3908
- llvm::SmallVector<FieldDecl*, 32 > RecFields;
3905
+ const ObjCInterfaceDecl *OI = OMD->getClassInterface();
3906
+ SmallVector<const FieldDecl*, 32> RecFields;
3909
3907
if (CGM.getLangOptions().ObjCAutoRefCount) {
3910
- for (ObjCIvarDecl *IVD = OI->all_declared_ivar_begin ();
3908
+ for (const ObjCIvarDecl *IVD = OI->all_declared_ivar_begin();
3911
3909
IVD; IVD = IVD->getNextIvar())
3912
3910
RecFields.push_back(cast<FieldDecl>(IVD));
3913
3911
}
3914
3912
else {
3915
- llvm:: SmallVector<ObjCIvarDecl*, 32 > Ivars;
3913
+ SmallVector<const ObjCIvarDecl*, 32> Ivars;
3916
3914
CGM.getContext().DeepCollectObjCIvars(OI, true, Ivars);
3917
3915
3918
- for ( unsigned k = 0 , e = Ivars. size (); k != e; ++k)
3919
- RecFields.push_back (cast<FieldDecl>( Ivars[k] ));
3916
+ // FIXME: This is not ideal; we shouldn't have to do this copy.
3917
+ RecFields.append(Ivars.begin(), Ivars.end( ));
3920
3918
}
3921
3919
3922
3920
if (RecFields.empty())
@@ -5258,13 +5256,12 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(
5258
5256
5259
5257
std::vector<llvm::Constant*> Ivars, Ivar(5);
5260
5258
5261
- ObjCInterfaceDecl *OID =
5262
- const_cast <ObjCInterfaceDecl*>(ID->getClassInterface ());
5259
+ const ObjCInterfaceDecl *OID = ID->getClassInterface();
5263
5260
assert(OID && "CGObjCNonFragileABIMac::EmitIvarList - null interface");
5264
5261
5265
5262
// FIXME. Consolidate this with similar code in GenerateClass.
5266
5263
5267
- for (ObjCIvarDecl *IVD = OID->all_declared_ivar_begin ();
5264
+ for (const ObjCIvarDecl *IVD = OID->all_declared_ivar_begin();
5268
5265
IVD; IVD = IVD->getNextIvar()) {
5269
5266
// Ignore unnamed bit-fields.
5270
5267
if (!IVD->getDeclName())
0 commit comments