[cfe-commits] r44486 - /cfe/trunk/AST/Expr.cpp
Chris Lattner
sabre at nondot.org
Fri Nov 30 22:07:34 PST 2007
Author: lattner
Date: Sat Dec 1 00:07:34 2007
New Revision: 44486
URL: http://llvm.org/viewvc/llvm-project?rev=44486&view=rev
Log:
make the unused expression warning less noisy by not warning about comma exprs whose
LHS and RHS both have side effects.
Modified:
cfe/trunk/AST/Expr.cpp
Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=44486&r1=44485&r2=44486&view=diff
==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Sat Dec 1 00:07:34 2007
@@ -243,8 +243,15 @@
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;
More information about the cfe-commits
mailing list