[PATCH] D103949: Only consider built-in compound assignment operators for -Wunused-but-set-*
Stephan Bergmann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 9 23:11:41 PDT 2021
sberg added inline comments.
================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:7794-7798
+ if (BO->getLHS()->getType()->isDependentType() ||
+ BO->getRHS()->getType()->isDependentType())
+ {
+ if (BO->getOpcode() != BO_Assign)
+ return;
----------------
mbenfield wrote:
> Would you mind elaborating on the need for this code? IIUC, you're concerned about overloaded operators, but won't such operators always be covered by the `CXXOperatorCallExpr` case below?
That's what I would initially have thought too (see my unanswered <https://lists.llvm.org/pipermail/llvm-dev/2021-June/150875.html> "[llvm-dev] BinaryOperator vs. CXXOperatorCallExpr in template code"; but which, I notice now, I accidentally sent to llvm-dev rather than cfe-dev).
But e.g. the template `f4` test code in `warn-unused-but-set-variables-cpp.cpp` turns the `+=` into a `BinaryOperator`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103949/new/
https://reviews.llvm.org/D103949
More information about the cfe-commits
mailing list