@@ -852,7 +852,7 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) {
852
852
IvarT = GetGroupRecordTypeForObjCIvarBitfield (D);
853
853
854
854
if (!IvarT->getAs <TypedefType>() && IvarT->isRecordType ()) {
855
- RecordDecl *RD = IvarT->castAs <RecordType>()->getDecl ();
855
+ RecordDecl *RD = IvarT->castAs <RecordType>()->getOriginalDecl ();
856
856
RD = RD->getDefinition ();
857
857
if (RD && !RD->getDeclName ().getAsIdentifierInfo ()) {
858
858
// decltype(((Foo_IMPL*)0)->bar) *
@@ -865,7 +865,8 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) {
865
865
RecordDecl *RD = RecordDecl::Create (*Context, TagTypeKind::Struct, TUDecl,
866
866
SourceLocation (), SourceLocation (),
867
867
&Context->Idents .get (RecName));
868
- QualType PtrStructIMPL = Context->getPointerType (Context->getTagDeclType (RD));
868
+ QualType PtrStructIMPL =
869
+ Context->getPointerType (Context->getCanonicalTagType (RD));
869
870
unsigned UnsignedIntSize =
870
871
static_cast <unsigned >(Context->getTypeSize (Context->UnsignedIntTy ));
871
872
Expr *Zero = IntegerLiteral::Create (*Context,
@@ -2999,7 +3000,7 @@ QualType RewriteModernObjC::getSuperStructType() {
2999
3000
3000
3001
SuperStructDecl->completeDefinition ();
3001
3002
}
3002
- return Context->getTagDeclType (SuperStructDecl);
3003
+ return Context->getCanonicalTagType (SuperStructDecl);
3003
3004
}
3004
3005
3005
3006
QualType RewriteModernObjC::getConstantStringStructType () {
@@ -3032,7 +3033,7 @@ QualType RewriteModernObjC::getConstantStringStructType() {
3032
3033
3033
3034
ConstantStringDecl->completeDefinition ();
3034
3035
}
3035
- return Context->getTagDeclType (ConstantStringDecl);
3036
+ return Context->getCanonicalTagType (ConstantStringDecl);
3036
3037
}
3037
3038
3038
3039
// / getFunctionSourceLocation - returns start location of a function
@@ -3637,7 +3638,8 @@ bool RewriteModernObjC::RewriteObjCFieldDeclType(QualType &Type,
3637
3638
return RewriteObjCFieldDeclType (ElemTy, Result);
3638
3639
}
3639
3640
else if (Type->isRecordType ()) {
3640
- RecordDecl *RD = Type->castAs <RecordType>()->getDecl ();
3641
+ RecordDecl *RD =
3642
+ Type->castAs <RecordType>()->getOriginalDecl ()->getDefinitionOrSelf ();
3641
3643
if (RD->isCompleteDefinition ()) {
3642
3644
if (RD->isStruct ())
3643
3645
Result += " \n\t struct " ;
@@ -3660,7 +3662,8 @@ bool RewriteModernObjC::RewriteObjCFieldDeclType(QualType &Type,
3660
3662
}
3661
3663
}
3662
3664
else if (Type->isEnumeralType ()) {
3663
- EnumDecl *ED = Type->castAs <EnumType>()->getDecl ();
3665
+ EnumDecl *ED =
3666
+ Type->castAs <EnumType>()->getOriginalDecl ()->getDefinitionOrSelf ();
3664
3667
if (ED->isCompleteDefinition ()) {
3665
3668
Result += " \n\t enum " ;
3666
3669
Result += ED->getName ();
@@ -3732,10 +3735,10 @@ void RewriteModernObjC::RewriteLocallyDefinedNamedAggregates(FieldDecl *fieldDec
3732
3735
3733
3736
TagDecl *TD = nullptr ;
3734
3737
if (Type->isRecordType ()) {
3735
- TD = Type->castAs <RecordType>()->getDecl ();
3738
+ TD = Type->castAs <RecordType>()->getOriginalDecl ()-> getDefinitionOrSelf ();
3736
3739
}
3737
3740
else if (Type->isEnumeralType ()) {
3738
- TD = Type->castAs <EnumType>()->getDecl ();
3741
+ TD = Type->castAs <EnumType>()->getOriginalDecl ()-> getDefinitionOrSelf ();
3739
3742
}
3740
3743
3741
3744
if (TD) {
@@ -3793,7 +3796,7 @@ QualType RewriteModernObjC::SynthesizeBitfieldGroupStructType(
3793
3796
false , ICIS_NoInit));
3794
3797
}
3795
3798
RD->completeDefinition ();
3796
- return Context->getTagDeclType (RD);
3799
+ return Context->getCanonicalTagType (RD);
3797
3800
}
3798
3801
3799
3802
QualType RewriteModernObjC::GetGroupRecordTypeForObjCIvarBitfield (ObjCIvarDecl *IV) {
@@ -4572,7 +4575,7 @@ Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp
4572
4575
RecordDecl *RD = RecordDecl::Create (*Context, TagTypeKind::Struct, TUDecl,
4573
4576
SourceLocation (), SourceLocation (),
4574
4577
&Context->Idents .get (" __block_impl" ));
4575
- QualType PtrBlock = Context->getPointerType (Context->getTagDeclType (RD));
4578
+ QualType PtrBlock = Context->getPointerType (Context->getCanonicalTagType (RD));
4576
4579
4577
4580
// Generate a funky cast.
4578
4581
SmallVector<QualType, 8 > ArgTypes;
@@ -5316,7 +5319,8 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
5316
5319
RecordDecl::Create (*Context, TagTypeKind::Struct, TUDecl,
5317
5320
SourceLocation (), SourceLocation (), II);
5318
5321
assert (RD && " SynthBlockInitExpr(): Can't find RecordDecl" );
5319
- QualType castT = Context->getPointerType (Context->getTagDeclType (RD));
5322
+ QualType castT =
5323
+ Context->getPointerType (Context->getCanonicalTagType (RD));
5320
5324
5321
5325
FD = SynthBlockInitFunctionDecl (ND->getName ());
5322
5326
Exp = new (Context) DeclRefExpr (*Context, FD, false , FD->getType (),
@@ -5719,7 +5723,10 @@ void RewriteModernObjC::HandleDeclInMainFile(Decl *D) {
5719
5723
}
5720
5724
}
5721
5725
} else if (VD->getType ()->isRecordType ()) {
5722
- RecordDecl *RD = VD->getType ()->castAs <RecordType>()->getDecl ();
5726
+ RecordDecl *RD = VD->getType ()
5727
+ ->castAs <RecordType>()
5728
+ ->getOriginalDecl ()
5729
+ ->getDefinitionOrSelf ();
5723
5730
if (RD->isCompleteDefinition ())
5724
5731
RewriteRecordBody (RD);
5725
5732
}
@@ -7460,7 +7467,7 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
7460
7467
IvarT = GetGroupRecordTypeForObjCIvarBitfield (D);
7461
7468
7462
7469
if (!IvarT->getAs <TypedefType>() && IvarT->isRecordType ()) {
7463
- RecordDecl *RD = IvarT->castAs <RecordType>()->getDecl ();
7470
+ RecordDecl *RD = IvarT->castAs <RecordType>()->getOriginalDecl ();
7464
7471
RD = RD->getDefinition ();
7465
7472
if (RD && !RD->getDeclName ().getAsIdentifierInfo ()) {
7466
7473
// decltype(((Foo_IMPL*)0)->bar) *
@@ -7473,7 +7480,8 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
7473
7480
RecordDecl *RD = RecordDecl::Create (
7474
7481
*Context, TagTypeKind::Struct, TUDecl, SourceLocation (),
7475
7482
SourceLocation (), &Context->Idents .get (RecName));
7476
- QualType PtrStructIMPL = Context->getPointerType (Context->getTagDeclType (RD));
7483
+ QualType PtrStructIMPL =
7484
+ Context->getPointerType (Context->getCanonicalTagType (RD));
7477
7485
unsigned UnsignedIntSize =
7478
7486
static_cast <unsigned >(Context->getTypeSize (Context->UnsignedIntTy ));
7479
7487
Expr *Zero = IntegerLiteral::Create (*Context,
0 commit comments