summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-02-08 07:48:59 +0100
committerStephan Bergmann <sbergman@redhat.com>2021-02-08 09:15:01 +0100
commit6b00d0576a310796590631d14c54d7d5ea6814ac (patch)
tree2e11a4454592be39cfeaa68458cae964d8cdef5e /compilerplugins
parent17149f65f03a34e88bb4a10abcd20e6891f5d7ca (diff)
Improve loplugin:cppunitassertequal for CPPUNIT_ASSERT(a && b)
...by re-enabling the code temporarily #if'ed-out in a528392e71bc70136021be4e3d83732fccbb885e "Fixed/improved loplugin:cppunitassertequals" (and which then triggers lots of other lopglugin:cppunitassertequal CPPUNIT_ASSERT -> CPPUNIT_ASSERT_EQUAL warnings). For two css::uno::Reference equality comparisons in cppu/qa/test_any.cxx, it was more straightforward to rewrite them with an explicit call to operator == (which silences loplugin:cppunitassertequal) than to adapt them to CPPUNIT_ASSERT_EQUAL's requirement for arguments of identical types. In sc/qa/unit/ucalc_pivottable.cxx, ScDPItemData needs toString, which has been implemented trivially for now, but might want to combine that with the DEBUG_PIVOT_TABLE-only ScDPItemData::Dump. Change-Id: Iae6d09cf69bd4e52fe4411bba9e50c48e696291c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110546 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/cppunitassertequals.cxx2
-rw-r--r--compilerplugins/clang/test/cppunitassertequals.cxx2
2 files changed, 0 insertions, 4 deletions
diff --git a/compilerplugins/clang/cppunitassertequals.cxx b/compilerplugins/clang/cppunitassertequals.cxx
index 4f5e364540c8..56f13b822163 100644
--- a/compilerplugins/clang/cppunitassertequals.cxx
+++ b/compilerplugins/clang/cppunitassertequals.cxx
@@ -191,7 +191,6 @@ void CppunitAssertEquals::checkExpr(
reportEquals(range, name, op == BO_NE, e->getLHS(), e->getRHS());
return;
}
-#if 0 // TODO: enable later
if ((!negated && op == BO_LAnd) || (negated && op == BO_LOr)) {
report(
DiagnosticsEngine::Warning,
@@ -199,7 +198,6 @@ void CppunitAssertEquals::checkExpr(
<< name << range;
return;
}
-#endif
return;
}
if (auto const e = dyn_cast<CXXOperatorCallExpr>(expr)) {
diff --git a/compilerplugins/clang/test/cppunitassertequals.cxx b/compilerplugins/clang/test/cppunitassertequals.cxx
index 0eb1b4e3cfd9..9fe35cfc6919 100644
--- a/compilerplugins/clang/test/cppunitassertequals.cxx
+++ b/compilerplugins/clang/test/cppunitassertequals.cxx
@@ -23,14 +23,12 @@ void test(
bool b1, bool b2, OUString const & s1, OUString const & s2, T t, void * p, std::nullptr_t n)
{
CppUnit::Asserter::failIf(b1,"");
-#if 0 // TODO: enable later
CPPUNIT_ASSERT(b1 && b2); // expected-error {{rather split into two CPPUNIT_ASSERT [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT((b1 && b2)); // expected-error {{rather split into two CPPUNIT_ASSERT [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT(!(b1 || b2)); // expected-error {{rather split into two CPPUNIT_ASSERT [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT(!(b1 && b2));
CPPUNIT_ASSERT(!!(b1 && b2)); // expected-error {{rather split into two CPPUNIT_ASSERT [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT_MESSAGE("", b1 && b2); // expected-error {{rather split into two CPPUNIT_ASSERT_MESSAGE [loplugin:cppunitassertequals]}}
-#endif
CPPUNIT_ASSERT(b1 == b2); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT(b1 != b2);
CPPUNIT_ASSERT((b1 == b2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}