aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-03-03 18:49:40 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-03-03 18:49:40 +0000
commited1d29d62595a83ccf6ef23eb2759d355206df2e (patch)
tree9c8cd3f02a2cb5ce23376772661905164a57178e
parent6076e0a65183e52dd118e34f62bc2adc056a54e1 (diff)
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
-rw-r--r--lib/CodeGen/CGObjC.cpp10
-rw-r--r--test/CodeGenObjC/objc2-retain-codegen.m12
2 files changed, 19 insertions, 3 deletions
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
+