[cfe-commits] r65955 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp test/CodeGenObjC/objc2-retain-codegen.m

Fariborz Jahanian fjahanian at apple.com
Tue Mar 3 10:49:44 PST 2009


Author: fjahanian
Date: Tue Mar  3 12:49:40 2009
New Revision: 65955

URL: http://llvm.org/viewvc/llvm-project?rev=65955&view=rev
Log:
Fixed an ir-gen bug in syntheszing a getter function
with property type which does not match its ivar and
in -fobjc-gc-only mode!

Added:
    cfe/trunk/test/CodeGenObjC/objc2-retain-codegen.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=65955&r1=65954&r2=65955&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Tue Mar  3 12:49:40 2009
@@ -205,9 +205,13 @@
     if (hasAggregateLLVMType(Ivar->getType())) {
       EmitAggregateCopy(ReturnValue, LV.getAddress(), Ivar->getType());
     }
-    else
-      EmitReturnOfRValue(EmitLoadOfLValue(LV, Ivar->getType()), 
-                                          PD->getType());
+    else {
+      CodeGenTypes &Types = CGM.getTypes();
+      RValue RV = EmitLoadOfLValue(LV, Ivar->getType());
+      RV = RValue::get(Builder.CreateBitCast(RV.getScalarVal(),
+                       Types.ConvertType(PD->getType()))); 
+      EmitReturnOfRValue(RV, PD->getType());
+    }
   }
 
   FinishFunction();

Added: cfe/trunk/test/CodeGenObjC/objc2-retain-codegen.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc2-retain-codegen.m?rev=65955&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenObjC/objc2-retain-codegen.m (added)
+++ cfe/trunk/test/CodeGenObjC/objc2-retain-codegen.m Tue Mar  3 12:49:40 2009
@@ -0,0 +1,12 @@
+// RUN: clang -triple x86_64-unknown-unknown -fobjc-gc-only -emit-llvm -o %t %s
+
+ at interface I0 {
+  I0 *_f0;
+}
+ at property (retain) id p0;
+ at end 
+
+ at implementation I0 
+  @synthesize p0 = _f0;
+ at end
+





More information about the cfe-commits mailing list