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 | e7716e6133e23e4a89248a65a388bc840d8c130c (patch) | |
tree | dbd680cc82aa5234003fba9235c7df52a1b5a3e6 | |
parent | a977636a9c1edfea2ba36e039e195b80b6e43cdf (diff) |
make the unused expression warning less noisy by not warning about comma exprs whose
LHS and RHS both have side effects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44486 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | AST/Expr.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
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<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; |