Revert r142914 and r142915, due to possibly missing file.

r142914: "Introduce a placeholder type for "pseudo object""
r142915: "Pull the pseudo-object stuff into its own file."

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142921 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp
index 25d3c2a..16c17fb 100644
--- a/lib/Sema/SemaExprMember.cpp
+++ b/lib/Sema/SemaExprMember.cpp
@@ -777,7 +777,7 @@
   QualType BaseType = BaseExprType;
   if (IsArrow) {
     assert(BaseType->isPointerType());
-    BaseType = BaseType->castAs<PointerType>()->getPointeeType();
+    BaseType = BaseType->getAs<PointerType>()->getPointeeType();
   }
   R.setBaseObjectType(BaseType);
 
@@ -814,6 +814,15 @@
       CheckQualifiedMemberReference(BaseExpr, BaseType, SS, R))
     return ExprError();
   
+  // Perform a property load on the base regardless of whether we
+  // actually need it for the declaration.
+  if (BaseExpr && BaseExpr->getObjectKind() == OK_ObjCProperty) {
+    ExprResult Result = ConvertPropertyForRValue(BaseExpr);
+    if (Result.isInvalid())
+      return ExprError();
+    BaseExpr = Result.take();
+  }
+
   // Construct an unresolved result if we in fact got an unresolved
   // result.
   if (R.isOverloadedResult() || R.isUnresolvableResult()) {
@@ -1200,8 +1209,11 @@
           if (DiagnoseUseOfDecl(PD, MemberLoc))
             return ExprError();
 
-          return Owned(new (Context) ObjCPropertyRefExpr(PD,
-                                                         Context.PseudoObjectTy,
+          QualType T = PD->getType();
+          if (ObjCMethodDecl *Getter = PD->getGetterMethodDecl())
+            T = getMessageSendResultType(BaseType, Getter, false, false);
+         
+          return Owned(new (Context) ObjCPropertyRefExpr(PD, T,
                                                          VK_LValue,
                                                          OK_ObjCProperty,
                                                          MemberLoc, 
@@ -1219,10 +1231,16 @@
           if (Decl *SDecl = FindGetterSetterNameDecl(OPT, /*Property id*/0, 
                                                      SetterSel, Context))
             SMD = dyn_cast<ObjCMethodDecl>(SDecl);
+          QualType PType = getMessageSendResultType(BaseType, OMD, false, 
+                                                    false);
           
-          return Owned(new (Context) ObjCPropertyRefExpr(OMD, SMD,
-                                                         Context.PseudoObjectTy,
-                                                         VK_LValue, OK_ObjCProperty,
+          ExprValueKind VK = VK_LValue;
+          if (!getLangOptions().CPlusPlus && PType.isCForbiddenLValueType())
+            VK = VK_RValue;
+          ExprObjectKind OK = (VK == VK_RValue ? OK_Ordinary : OK_ObjCProperty);
+
+          return Owned(new (Context) ObjCPropertyRefExpr(OMD, SMD, PType,
+                                                         VK, OK,
                                                          MemberLoc, BaseExpr.take()));
         }
       }
@@ -1277,9 +1295,23 @@
         return ExprError();
 
       if (Getter || Setter) {
+        QualType PType;
+
+        ExprValueKind VK = VK_LValue;
+        if (Getter) {
+          PType = getMessageSendResultType(QualType(OT, 0), Getter, true, 
+                                           false);
+          if (!getLangOptions().CPlusPlus && PType.isCForbiddenLValueType())
+            VK = VK_RValue;
+        } else {
+          // Get the expression type from Setter's incoming parameter.
+          PType = (*(Setter->param_end() -1))->getType();
+        }
+        ExprObjectKind OK = (VK == VK_RValue ? OK_Ordinary : OK_ObjCProperty);
+
+        // FIXME: we must check that the setter has property type.
         return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter,
-                                                       Context.PseudoObjectTy,
-                                                       VK_LValue, OK_ObjCProperty,
+                                                       PType, VK, OK,
                                                        MemberLoc, BaseExpr.take()));
       }