diff options
author | Richard Trieu <rtrieu@google.com> | 2011-09-15 21:56:47 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2011-09-15 21:56:47 +0000 |
commit | 82402a06f1e083a1c73a8ca7e6c901cdd102b7f4 (patch) | |
tree | 7ac5cedd23e790a5efb11fe92c2f8938a5b8af8a /clang/lib/Sema/SemaExprCXX.cpp | |
parent | b08b736de9a92aa7e9ee5d4359cd5a6d15caf841 (diff) | |
download | bcm5719-llvm-82402a06f1e083a1c73a8ca7e6c901cdd102b7f4.tar.gz bcm5719-llvm-82402a06f1e083a1c73a8ca7e6c901cdd102b7f4.zip |
Finish the lex->LHS and rex->RHS cleanup in Sema.
llvm-svn: 139856
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 08f4c437c3e..98f96bc68da 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -3269,34 +3269,34 @@ ExprResult Sema::BuildExpressionTrait(ExpressionTrait ET, 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 @@ QualType Sema::CheckPointerToMemberOperands(ExprResult &lex, ExprResult &rex, // [...] 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 @@ QualType Sema::CheckPointerToMemberOperands(ExprResult &lex, ExprResult &rex, /*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 @@ QualType Sema::CheckPointerToMemberOperands(ExprResult &lex, ExprResult &rex, // 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 @@ QualType Sema::CheckPointerToMemberOperands(ExprResult &lex, ExprResult &rex, 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 @@ QualType Sema::CheckPointerToMemberOperands(ExprResult &lex, ExprResult &rex, } else if (isIndirect) { VK = VK_LValue; } else { - VK = lex.get()->getValueKind(); + VK = LHS.get()->getValueKind(); } return Result; |