r186169 - Objective-C: Produce gcc compatible encoding of

Fariborz Jahanian fjahanian at apple.com
Fri Jul 12 09:19:11 PDT 2013


Author: fjahanian
Date: Fri Jul 12 11:19:11 2013
New Revision: 186169

URL: http://llvm.org/viewvc/llvm-project?rev=186169&view=rev
Log:
Objective-C: Produce gcc compatible encoding of
ivar type in meta-data while preventing recursive
encoding in a corner case. // rdar://14408244

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/CodeGenObjC/encode-test-6.m

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=186169&r1=186168&r2=186169&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Jul 12 11:19:11 2013
@@ -5434,6 +5434,20 @@ void ASTContext::getObjCEncodingForTypeI
       // 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,

Modified: cfe/trunk/test/CodeGenObjC/encode-test-6.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/encode-test-6.m?rev=186169&r1=186168&r2=186169&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/encode-test-6.m (original)
+++ cfe/trunk/test/CodeGenObjC/encode-test-6.m Fri Jul 12 11:19:11 2013
@@ -35,3 +35,21 @@ typedef BABugExample BABugExampleRedefin
 @end
 
 // CHECK: internal global [24 x i8] c"^{BABugExample=@}16
+
+// rdar://14408244
+ at class SCNCamera;
+typedef SCNCamera C3DCamera;
+typedef struct
+{
+    C3DCamera *presentationInstance;
+}  C3DCameraStorage;
+
+ at interface SCNCamera
+ at end
+
+ at implementation SCNCamera
+{
+    C3DCameraStorage _storage;
+}
+ at end
+// CHECK: internal global [39 x i8] c"{?=\22presentationInstance\22^{SCNCamera}}\00"





More information about the cfe-commits mailing list