]> granicus.if.org Git - clang/commitdiff
Fixed an ir-gen bug in syntheszing a getter function
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 3 Mar 2009 18:49:40 +0000 (18:49 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 3 Mar 2009 18:49:40 +0000 (18:49 +0000)
with property type which does not match its ivar and
in -fobjc-gc-only mode!

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

lib/CodeGen/CGObjC.cpp
test/CodeGenObjC/objc2-retain-codegen.m [new file with mode: 0644]

index cebaa1eb03084065623af058ab13333c5a31b6c6..579886507744099b40497ba3de8523cc2b3cf3c2 100644 (file)
@@ -205,9 +205,13 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
     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();
diff --git a/test/CodeGenObjC/objc2-retain-codegen.m b/test/CodeGenObjC/objc2-retain-codegen.m
new file mode 100644 (file)
index 0000000..b287249
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: clang -triple x86_64-unknown-unknown -fobjc-gc-only -emit-llvm -o %t %s
+
+@interface I0 {
+  I0 *_f0;
+}
+@property (retain) id p0;
+@end 
+
+@implementation I0 
+  @synthesize p0 = _f0;
+@end
+