forked from OSchip/llvm-project
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:
parent
e69d662bae
commit
ae7a834e74
|
@ -243,8 +243,15 @@ bool Expr::hasLocalSideEffect() const {
|
||||||
return UO->getSubExpr()->hasLocalSideEffect();
|
return UO->getSubExpr()->hasLocalSideEffect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case BinaryOperatorClass:
|
case BinaryOperatorClass: {
|
||||||
return cast<BinaryOperator>(this)->isAssignmentOp();
|
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:
|
case CompoundAssignOperatorClass:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue