зеркало из https://github.com/microsoft/clang-1.git
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
This commit is contained in:
Родитель
a977636a9c
Коммит
e7716e6133
11
AST/Expr.cpp
11
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;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче