diff options
author | Chris Lattner <sabre@nondot.org> | 2007-12-01 06:07:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-12-01 06:07:34 +0000 |
commit | ae7a834e74e19f34b87c6546f5017ebb719bbad3 (patch) | |
tree | e464ff0e67cc4a924c8de1b2831dcdab7b618ac1 | |
parent | e69d662baea612419e5f4d1ccf4e327511c3fe7a (diff) | |
download | bcm5719-llvm-ae7a834e74e19f34b87c6546f5017ebb719bbad3.tar.gz bcm5719-llvm-ae7a834e74e19f34b87c6546f5017ebb719bbad3.zip |
make the unused expression warning less noisy by not warning about comma exprs whose
LHS and RHS both have side effects.
llvm-svn: 44486
-rw-r--r-- | clang/AST/Expr.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/AST/Expr.cpp b/clang/AST/Expr.cpp index 15fbb24a0d4..5871a5c8682 100644 --- a/clang/AST/Expr.cpp +++ b/clang/AST/Expr.cpp @@ -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; |