Objective-C: Produce gcc compatible encoding of

ivar type in meta-data while preventing recursive
encoding in a corner case. // rdar://14408244

llvm-svn: 186169
This commit is contained in:
Fariborz Jahanian 2013-07-12 16:19:11 +00:00
parent 41eec7e475
commit 88890e7b50
2 changed files with 32 additions and 0 deletions

View File

@ -5434,6 +5434,20 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
// We encode the underlying type which comes out as
// {...};
S += '^';
if (FD && OPT->getInterfaceDecl()) {
// Prevent redursive encoding of fields in some rare cases.
ObjCInterfaceDecl *OI = OPT->getInterfaceDecl();
SmallVector<const ObjCIvarDecl*, 32> Ivars;
DeepCollectObjCIvars(OI, true, Ivars);
for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
if (cast<FieldDecl>(Ivars[i]) == FD) {
S += '{';
S += OI->getIdentifier()->getName();
S += '}';
return;
}
}
}
getObjCEncodingForTypeImpl(PointeeTy, S,
false, ExpandPointedToStructures,
NULL,

View File

@ -35,3 +35,21 @@ typedef BABugExample BABugExampleRedefinition;
@end
// CHECK: internal global [24 x i8] c"^{BABugExample=@}16
// rdar://14408244
@class SCNCamera;
typedef SCNCamera C3DCamera;
typedef struct
{
C3DCamera *presentationInstance;
} C3DCameraStorage;
@interface SCNCamera
@end
@implementation SCNCamera
{
C3DCameraStorage _storage;
}
@end
// CHECK: internal global [39 x i8] c"{?=\22presentationInstance\22^{SCNCamera}}\00"