]> granicus.if.org Git - clang/commitdiff
Add support for block imported struct variable layout info.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 5 Aug 2010 21:00:25 +0000 (21:00 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 5 Aug 2010 21:00:25 +0000 (21:00 +0000)
(objc gc and blocks in NeXt runtime).

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

lib/CodeGen/CGObjCMac.cpp
test/CodeGenObjC/block-var-layout.m

index b8ed516ad7da1d0d6138d1bbd7aa2d5eb2b34d5e..b3921a4816541500759a9ecbecb00aa09c5a2a98 100644 (file)
@@ -1727,10 +1727,18 @@ llvm::Constant *CGObjCCommonMac::GCBlockLayout(CodeGen::CodeGenFunction &CGF,
     QualType Ty = VD->getType();
     assert(!Ty->isArrayType() && 
            "Array block variable should have been caught");
+    if (Ty->isRecordType() && !BDRE->isByRef()) {
+      bool HasUnion = false;
+      BuildAggrIvarRecordLayout(Ty->getAs<RecordType>(),
+                                FieldOffset,
+                                true,
+                                HasUnion);
+      continue;
+    }
     // FIXME. Handle none __block Aggregate variables
 #if 0
-    if ((Ty->isRecordType() || Ty->isUnionType()) && !BDRE->isByRef())
-      assert(false && "Aggregate block variable layout NYI");
+    if (Ty->isUnionType() && !BDRE->isByRef())
+      assert(false && "union block variable layout NYI");
 #endif
     Qualifiers::GC GCAttr = GetGCAttrTypeForType(CGM.getContext(), Ty);
     unsigned FieldSize = CGM.getContext().getTypeSize(Ty);
index 6e4b8125392db7d58aeb402651af08d197d4e62f..f00b44fdd553dcb5074c91493cd6898f759b272b 100644 (file)
@@ -3,6 +3,17 @@
 // RUN: %clang_cc1 -x objective-c++ -fblocks -fobjc-gc -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s
 // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
 
+struct S {
+    int i1;
+    id o1;
+    struct V {
+     int i2;
+     id o2;
+    } v1;
+    int i3;
+    id o3;
+};
+
 __weak id wid;
 void x(id y) {}
 void y(int a) {}
@@ -52,6 +63,13 @@ void (^d)() = ^{
         x(byref_bab);
     };    
     d();
+
+// Test4
+    struct S s2;
+    void (^e)() = ^{
+        x(s2.o1);
+    };    
+    e();
 }
 
 // CHECK-LP64: L_OBJC_CLASS_NAME_:
@@ -63,3 +81,5 @@ void (^d)() = ^{
 // CHECK-LP64: L_OBJC_CLASS_NAME_6:
 // CHECK-LP64-NEXT: .asciz   "A\023!"
 
+// CHECK-LP64: L_OBJC_CLASS_NAME_11:
+// CHECK-LP64-NEXT: .asciz   "Q\021\021"