IRGen fix for using property-dot syntax to pass 
reference object to a c++ member function.
fixes radar 8409336.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113602 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp
index 9a98281..acdbe06 100644
--- a/lib/CodeGen/CGExprCXX.cpp
+++ b/lib/CodeGen/CGExprCXX.cpp
@@ -100,7 +100,15 @@
     This = EmitScalarExpr(ME->getBase());
   else {
     LValue BaseLV = EmitLValue(ME->getBase());
-    This = BaseLV.getAddress();
+    if (BaseLV.isPropertyRef() || BaseLV.isKVCRef()) {
+      QualType QT = ME->getBase()->getType();
+      RValue RV = 
+        BaseLV.isPropertyRef() ? EmitLoadOfPropertyRefLValue(BaseLV, QT)
+          : EmitLoadOfKVCRefLValue(BaseLV, QT);
+      This = RV.isScalar() ? RV.getScalarVal() : RV.getAggregateAddr();
+    }
+    else
+      This = BaseLV.getAddress();
   }
 
   if (MD->isTrivial()) {