compilerplugins/clang/redundantcast.cxx | 42 +++++---------------- compilerplugins/clang/test/cppunitassertequals.cxx | 6 +-- sc/qa/unit/bugfix-test.cxx | 2 - sc/qa/unit/subsequent_filters-test.cxx | 2 - sw/qa/extras/odfexport/odfexport.cxx | 12 +++--- sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 12 +++--- sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 2 - sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 8 ++-- sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 4 +- sw/qa/extras/uiwriter/uiwriter.cxx | 2 - sw/qa/extras/ww8import/ww8import.cxx | 2 - 11 files changed, 37 insertions(+), 57 deletions(-)
New commits: commit 93aeaa75a4bfd5756b2d3ada59be4f452e320aab Author: Stephan Bergmann <sberg...@redhat.com> Date: Thu Jun 1 14:37:02 2017 +0200 Improve suppression of loplugin:redundantcast in CPPUNIT_ASSERT Change-Id: I65f95e7245f08592ea11cc75e1cf34dcbdf16b40 diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 2c9a6fa49c89..de3353b295c1 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -456,37 +456,6 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp if (ignoreLocation(expr)) { return true; } - // A bit of a rabbit hole here, these expressions look like - // CPPUNIT_ASSERT( bool(aVec.find(p1.get()) == aVec.end()) ) - // If I remove the bool, then another plugin wants me to change it to CPPUNIT_ASSERT_EQUAL, - // but that fails because CppUnit can't do "std::ostream << iterator". - StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(expr->getLocStart())); - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/o3tl/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sfx2/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/postprocess/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sc/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/cppu/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/vcl/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/cppuhelper/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/comphelper/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/connectivity/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sal/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/salhelper/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sw/qa/")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/svl/qa/")) - return true; // Restrict this to "real" casts (compared to uses of braced-init-list, like // @@ -502,6 +471,17 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp return true; } + // See "There might even be good reasons(?) not to warn inside explicit + // casts" block in compilerplugins/clang/test/cppunitassertequals.cxx: + auto const eloc = expr->getExprLoc(); + if (compiler.getSourceManager().isMacroArgExpansion(eloc)) { + auto const name = Lexer::getImmediateMacroName( + eloc, compiler.getSourceManager(), compiler.getLangOpts()); + if (name == "CPPUNIT_ASSERT" || name == "CPPUNIT_ASSERT_MESSAGE") { + return true; + } + } + // See the commit message of d0e7d020fa405ab94f19916ec96fbd4611da0031 // "socket.c -> socket.cxx" for the reason to have // diff --git a/compilerplugins/clang/test/cppunitassertequals.cxx b/compilerplugins/clang/test/cppunitassertequals.cxx index f0b03fa7ffb4..239de58853b3 100644 --- a/compilerplugins/clang/test/cppunitassertequals.cxx +++ b/compilerplugins/clang/test/cppunitassertequals.cxx @@ -48,9 +48,9 @@ void test(bool b1, bool b2, OUString const & s1, OUString const & s2, T t) { CPPUNIT_ASSERT(t.operator ==(t)); // There might even be good reasons(?) not to warn inside explicit casts: - CPPUNIT_ASSERT(bool(b1 && b2)); // expected-error {{redundant functional cast from/to 'bool' [loplugin:redundantcast]}} - CPPUNIT_ASSERT(bool(b1 == b2)); // expected-error {{redundant functional cast from/to 'bool' [loplugin:redundantcast]}} - CPPUNIT_ASSERT(bool(s1 == s2)); // expected-error {{redundant functional cast from/to 'bool' [loplugin:redundantcast]}} + CPPUNIT_ASSERT(bool(b1 && b2)); + CPPUNIT_ASSERT(bool(b1 == b2)); + CPPUNIT_ASSERT(bool(s1 == s2)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx index a899ae468099..a4629a62cd2a 100644 --- a/sc/qa/unit/bugfix-test.cxx +++ b/sc/qa/unit/bugfix-test.cxx @@ -194,7 +194,7 @@ void ScFiltersTest::testTdf98657() xDocSh->DoHardRecalc(); // this was a NaN before the fix - CPPUNIT_ASSERT_EQUAL(double(285.0), rDoc.GetValue(ScAddress(1, 1, 0))); + CPPUNIT_ASSERT_EQUAL(285.0, rDoc.GetValue(ScAddress(1, 1, 0))); xDocSh->DoClose(); } diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 7ca68d89f6e8..8bbad1cb6e60 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -3852,7 +3852,7 @@ void ScFiltersTest::testTdf100458() CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.is()); ScDocument& rDoc = xDocSh->GetDocument(); CPPUNIT_ASSERT(rDoc.HasValueData(0, 0, 0)); - CPPUNIT_ASSERT_EQUAL(double(0.0), rDoc.GetValue(0,0,0)); + CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(0,0,0)); CPPUNIT_ASSERT(!rDoc.HasStringData(0, 0, 0)); xDocSh->DoClose(); } diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 13b9a368fb02..960878b43c0e 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -1301,9 +1301,9 @@ DECLARE_ODFEXPORT_TEST(testTableStyles2, "table_styles_2.odt") xCell1Style->getPropertyValue("CharColor") >>= nInt64; CPPUNIT_ASSERT_EQUAL(sal_Int64(0xFF6600), nInt64); xCell1Style->getPropertyValue("CharContoured") >>= bBool; - CPPUNIT_ASSERT_EQUAL(bool(false), bBool); + CPPUNIT_ASSERT_EQUAL(false, bBool); xCell1Style->getPropertyValue("CharShadowed") >>= bBool; - CPPUNIT_ASSERT_EQUAL(bool(true), bBool); + CPPUNIT_ASSERT_EQUAL(true, bBool); xCell1Style->getPropertyValue("CharStrikeout") >>= nInt32; CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nInt32); xCell1Style->getPropertyValue("CharUnderline") >>= nInt32; @@ -1366,9 +1366,9 @@ DECLARE_ODFEXPORT_TEST(testTableStyles2, "table_styles_2.odt") xCell1Style->getPropertyValue("CharColor") >>= nInt64; CPPUNIT_ASSERT_EQUAL(sal_Int64(0x9900FF), nInt64); xCell1Style->getPropertyValue("CharContoured") >>= bBool; - CPPUNIT_ASSERT_EQUAL(bool(true), bBool); + CPPUNIT_ASSERT_EQUAL(true, bBool); xCell1Style->getPropertyValue("CharShadowed") >>= bBool; - CPPUNIT_ASSERT_EQUAL(bool(false), bBool); + CPPUNIT_ASSERT_EQUAL(false, bBool); xCell1Style->getPropertyValue("CharStrikeout") >>= nInt32; CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32); xCell1Style->getPropertyValue("CharUnderline") >>= nInt32; @@ -1427,9 +1427,9 @@ DECLARE_ODFEXPORT_TEST(testTableStyles2, "table_styles_2.odt") xCell1Style->getPropertyValue("CharColor") >>= nInt64; CPPUNIT_ASSERT_EQUAL(sal_Int64(0), nInt64); xCell1Style->getPropertyValue("CharContoured") >>= bBool; - CPPUNIT_ASSERT_EQUAL(bool(true), bBool); + CPPUNIT_ASSERT_EQUAL(true, bBool); xCell1Style->getPropertyValue("CharShadowed") >>= bBool; - CPPUNIT_ASSERT_EQUAL(bool(true), bBool); + CPPUNIT_ASSERT_EQUAL(true, bBool); xCell1Style->getPropertyValue("CharStrikeout") >>= nInt32; CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nInt32); xCell1Style->getPropertyValue("CharUnderline") >>= nInt32; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index 9a13c5aaef21..d4fa7a410701 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -650,9 +650,9 @@ DECLARE_OOXMLEXPORT_TEST(testFdo65655, "fdo65655.docx") uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); bool bValue = false; xPropertySet->getPropertyValue("HeaderIsShared") >>= bValue; - CPPUNIT_ASSERT_EQUAL(false, bool(bValue)); + CPPUNIT_ASSERT_EQUAL(false, bValue); xPropertySet->getPropertyValue("FooterIsShared") >>= bValue; - CPPUNIT_ASSERT_EQUAL(false, bool(bValue)); + CPPUNIT_ASSERT_EQUAL(false, bValue); } DECLARE_OOXMLEXPORT_TEST(testFDO63053, "fdo63053.docx") @@ -965,16 +965,16 @@ DECLARE_OOXMLEXPORT_TEST(testFdo65718, "fdo65718.docx") // the actual attributes where 'distT', 'distB', 'distL', 'distR' uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32( oox::drawingml::convertEmuToHmm(0) ), getProperty<sal_Int32>(xPropertySet, "TopMargin") ); - CPPUNIT_ASSERT_EQUAL(sal_Int32( oox::drawingml::convertEmuToHmm(0) ), getProperty<sal_Int32>(xPropertySet, "BottomMargin") ); + CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(0), getProperty<sal_Int32>(xPropertySet, "TopMargin") ); + CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(0), getProperty<sal_Int32>(xPropertySet, "BottomMargin") ); // 'getProperty' return 318 (instead of 317.5) // I think this is because it returns an integer, instead of a float. // The actual exporting to DOCX exports the correct value (114300 = 317.5 * 360) // The exporting to DOCX uses the 'SvxLRSpacing' that stores the value in TWIPS (180 TWIPS) // However, the 'LeftMargin' property is an integer property that holds that value in 'MM100' (should hold 317.5, but it is 318) - CPPUNIT_ASSERT_EQUAL(sal_Int32( oox::drawingml::convertEmuToHmm(114300) ), getProperty<sal_Int32>(xPropertySet, "LeftMargin") ); - CPPUNIT_ASSERT_EQUAL(sal_Int32( oox::drawingml::convertEmuToHmm(114300) ), getProperty<sal_Int32>(xPropertySet, "RightMargin") ); + CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(114300), getProperty<sal_Int32>(xPropertySet, "LeftMargin") ); + CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(114300), getProperty<sal_Int32>(xPropertySet, "RightMargin") ); } DECLARE_OOXMLEXPORT_TEST(testFdo64350, "fdo64350.docx") diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 1d94e25938aa..e80e348ca196 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -693,7 +693,7 @@ DECLARE_OOXMLEXPORT_TEST(testComboBoxControl, "combobox-control.docx") CPPUNIT_ASSERT_EQUAL(OUString("Manolo"), getProperty<OUString>(xControl->getControl(), "Text")); uno::Sequence<OUString> aItems = getProperty< uno::Sequence<OUString> >(xControl->getControl(), "StringItemList"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), sal_Int32(aItems.getLength())); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aItems.getLength()); CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems[0]); CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems[1]); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 9fdad718157e..7fc5d19b2db3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -320,7 +320,7 @@ DECLARE_OOXMLEXPORT_TEST(testN764005, "n764005.docx") CPPUNIT_ASSERT(eValue != text::TextContentAnchorType_AS_CHARACTER); bool bValue = true; xPropertySet->getPropertyValue("Opaque") >>= bValue; - CPPUNIT_ASSERT_EQUAL(false, bool(bValue)); + CPPUNIT_ASSERT_EQUAL(false, bValue); } DECLARE_OOXMLEXPORT_TEST(testN766481, "n766481.docx") @@ -877,7 +877,7 @@ DECLARE_OOXMLEXPORT_TEST(testfdo78904, "fdo78904.docx") if (xIndexAccess->getCount()) { uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(oox::drawingml::convertEmuToHmm(0)), getProperty<sal_Int32>(xFrame, "HoriOrientPosition")); + CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(0), getProperty<sal_Int32>(xFrame, "HoriOrientPosition")); } } @@ -1213,7 +1213,7 @@ DECLARE_OOXMLEXPORT_TEST(testWpsOnly, "wps-only.docx") CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_PARAGRAPH, eValue); // Check position, it was 0. This is a shape, so use getPosition(), not a property. - CPPUNIT_ASSERT_EQUAL(sal_Int32(oox::drawingml::convertEmuToHmm(671830)), xShape->getPosition().X); + CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(671830), xShape->getPosition().X); // Left margin was 0, instead of 114300 EMU's. CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xShape, "LeftMargin")); @@ -1232,7 +1232,7 @@ DECLARE_OOXMLEXPORT_TEST(testWpgOnly, "wpg-only.docx") { uno::Reference<drawing::XShape> xShape = getShape(1); // Check position, it was nearly 0. This is a shape, so use getPosition(), not a property. - CPPUNIT_ASSERT_EQUAL(sal_Int32(oox::drawingml::convertEmuToHmm(548005)), xShape->getPosition().X); + CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(548005), xShape->getPosition().X); } DECLARE_OOXMLEXPORT_TEST(testWpgNested, "wpg-nested.docx") diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index ebebedda914b..15aebdab076b 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -606,7 +606,7 @@ DECLARE_OOXMLIMPORT_TEST(testFdo43641, "fdo43641.docx") uno::Reference<container::XIndexAccess> xGroupShape(getShape(1), uno::UNO_QUERY); uno::Reference<drawing::XShape> xLine(xGroupShape->getByIndex(1), uno::UNO_QUERY); // This was 2200, not 2579 in mm100, i.e. the size of the line shape was incorrect. - CPPUNIT_ASSERT_EQUAL(sal_Int32(oox::drawingml::convertEmuToHmm(928440)), xLine->getSize().Width); + CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(928440), xLine->getSize().Width); } DECLARE_OOXMLIMPORT_TEST(testGroupshapeSdt, "groupshape-sdt.docx") @@ -764,7 +764,7 @@ DECLARE_OOXMLIMPORT_TEST(textboxWpsOnly, "textbox-wps-only.docx") DECLARE_OOXMLIMPORT_TEST(testGroupshapeRelsize, "groupshape-relsize.docx") { // This was 43760, i.e. the height of the groupshape was larger than the page height, which is obviously incorrect. - CPPUNIT_ASSERT_EQUAL(sal_Int32(oox::drawingml::convertEmuToHmm(9142730)), getShape(1)->getSize().Height); + CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(9142730), getShape(1)->getSize().Height); } DECLARE_OOXMLIMPORT_TEST(testOleAnchor, "ole-anchor.docx") diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 88be24d04a53..2452ad422c21 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -3193,7 +3193,7 @@ void SwUiWriterTest::testTdf88899() alocale.Language = "en"; alocale.Country = "US"; sal_Int16 key = xNumFormat->getStandardFormat(util::NumberFormat::DATETIME, alocale); - xPropSet->setPropertyValue("NumberFormat", uno::makeAny(sal_Int16(key))); + xPropSet->setPropertyValue("NumberFormat", uno::makeAny(key)); //Inserting Text Content uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextRange> xTextRange(xTextDocument->getText(), uno::UNO_QUERY); diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 4c2c83499405..52cab54b2e61 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -95,7 +95,7 @@ DECLARE_WW8IMPORT_TEST( testTdf105570, "tdf105570.doc" ) SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); SwShellCursor* pShellCursor = pWrtShell->getShellCursor( false ); - SwNodeIndex aIdx = SwNodeIndex( pShellCursor->Start()->nNode ); + SwNodeIndex aIdx = pShellCursor->Start()->nNode; // Find first table SwTableNode* pTableNd = aIdx.GetNode().FindTableNode(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits