make the unused expression warning less noisy by not warning about comma exprs whose

LHS and RHS both have side effects.

llvm-svn: 44486
This commit is contained in:
Chris Lattner 2007-12-01 06:07:34 +00:00
parent e69d662bae
commit ae7a834e74
1 changed files with 9 additions and 2 deletions

View File

@ -243,8 +243,15 @@ bool Expr::hasLocalSideEffect() const {
return UO->getSubExpr()->hasLocalSideEffect();
}
}
case BinaryOperatorClass:
return cast<BinaryOperator>(this)->isAssignmentOp();
case BinaryOperatorClass: {
const BinaryOperator *BinOp = cast<BinaryOperator>(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;