[cfe-commits] r114299 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGenObjCXX/property-dot-reference.mm

Fariborz Jahanian fjahanian at apple.com
Sat Sep 18 13:47:25 PDT 2010


Author: fjahanian
Date: Sat Sep 18 15:47:25 2010
New Revision: 114299

URL: http://llvm.org/viewvc/llvm-project?rev=114299&view=rev
Log:
Fixes IRgen bug in objc++ reference binding of a
getter expression. 
Fixes // rdar://8437240

Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/test/CodeGenObjCXX/property-dot-reference.mm

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=114299&r1=114298&r2=114299&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Sat Sep 18 15:47:25 2010
@@ -196,7 +196,15 @@
   if (E->isLvalue(CGF.getContext()) == Expr::LV_Valid) {
     // Emit the expression as an lvalue.
     LValue LV = CGF.EmitLValue(E);
-
+    if (LV.isPropertyRef() || LV.isKVCRef()) {
+      QualType QT = E->getType();
+      RValue RV = 
+        LV.isPropertyRef() ? CGF.EmitLoadOfPropertyRefLValue(LV, QT) 
+                           : CGF.EmitLoadOfKVCRefLValue(LV, QT);
+      assert(RV.isScalar() && "EmitExprForReferenceBinding");
+      return RV.getScalarVal();
+    }
+    
     if (LV.isSimple())
       return LV.getAddress();
     

Modified: cfe/trunk/test/CodeGenObjCXX/property-dot-reference.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/property-dot-reference.mm?rev=114299&r1=114298&r2=114299&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/property-dot-reference.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/property-dot-reference.mm Sat Sep 18 15:47:25 2010
@@ -16,3 +16,23 @@
 	self.node.GetURL();
 }	// expected-warning {{control reaches end of non-void function}}
 @end
+
+// rdar://8437240
+struct X {
+  int x;
+};
+
+void f0(const X &parent);
+ at interface A
+- (const X&) target;
+ at end
+void f1(A *a) {
+// CHECK: [[PRP:%.*]] = call %struct.X* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK-NEXT:call void @_Z2f0RK1X(%struct.X* [[PRP]])
+  f0(a.target);
+
+// CHECK: [[MSG:%.*]] = call %struct.X* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK-NEXT:call void @_Z2f0RK1X(%struct.X* [[MSG]])
+  f0([a target]);
+}
+





More information about the cfe-commits mailing list