Restore r142914 and r142915, now with missing file and apparent
GCC compiler workaround.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142931 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp
index 16c17fb..25d3c2a 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->getAs<PointerType>()->getPointeeType();
+    BaseType = BaseType->castAs<PointerType>()->getPointeeType();
   }
   R.setBaseObjectType(BaseType);
 
@@ -814,15 +814,6 @@
       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()) {
@@ -1209,11 +1200,8 @@
           if (DiagnoseUseOfDecl(PD, MemberLoc))
             return ExprError();
 
-          QualType T = PD->getType();
-          if (ObjCMethodDecl *Getter = PD->getGetterMethodDecl())
-            T = getMessageSendResultType(BaseType, Getter, false, false);
-         
-          return Owned(new (Context) ObjCPropertyRefExpr(PD, T,
+          return Owned(new (Context) ObjCPropertyRefExpr(PD,
+                                                         Context.PseudoObjectTy,
                                                          VK_LValue,
                                                          OK_ObjCProperty,
                                                          MemberLoc, 
@@ -1231,16 +1219,10 @@
           if (Decl *SDecl = FindGetterSetterNameDecl(OPT, /*Property id*/0, 
                                                      SetterSel, Context))
             SMD = dyn_cast<ObjCMethodDecl>(SDecl);
-          QualType PType = getMessageSendResultType(BaseType, OMD, false, 
-                                                    false);
           
-          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,
+          return Owned(new (Context) ObjCPropertyRefExpr(OMD, SMD,
+                                                         Context.PseudoObjectTy,
+                                                         VK_LValue, OK_ObjCProperty,
                                                          MemberLoc, BaseExpr.take()));
         }
       }
@@ -1295,23 +1277,9 @@
         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,
-                                                       PType, VK, OK,
+                                                       Context.PseudoObjectTy,
+                                                       VK_LValue, OK_ObjCProperty,
                                                        MemberLoc, BaseExpr.take()));
       }