Index: lib/AST/Expr.cpp =================================================================== --- lib/AST/Expr.cpp +++ lib/AST/Expr.cpp @@ -2863,8 +2863,22 @@ // These never have a side-effect. return false; + case CXXOperatorCallExprClass: { + // When looking for potential side-effects, we assume that these + // operators: assignment, increment and decrement are intended + // to have a side-effect and other overloaded operators are not. + // Otherwise fall through the logic of call expression. + OverloadedOperatorKind Op = cast(this)->getOperator(); + if (CXXOperatorCallExpr::isAssignmentOp(Op) + || Op == OO_PlusPlus || Op == OO_Minus) { + const Decl *FD = cast(this)->getCalleeDecl(); + bool IsPure = FD && (FD->hasAttr() || FD->hasAttr()); + if (!IsPure) + return true; + } + LLVM_FALLTHROUGH; + } case CallExprClass: - case CXXOperatorCallExprClass: case CXXMemberCallExprClass: case CUDAKernelCallExprClass: case UserDefinedLiteralClass: {