Finish the lex->LHS and rex->RHS cleanup in Sema.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139856 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 08f4c43..98f96bc 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -3269,34 +3269,34 @@
                                                  RParen, Context.BoolTy));
 }
 
-QualType Sema::CheckPointerToMemberOperands(ExprResult &lex, ExprResult &rex,
+QualType Sema::CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS,
                                             ExprValueKind &VK,
                                             SourceLocation Loc,
                                             bool isIndirect) {
-  assert(!lex.get()->getType()->isPlaceholderType() &&
-         !rex.get()->getType()->isPlaceholderType() &&
+  assert(!LHS.get()->getType()->isPlaceholderType() &&
+         !RHS.get()->getType()->isPlaceholderType() &&
          "placeholders should have been weeded out by now");
 
   // The LHS undergoes lvalue conversions if this is ->*.
   if (isIndirect) {
-    lex = DefaultLvalueConversion(lex.take());
-    if (lex.isInvalid()) return QualType();
+    LHS = DefaultLvalueConversion(LHS.take());
+    if (LHS.isInvalid()) return QualType();
   }
 
   // The RHS always undergoes lvalue conversions.
-  rex = DefaultLvalueConversion(rex.take());
-  if (rex.isInvalid()) return QualType();
+  RHS = DefaultLvalueConversion(RHS.take());
+  if (RHS.isInvalid()) return QualType();
 
   const char *OpSpelling = isIndirect ? "->*" : ".*";
   // C++ 5.5p2
   //   The binary operator .* [p3: ->*] binds its second operand, which shall
   //   be of type "pointer to member of T" (where T is a completely-defined
   //   class type) [...]
-  QualType RType = rex.get()->getType();
-  const MemberPointerType *MemPtr = RType->getAs<MemberPointerType>();
+  QualType RHSType = RHS.get()->getType();
+  const MemberPointerType *MemPtr = RHSType->getAs<MemberPointerType>();
   if (!MemPtr) {
     Diag(Loc, diag::err_bad_memptr_rhs)
-      << OpSpelling << RType << rex.get()->getSourceRange();
+      << OpSpelling << RHSType << RHS.get()->getSourceRange();
     return QualType();
   }
 
@@ -3312,21 +3312,21 @@
   //   [...] to its first operand, which shall be of class T or of a class of
   //   which T is an unambiguous and accessible base class. [p3: a pointer to
   //   such a class]
-  QualType LType = lex.get()->getType();
+  QualType LHSType = LHS.get()->getType();
   if (isIndirect) {
-    if (const PointerType *Ptr = LType->getAs<PointerType>())
-      LType = Ptr->getPointeeType();
+    if (const PointerType *Ptr = LHSType->getAs<PointerType>())
+      LHSType = Ptr->getPointeeType();
     else {
       Diag(Loc, diag::err_bad_memptr_lhs)
-        << OpSpelling << 1 << LType
+        << OpSpelling << 1 << LHSType
         << FixItHint::CreateReplacement(SourceRange(Loc), ".*");
       return QualType();
     }
   }
 
-  if (!Context.hasSameUnqualifiedType(Class, LType)) {
+  if (!Context.hasSameUnqualifiedType(Class, LHSType)) {
     // If we want to check the hierarchy, we need a complete type.
-    if (RequireCompleteType(Loc, LType, PDiag(diag::err_bad_memptr_lhs)
+    if (RequireCompleteType(Loc, LHSType, PDiag(diag::err_bad_memptr_lhs)
         << OpSpelling << (int)isIndirect)) {
       return QualType();
     }
@@ -3334,23 +3334,24 @@
                        /*DetectVirtual=*/false);
     // FIXME: Would it be useful to print full ambiguity paths, or is that
     // overkill?
-    if (!IsDerivedFrom(LType, Class, Paths) ||
+    if (!IsDerivedFrom(LHSType, Class, Paths) ||
         Paths.isAmbiguous(Context.getCanonicalType(Class))) {
       Diag(Loc, diag::err_bad_memptr_lhs) << OpSpelling
-        << (int)isIndirect << lex.get()->getType();
+        << (int)isIndirect << LHS.get()->getType();
       return QualType();
     }
     // Cast LHS to type of use.
     QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
     ExprValueKind VK =
-        isIndirect ? VK_RValue : CastCategory(lex.get());
+        isIndirect ? VK_RValue : CastCategory(LHS.get());
 
     CXXCastPath BasePath;
     BuildBasePathArray(Paths, BasePath);
-    lex = ImpCastExprToType(lex.take(), UseType, CK_DerivedToBase, VK, &BasePath);
+    LHS = ImpCastExprToType(LHS.take(), UseType, CK_DerivedToBase, VK,
+                            &BasePath);
   }
 
-  if (isa<CXXScalarValueInitExpr>(rex.get()->IgnoreParens())) {
+  if (isa<CXXScalarValueInitExpr>(RHS.get()->IgnoreParens())) {
     // Diagnose use of pointer-to-member type which when used as
     // the functional cast in a pointer-to-member expression.
     Diag(Loc, diag::err_pointer_to_member_type) << isIndirect;
@@ -3363,7 +3364,7 @@
   // The cv qualifiers are the union of those in the pointer and the left side,
   // in accordance with 5.5p5 and 5.2.5.
   QualType Result = MemPtr->getPointeeType();
-  Result = Context.getCVRQualifiedType(Result, LType.getCVRQualifiers());
+  Result = Context.getCVRQualifiedType(Result, LHSType.getCVRQualifiers());
 
   // C++0x [expr.mptr.oper]p6:
   //   In a .* expression whose object expression is an rvalue, the program is
@@ -3378,15 +3379,15 @@
       break;
 
     case RQ_LValue:
-      if (!isIndirect && !lex.get()->Classify(Context).isLValue())
+      if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
         Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-          << RType << 1 << lex.get()->getSourceRange();
+          << RHSType << 1 << LHS.get()->getSourceRange();
       break;
 
     case RQ_RValue:
-      if (isIndirect || !lex.get()->Classify(Context).isRValue())
+      if (isIndirect || !LHS.get()->Classify(Context).isRValue())
         Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-          << RType << 0 << lex.get()->getSourceRange();
+          << RHSType << 0 << LHS.get()->getSourceRange();
       break;
     }
   }
@@ -3404,7 +3405,7 @@
   } else if (isIndirect) {
     VK = VK_LValue;
   } else {
-    VK = lex.get()->getValueKind();
+    VK = LHS.get()->getValueKind();
   }
 
   return Result;