[cfe-commits] r60122 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp test/CodeGenObjC/property-aggr-type.m

Fariborz Jahanian fjahanian at apple.com
Wed Nov 26 14:36:09 PST 2008


Author: fjahanian
Date: Wed Nov 26 16:36:09 2008
New Revision: 60122

URL: http://llvm.org/viewvc/llvm-project?rev=60122&view=rev
Log:
Code gen for aggregate-valued properties and a test case.


Added:
    cfe/trunk/test/CodeGenObjC/property-aggr-type.m
Modified:
    cfe/trunk/lib/CodeGen/CGObjC.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=60122&r1=60121&r2=60122&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed Nov 26 16:36:09 2008
@@ -187,10 +187,13 @@
                                            Types.ConvertType(PD->getType())));
     EmitReturnOfRValue(RV, PD->getType());
   } else {
-    EmitReturnOfRValue(EmitLoadOfLValue(EmitLValueForIvar(LoadObjCSelf(), 
-                                                          Ivar, 0), 
-                                        Ivar->getType()), 
-                       PD->getType());
+    LValue LV = EmitLValueForIvar(LoadObjCSelf(), Ivar, 0);
+    if (hasAggregateLLVMType(Ivar->getType())) {
+      EmitAggregateCopy(ReturnValue, LV.getAddress(), Ivar->getType());
+    }
+    else
+      EmitReturnOfRValue(EmitLoadOfLValue(LV, Ivar->getType()), 
+                                          PD->getType());
   }
 
   FinishFunction();

Added: cfe/trunk/test/CodeGenObjC/property-aggr-type.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/property-aggr-type.m?rev=60122&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenObjC/property-aggr-type.m (added)
+++ cfe/trunk/test/CodeGenObjC/property-aggr-type.m Wed Nov 26 16:36:09 2008
@@ -0,0 +1,50 @@
+// RUN: clang -emit-llvm -o %t %s
+
+ at interface Object
+- (id) new;
+ at end
+
+typedef struct {int x, y, w, h;} st1;
+typedef struct {int x, y, w, h;} st2;
+
+ at interface bar : Object
+- (void)setFrame:(st1)frameRect;
+ at end
+
+ at interface bar1 : Object
+- (void)setFrame:(int)frameRect;
+ at end
+
+ at interface foo : Object
+{
+	st2 ivar;
+}
+ at property (assign) st2 frame;
+ at end
+
+ at implementation foo
+ at synthesize frame = ivar;
+ at end
+
+extern void abort();
+
+static   st2 r = {1,2,3,4};
+st2 test (void)
+{
+    foo *obj = [foo new];
+    id objid = [foo new];;
+
+    obj.frame = r;
+
+    ((foo*)objid).frame = obj.frame;
+
+    return ((foo*)objid).frame;
+}
+
+int main ()
+{
+  st2 res = test ();
+  if (res.x != 1 || res.h != 4)
+    abort();
+  return 0;
+}





More information about the cfe-commits mailing list