Fix an IRGen bug in property setter calls when

setter and getter types mismatch. // rdar://8966864

llvm-svn: 125125
This commit is contained in:
Fariborz Jahanian 2011-02-08 22:33:23 +00:00
parent fa0734ec4f
commit 701f094afb
2 changed files with 28 additions and 1 deletions

View File

@ -585,7 +585,17 @@ void CodeGenFunction::EmitStoreThroughPropertyRefLValue(RValue Src,
} else {
ArgType = E->getType();
}
// FIXME. Other than scalars, AST is not adequate for setter and
// getter type mismatches which require conversion.
if (Src.isScalar()) {
llvm::Value *SrcVal = Src.getScalarVal();
QualType DstType = getContext().getCanonicalType(ArgType);
const llvm::Type *DstTy = ConvertType(DstType);
if (SrcVal->getType() != DstTy)
Src =
RValue::get(EmitScalarConversion(SrcVal, E->getType(), DstType));
}
CallArgList Args;
Args.push_back(std::make_pair(Src, ArgType));

View File

@ -0,0 +1,17 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o - %s | FileCheck %s
// rdar://8966864
@interface Foo
-(float)myfo;
-(void)setMyfo: (int)p;
@end
void bar(Foo *x) {
x.myfo++;
}
// CHECK: [[C1:%.*]] = call float bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
// CHECK: [[I:%.*]] = fadd float [[C1]], 1.000000e+00
// CHECK: [[CONV:%.*]] = fptosi float [[I]] to i32
// CHECK: [[T3:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_2"
// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend