]> granicus.if.org Git - clang/commitdiff
Objective-C: Produce gcc compatible encoding of
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 12 Jul 2013 16:19:11 +0000 (16:19 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 12 Jul 2013 16:19:11 +0000 (16:19 +0000)
ivar type in meta-data while preventing recursive
encoding in a corner case. // rdar://14408244

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186169 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/CodeGenObjC/encode-test-6.m

index 933e5e057ee93c03c60fe19c2e0e0fb58b027d7d..527a647701884dac5d44463566092854d1963b26 100644 (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,
index b7feb14434bc0f92eda305e11acf48e284d446ae..b7b37997e1fad9ebd9244f3b4f2e6f9532d6f91e 100644 (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"