From: Fariborz Jahanian Date: Tue, 3 Mar 2009 18:49:40 +0000 (+0000) Subject: Fixed an ir-gen bug in syntheszing a getter function X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed1d29d62595a83ccf6ef23eb2759d355206df2e;p=clang 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65955 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index cebaa1eb03..5798865077 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -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 index 0000000000..b287249624 --- /dev/null +++ b/test/CodeGenObjC/objc2-retain-codegen.m @@ -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 +