diff --git a/AST/Expr.cpp b/AST/Expr.cpp index 15fbb24a0d..5871a5c868 100644 --- a/AST/Expr.cpp +++ b/AST/Expr.cpp @@ -243,8 +243,15 @@ bool Expr::hasLocalSideEffect() const { return UO->getSubExpr()->hasLocalSideEffect(); } } - case BinaryOperatorClass: - return cast(this)->isAssignmentOp(); + case BinaryOperatorClass: { + const BinaryOperator *BinOp = cast(this); + // Consider comma to have side effects if the LHS and RHS both do. + if (BinOp->getOpcode() == BinaryOperator::Comma) + return BinOp->getLHS()->hasLocalSideEffect() && + BinOp->getRHS()->hasLocalSideEffect(); + + return BinOp->isAssignmentOp(); + } case CompoundAssignOperatorClass: return true;