Expr *E, llvm::DenseMap<const VarDecl *, int> &RefsMinusAssignments) {
DeclRefExpr *LHS = nullptr;
if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
- if (!BO->isAssignmentOp())
+ if (BO->getLHS()->getType()->isDependentType() ||
+ BO->getRHS()->getType()->isDependentType()) {
+ if (BO->getOpcode() != BO_Assign)
+ return;
+ } else if (!BO->isAssignmentOp())
return;
LHS = dyn_cast<DeclRefExpr>(BO->getLHS());
} else if (CXXOperatorCallExpr *COCE = dyn_cast<CXXOperatorCallExpr>(E)) {
- if (!COCE->isAssignmentOp())
+ if (COCE->getOperator() != OO_Equal)
return;
LHS = dyn_cast<DeclRefExpr>(COCE->getArg(0));
}
struct __attribute__((warn_unused)) SWarnUnused {
int j;
+ void operator +=(int);
};
int f0() {
char a[x];
char b[y];
}
+
+void f3(int n) {
+ // Don't warn for overloaded compound assignment operators.
+ SWarnUnused swu;
+ swu += n;
+}
+
+template<typename T> void f4(T n) {
+ // Don't warn for (potentially) overloaded compound assignment operators in
+ // template code.
+ SWarnUnused swu;
+ swu += n;
+}