diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-07-12 16:19:11 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-07-12 16:19:11 +0000 |
commit | 88890e7b50e71cfec91e7daa44bed359fc947288 (patch) | |
tree | bf74b13a120a78e663f50b6743a6e64ddd4c5ed5 | |
parent | 41eec7e475f4c72426e56b663a44c60a2daf839d (diff) | |
download | bcm5719-llvm-88890e7b50e71cfec91e7daa44bed359fc947288.tar.gz bcm5719-llvm-88890e7b50e71cfec91e7daa44bed359fc947288.zip |
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
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 14 | ||||
-rw-r--r-- | clang/test/CodeGenObjC/encode-test-6.m | 18 |
2 files changed, 32 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 933e5e057ee..527a6477018 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -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, diff --git a/clang/test/CodeGenObjC/encode-test-6.m b/clang/test/CodeGenObjC/encode-test-6.m index b7feb14434b..b7b37997e1f 100644 --- a/clang/test/CodeGenObjC/encode-test-6.m +++ b/clang/test/CodeGenObjC/encode-test-6.m @@ -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" |