aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ExprClassification.cpp2
-rw-r--r--lib/Sema/SemaExpr.cpp44
2 files changed, 28 insertions, 18 deletions
diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp
index 1afc7602fb..a43bea298e 100644
--- a/lib/AST/ExprClassification.cpp
+++ b/lib/AST/ExprClassification.cpp
@@ -515,7 +515,7 @@ static Cl::ModifiableType IsModifiable(ASTContext &Ctx, const Expr *E,
// Records with any const fields (recursively) are not modifiable.
if (const RecordType *R = CT->getAs<RecordType>()) {
- assert((isa<ObjCPropertyRefExpr>(E) ||
+ assert((E->getObjectKind() == OK_ObjCProperty ||
!Ctx.getLangOptions().CPlusPlus) &&
"C++ struct assignment should be resolved by the "
"copy assignment operator.");
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 3d6d59a406..34965e6267 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -7684,24 +7684,34 @@ ExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc,
ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc,
BinaryOperatorKind Opc,
Expr *lhs, Expr *rhs) {
- if (getLangOptions().CPlusPlus &&
- (!isa<ObjCPropertyRefExpr>(lhs)
- || rhs->isTypeDependent() || Opc != BO_Assign) &&
- (lhs->getType()->isOverloadableType() ||
- rhs->getType()->isOverloadableType())) {
- // Find all of the overloaded operators visible from this
- // point. We perform both an operator-name lookup from the local
- // scope and an argument-dependent lookup based on the types of
- // the arguments.
- UnresolvedSet<16> Functions;
- OverloadedOperatorKind OverOp = BinaryOperator::getOverloadedOperator(Opc);
- if (S && OverOp != OO_None)
- LookupOverloadedOperatorName(OverOp, S, lhs->getType(), rhs->getType(),
- Functions);
+ if (getLangOptions().CPlusPlus) {
+ bool UseBuiltinOperator;
- // Build the (potentially-overloaded, potentially-dependent)
- // binary operation.
- return CreateOverloadedBinOp(OpLoc, Opc, Functions, lhs, rhs);
+ if (lhs->isTypeDependent() || rhs->isTypeDependent()) {
+ UseBuiltinOperator = false;
+ } else if (Opc == BO_Assign && lhs->getObjectKind() == OK_ObjCProperty) {
+ UseBuiltinOperator = true;
+ } else {
+ UseBuiltinOperator = !lhs->getType()->isOverloadableType() &&
+ !rhs->getType()->isOverloadableType();
+ }
+
+ if (!UseBuiltinOperator) {
+ // Find all of the overloaded operators visible from this
+ // point. We perform both an operator-name lookup from the local
+ // scope and an argument-dependent lookup based on the types of
+ // the arguments.
+ UnresolvedSet<16> Functions;
+ OverloadedOperatorKind OverOp
+ = BinaryOperator::getOverloadedOperator(Opc);
+ if (S && OverOp != OO_None)
+ LookupOverloadedOperatorName(OverOp, S, lhs->getType(), rhs->getType(),
+ Functions);
+
+ // Build the (potentially-overloaded, potentially-dependent)
+ // binary operation.
+ return CreateOverloadedBinOp(OpLoc, Opc, Functions, lhs, rhs);
+ }
}
// Build a built-in binary operation.