We were failing to set source locations and ranges in isUnusedResultAWarning
for CXXOperatorCallExprs, leading to an "expression result unused" warning
with absolutely no context if the expression was inside a macro.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140036
91177308-0d34-0410-b5e6-
96231b3b80d8
// DiagnoseUnusedComparison should be as well.
const CXXOperatorCallExpr *Op = cast<CXXOperatorCallExpr>(this);
if (Op->getOperator() == OO_EqualEqual ||
- Op->getOperator() == OO_ExclaimEqual)
+ Op->getOperator() == OO_ExclaimEqual) {
+ Loc = Op->getOperatorLoc();
+ R1 = Op->getSourceRange();
return true;
+ }
// Fallthrough for generic call handling.
}
box->j;
}
}
+
+namespace test1 {
+struct Foo {
+ int i;
+ bool operator==(const Foo& rhs) {
+ return i == rhs.i;
+ }
+};
+
+#define NOP(x) (x)
+void b(Foo f1, Foo f2) {
+ NOP(f1 == f2); // expected-warning {{expression result unused}}
+}
+#undef NOP
+}