]> granicus.if.org Git - clang/commitdiff
Fixes IRgen bug in objc++ reference binding of a
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 18 Sep 2010 20:47:25 +0000 (20:47 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 18 Sep 2010 20:47:25 +0000 (20:47 +0000)
getter expression.
Fixes // rdar://8437240

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114299 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGenObjCXX/property-dot-reference.mm

index 924ca3ec4bb977f0aaedc7023a14f691ffaf34ad..9b69297bbed00f768cb8e27cc88731917ef6b24b 100644 (file)
@@ -196,7 +196,15 @@ EmitExprForReferenceBinding(CodeGenFunction &CGF, const Expr *E,
   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();
     
index 82e89f26acf4fde6101f9d08accb73ecf6b58d42..0d455c6ca81cf1cf0d5c466a09f08193bc904f75 100644 (file)
@@ -16,3 +16,23 @@ void GetURL() const;
        self.node.GetURL();
 }      // expected-warning {{control reaches end of non-void function}}
 @end
+
+// rdar://8437240
+struct X {
+  int x;
+};
+
+void f0(const X &parent);
+@interface A
+- (const X&) target;
+@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]);
+}
+