[cfe-commits] r125125 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp test/CodeGenObjC/property-type-mismatch.m

Fariborz Jahanian fjahanian at apple.com
Tue Feb 8 14:33:23 PST 2011


Author: fjahanian
Date: Tue Feb  8 16:33:23 2011
New Revision: 125125

URL: http://llvm.org/viewvc/llvm-project?rev=125125&view=rev
Log:
Fix an IRGen bug in property setter calls when
setter and getter types mismatch. // rdar://8966864

Added:
    cfe/trunk/test/CodeGenObjC/property-type-mismatch.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=125125&r1=125124&r2=125125&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Tue Feb  8 16:33:23 2011
@@ -585,7 +585,17 @@
   } 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));
 

Added: cfe/trunk/test/CodeGenObjC/property-type-mismatch.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/property-type-mismatch.m?rev=125125&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/property-type-mismatch.m (added)
+++ cfe/trunk/test/CodeGenObjC/property-type-mismatch.m Tue Feb  8 16:33:23 2011
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10  -fobjc-nonfragile-abi -emit-llvm -o - %s | FileCheck %s
+// rdar://8966864
+
+ at interface Foo
+-(float)myfo;
+-(void)setMyfo: (int)p;
+ at 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





More information about the cfe-commits mailing list