diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-03 09:29:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-03 14:03:54 +0200 |
commit | 7cc1d3437a48140382773bf41401a46a3ced4706 (patch) | |
tree | 5e038178bb0b2699bb9314bd02fb7e197597ecb2 | |
parent | b912eafa33227a5622c5a4310948cfa07c984726 (diff) |
loplugin:unnecessaryparen small improvement
when calling a function, and passing only one arg, but the
function has defaulted args, we were ignoring this case.
Change-Id: I86517f18e30531127664088ddc09ef96dbd8bdf5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115033
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | compilerplugins/clang/test/unnecessaryparen.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/unnecessaryparen.cxx | 9 | ||||
-rw-r--r-- | extensions/source/dbpilots/groupboxwiz.cxx | 2 | ||||
-rw-r--r-- | filter/source/svg/svgwriter.cxx | 2 | ||||
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 6 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/excel/excrecds.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/xcl97/xcl97rec.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationmanager.cxx | 4 | ||||
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape2d.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 10 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageMarginControl.cxx | 2 | ||||
-rw-r--r-- | tools/source/generic/poly.cxx | 4 | ||||
-rw-r--r-- | vcl/qt5/Qt5Menu.cxx | 2 | ||||
-rw-r--r-- | vcl/source/helper/evntpost.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/print/glyphset.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/style/impastpl.cxx | 14 |
19 files changed, 46 insertions, 37 deletions
diff --git a/compilerplugins/clang/test/unnecessaryparen.cxx b/compilerplugins/clang/test/unnecessaryparen.cxx index f932cd312558..ccc2b4ce6556 100644 --- a/compilerplugins/clang/test/unnecessaryparen.cxx +++ b/compilerplugins/clang/test/unnecessaryparen.cxx @@ -113,6 +113,8 @@ int main() BrowseMode nBits = ( BrowseMode::Modules | BrowseMode::Top ); // expected-error {{parentheses immediately inside vardecl statement [loplugin:unnecessaryparen]}} (void)nBits; + + OUString::number((v2+1)); // expected-error {{parentheses immediately inside single-arg call [loplugin:unnecessaryparen]}} }; struct B { operator bool() const; }; diff --git a/compilerplugins/clang/unnecessaryparen.cxx b/compilerplugins/clang/unnecessaryparen.cxx index d39dd074eb43..eb53c449cd77 100644 --- a/compilerplugins/clang/unnecessaryparen.cxx +++ b/compilerplugins/clang/unnecessaryparen.cxx @@ -368,9 +368,16 @@ bool UnnecessaryParen::VisitCallExpr(const CallExpr* callExpr) { if (ignoreLocation(callExpr)) return true; - if (callExpr->getNumArgs() != 1 || isa<CXXOperatorCallExpr>(callExpr)) + if (callExpr->getNumArgs() == 0 || isa<CXXOperatorCallExpr>(callExpr)) return true; + // if we are calling a >1 arg method, are we using the defaults? + if (callExpr->getNumArgs() > 1) + { + if (!isa<CXXDefaultArgExpr>(callExpr->getArg(1))) + return true; + } + auto parenExpr = dyn_cast<ParenExpr>(ignoreAllImplicit(callExpr->getArg(0))); if (!parenExpr) return true; diff --git a/extensions/source/dbpilots/groupboxwiz.cxx b/extensions/source/dbpilots/groupboxwiz.cxx index 9d74990ee0ac..ead0e4a4e48e 100644 --- a/extensions/source/dbpilots/groupboxwiz.cxx +++ b/extensions/source/dbpilots/groupboxwiz.cxx @@ -227,7 +227,7 @@ namespace dbp for (sal_Int32 i=0; i<m_xExistingRadios->n_children(); ++i) { rSettings.aLabels.push_back(m_xExistingRadios->get_text(i)); - rSettings.aValues.push_back(OUString::number((i + 1))); + rSettings.aValues.push_back(OUString::number(i + 1)); } return true; diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index dded11e4b86f..26421884212b 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -1437,7 +1437,7 @@ void SVGTextWriter::implWriteBulletChars() // Add ref attribute sRefId = "#bullet-char-template-" + - OUString::number( ( rInfo.cBulletChar ) ); + OUString::number( rInfo.cBulletChar ); mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, sRefId ); SvXMLElementExport aRefElem( mrExport, XML_NAMESPACE_NONE, "use", true, true ); diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index cdd2ebb35c47..a8532d206d31 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -1174,7 +1174,7 @@ void XmlFilterBase::exportCustomFragments() { uno::Reference<xml::dom::XDocument> customXmlDom = customXmlDomlist[j]; uno::Reference<xml::dom::XDocument> customXmlDomProps = customXmlDomPropslist[j]; - const OUString fragmentPath = "customXml/item" + OUString::number((j+1)) + ".xml"; + const OUString fragmentPath = "customXml/item" + OUString::number(j+1) + ".xml"; if (customXmlDom.is()) { addRelation(oox::getRelationship(Relationship::CUSTOMXML), OUString("../" + fragmentPath)); @@ -1190,7 +1190,7 @@ void XmlFilterBase::exportCustomFragments() { uno::Reference<xml::sax::XSAXSerializable> serializer(customXmlDomProps, uno::UNO_QUERY); uno::Reference<xml::sax::XWriter> writer = xml::sax::Writer::create(comphelper::getProcessComponentContext()); - writer->setOutputStream(openFragmentStream("customXml/itemProps"+OUString::number((j+1))+".xml", + writer->setOutputStream(openFragmentStream("customXml/itemProps"+OUString::number(j+1)+".xml", "application/vnd.openxmlformats-officedocument.customXmlProperties+xml")); serializer->serialize(uno::Reference<xml::sax::XDocumentHandler>(writer, uno::UNO_QUERY_THROW), uno::Sequence<beans::StringPair>()); @@ -1198,7 +1198,7 @@ void XmlFilterBase::exportCustomFragments() // Adding itemprops's relationship entry to item.xml.rels file addRelation(openFragmentStream(fragmentPath, "application/xml"), oox::getRelationship(Relationship::CUSTOMXMLPROPS), - OUString("itemProps"+OUString::number((j+1))+".xml")); + OUString("itemProps"+OUString::number(j+1)+".xml")); } } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 5b16931da1d3..1e94c7bd68ab 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -637,7 +637,7 @@ void DrawingML::WriteGrabBagGradientFill( const Sequence< PropertyValue >& aGrad default: mpFS->singleElementNS( XML_a, XML_lin, XML_ang, - OString::number((((3600 - rGradient.Angle + 900) * 6000) % 21600000))); + OString::number(((3600 - rGradient.Angle + 900) * 6000) % 21600000)); break; case awt::GradientStyle_RADIAL: WriteGradientPath(rGradient, mpFS, true); @@ -674,7 +674,7 @@ void DrawingML::WriteGradientFill(awt::Gradient rGradient, awt::Gradient rTransp mpFS->endElementNS( XML_a, XML_gsLst ); mpFS->singleElementNS( XML_a, XML_lin, XML_ang, - OString::number((((3600 - rGradient.Angle + 900) * 6000) % 21600000))); + OString::number(((3600 - rGradient.Angle + 900) * 6000) % 21600000)); break; } @@ -702,7 +702,7 @@ void DrawingML::WriteGradientFill(awt::Gradient rGradient, awt::Gradient rTransp mpFS->endElementNS(XML_a, XML_gsLst); mpFS->singleElementNS( XML_a, XML_lin, XML_ang, - OString::number((((3600 - rGradient.Angle + 900) * 6000) % 21600000))); + OString::number(((3600 - rGradient.Angle + 900) * 6000) % 21600000)); break; } diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 7a215c8d1f41..b73c695391bd 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -590,7 +590,7 @@ static OString lcl_GetValue( sal_uInt8 nType, double fVal, const XclExpString* p { case EXC_AFTYPE_STRING: return XclXmlUtils::ToOString( *pStr ); case EXC_AFTYPE_DOUBLE: return OString::number( fVal ); - case EXC_AFTYPE_BOOLERR: return OString::number( ( fVal != 0 ? 1 : 0 ) ); + case EXC_AFTYPE_BOOLERR: return OString::number( fVal != 0 ? 1 : 0 ); default: return OString(); } } @@ -825,7 +825,7 @@ void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm ) rWorksheet->singleElement( XML_top10, XML_top, ToPsz( get_flag( nFlags, EXC_AFFLAG_TOP10TOP ) ), XML_percent, ToPsz( get_flag( nFlags, EXC_AFFLAG_TOP10PERC ) ), - XML_val, OString::number((nFlags >> 7)) + XML_val, OString::number(nFlags >> 7) // OOXTODO: XML_filterVal ); } diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index 485bdc38b784..de7a3762ac8b 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -1384,7 +1384,7 @@ void ExcBundlesheet8::SaveXml( XclExpXmlStream& rStrm ) rStrm.GetCurrentStream()->singleElement( XML_sheet, XML_name, sUnicodeName.toUtf8(), - XML_sheetId, OString::number( ( nTab+1 ) ), + XML_sheetId, OString::number( nTab+1 ), XML_state, nGrbit == 0x0000 ? "visible" : "hidden", FSNS( XML_r, XML_id ), sId.toUtf8() ); } diff --git a/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx b/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx index 4e57e1c2a42a..8a009fada4db 100644 --- a/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx +++ b/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx @@ -357,7 +357,7 @@ OUString ScAccessiblePreviewHeaderCell::createAccessibleName() else { // name of row header - sName += OUString::number( ( maCellPos.Row() + 1 ) ); + sName += OUString::number( maCellPos.Row() + 1 ); } return sName; diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 28f09dd8b237..4f7612af6d47 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -767,7 +767,7 @@ void AnnotationManagerImpl::SelectNextAnnotation(bool bForward) ++iter; if( iter != aAnnotations.end() ) { - SelectAnnotation( (*iter) ); + SelectAnnotation( *iter ); return; } } @@ -786,7 +786,7 @@ void AnnotationManagerImpl::SelectNextAnnotation(bool bForward) if (iter != aAnnotations.end() && iter != aAnnotations.begin()) { --iter; - SelectAnnotation( (*iter) ); + SelectAnnotation( *iter ); return; } } diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index 736634c42205..046f5a783c31 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -332,7 +332,7 @@ void EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( OUString if ( nPara & 0x400 ) { rParameter += "?"; - rParameter += OUString::number( ( nPara & 0xff ) ); + rParameter += OUString::number( nPara & 0xff ); rParameter += " "; } else @@ -351,7 +351,7 @@ void EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( OUString case DFF_Prop_adjust10Value : { rParameter += "$"; - rParameter += OUString::number( ( nPara - DFF_Prop_adjustValue ) ); + rParameter += OUString::number( nPara - DFF_Prop_adjustValue ); rParameter += " "; } break; diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 429ae90f7775..6527696bce29 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1491,11 +1491,11 @@ void DocxExport::WriteCustomXml() { m_rFilter.addRelation( m_pDocumentFS->getOutputStream(), oox::getRelationship(Relationship::CUSTOMXML), - OUString("../customXml/item"+OUString::number((j+1))+".xml" )); + OUString("../customXml/item"+OUString::number(j+1)+".xml" )); uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDom, uno::UNO_QUERY ); uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() ); - writer->setOutputStream( GetFilter().openFragmentStream( "customXml/item"+OUString::number((j+1))+".xml", + writer->setOutputStream( GetFilter().openFragmentStream( "customXml/item"+OUString::number(j+1)+".xml", "application/xml" ) ); serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ), uno::Sequence< beans::StringPair >() ); @@ -1505,16 +1505,16 @@ void DocxExport::WriteCustomXml() { uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDomProps, uno::UNO_QUERY ); uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() ); - writer->setOutputStream( GetFilter().openFragmentStream( "customXml/itemProps"+OUString::number((j+1))+".xml", + writer->setOutputStream( GetFilter().openFragmentStream( "customXml/itemProps"+OUString::number(j+1)+".xml", "application/vnd.openxmlformats-officedocument.customXmlProperties+xml" ) ); serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ), uno::Sequence< beans::StringPair >() ); // Adding itemprops's relationship entry to item.xml.rels file - m_rFilter.addRelation( GetFilter().openFragmentStream( "customXml/item"+OUString::number((j+1))+".xml", + m_rFilter.addRelation( GetFilter().openFragmentStream( "customXml/item"+OUString::number(j+1)+".xml", "application/xml" ) , oox::getRelationship(Relationship::CUSTOMXMLPROPS), - OUString("itemProps"+OUString::number((j+1))+".xml" )); + OUString("itemProps"+OUString::number(j+1)+".xml" )); } } } diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx index d3f2a0d91642..5f40751cda2e 100644 --- a/sw/source/uibase/sidebar/PageMarginControl.cxx +++ b/sw/source/uibase/sidebar/PageMarginControl.cxx @@ -577,7 +577,7 @@ void PageMarginControl::StoreUserCustomValues() SvtViewOptions aWinOpt5( EViewType::Window, SWPAGE_MIRROR_GVALUE ); aSeq[0].Name = "mbMirrored"; - aSeq[0].Value <<= OUString::number( (m_bMirrored ? 1 : 0) ); + aSeq[0].Value <<= OUString::number( m_bMirrored ? 1 : 0 ); aWinOpt5.SetUserData( aSeq ); } diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 05d35f7d1385..292247478aac 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -144,7 +144,7 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, std::unique_ptr<tools::Polygon> pEllipsePoly( new tools::Polygon( Point(), nHorzRound, nVertRound ) ); sal_uInt16 i, nEnd, nSize4 = pEllipsePoly->GetSize() >> 2; - ImplInitSize((pEllipsePoly->GetSize() + 1)); + ImplInitSize(pEllipsePoly->GetSize() + 1); const Point* pSrcAry = pEllipsePoly->GetConstPointAry(); Point* pDstAry = mxPointAry.get(); @@ -280,7 +280,7 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, c nStart = 1; nEnd = nPoints + 1; - ImplInitSize((nPoints + 2)); + ImplInitSize(nPoints + 2); mxPointAry[0] = aCenter2; mxPointAry[nEnd] = aCenter2; } diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx index b743197c8aa6..75ab745de2b4 100644 --- a/vcl/qt5/Qt5Menu.cxx +++ b/vcl/qt5/Qt5Menu.cxx @@ -650,7 +650,7 @@ void Qt5Menu::ShowCloseButton(bool bShow) aIcon = QIcon::fromTheme("window-close-symbolic"); else aIcon = QIcon( - QPixmap::fromImage((toQImage(Image(StockImage::Yes, SV_RESID_BITMAP_CLOSEDOC))))); + QPixmap::fromImage(toQImage(Image(StockImage::Yes, SV_RESID_BITMAP_CLOSEDOC)))); pButton = new QPushButton(mpQMenuBar); pButton->setIcon(aIcon); pButton->setFlat(true); diff --git a/vcl/source/helper/evntpost.cxx b/vcl/source/helper/evntpost.cxx index 710ac0ce197c..9e2106f492cb 100644 --- a/vcl/source/helper/evntpost.cxx +++ b/vcl/source/helper/evntpost.cxx @@ -42,7 +42,7 @@ EventPoster::~EventPoster() void EventPoster::Post() { DBG_TESTSOLARMUTEX(); - m_nId = Application::PostUserEvent( ( LINK( this, EventPoster, DoEvent_Impl ) ) ); + m_nId = Application::PostUserEvent( LINK( this, EventPoster, DoEvent_Impl ) ); } IMPL_LINK( EventPoster, DoEvent_Impl, void*, /*p*/, void ) diff --git a/vcl/unx/generic/print/glyphset.cxx b/vcl/unx/generic/print/glyphset.cxx index d83907038b25..6b0475a62bc3 100644 --- a/vcl/unx/generic/print/glyphset.cxx +++ b/vcl/unx/generic/print/glyphset.cxx @@ -153,7 +153,7 @@ GlyphSet::GetReencodedFontName (rtl_TextEncoding nEnc, std::string_view rFontNam { return OString::Concat(rFontName) + "-enc" - + OString::number ((nEnc - RTL_TEXTENCODING_USER_START)); + + OString::number(nEnc - RTL_TEXTENCODING_USER_START); } else { diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 87bfb050164a..af5885d3e354 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -3595,7 +3595,7 @@ void SchXMLExportHelper_Impl::exportDataPoints( if( aLastPoint.mnRepeat > 1 ) mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_REPEATED, - OUString::number( ( aLastPoint.mnRepeat ) )); + OUString::number( aLastPoint.mnRepeat )); for (auto& deletedLegendEntry : deletedLegendEntriesSeq) { @@ -3621,7 +3621,7 @@ void SchXMLExportHelper_Impl::exportDataPoints( if( aLastPoint.mnRepeat > 1 ) mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_REPEATED, - OUString::number( ( aLastPoint.mnRepeat ) )); + OUString::number( aLastPoint.mnRepeat )); for (auto& deletedLegendEntry : deletedLegendEntriesSeq) { diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx index 34dc16a32cc0..0a3e2e97595f 100644 --- a/xmloff/source/style/impastpl.cxx +++ b/xmloff/source/style/impastpl.cxx @@ -103,15 +103,15 @@ data2string(void *data, case typelib_TypeClass_BOOLEAN: return *static_cast<const sal_Bool*>(data) ? OUString("true") : OUString("false"); case typelib_TypeClass_BYTE: - return OUString::number((*static_cast<const sal_Int8*>(data))); + return OUString::number(*static_cast<const sal_Int8*>(data)); case typelib_TypeClass_SHORT: - return OUString::number((*static_cast<const sal_Int16*>(data))); + return OUString::number(*static_cast<const sal_Int16*>(data)); case typelib_TypeClass_LONG: - return OUString::number((*static_cast<const sal_Int32*>(data))); + return OUString::number(*static_cast<const sal_Int32*>(data)); case typelib_TypeClass_HYPER: - return OUString::number((*static_cast<const sal_Int64*>(data))); + return OUString::number(*static_cast<const sal_Int64*>(data)); case typelib_TypeClass_UNSIGNED_SHORT: - return OUString::number((*static_cast<const sal_uInt16*>(data))); + return OUString::number(*static_cast<const sal_uInt16*>(data)); case typelib_TypeClass_UNSIGNED_LONG: return OUString::number((*static_cast<const sal_uInt32*>(data)), 16); case typelib_TypeClass_UNSIGNED_HYPER: @@ -121,7 +121,7 @@ data2string(void *data, case typelib_TypeClass_DOUBLE: return OUString::number(*static_cast<const double*>(data)); case typelib_TypeClass_CHAR: - return ("U+" + OUString::number((*static_cast<const sal_uInt16*>(data)))); + return ("U+" + OUString::number(*static_cast<const sal_uInt16*>(data))); case typelib_TypeClass_STRING: return *static_cast<OUString*>(data); case typelib_TypeClass_TYPE: @@ -132,7 +132,7 @@ data2string(void *data, case typelib_TypeClass_STRUCT: return struct2string(data, type->pType); case typelib_TypeClass_ENUM: - return OUString::number((*static_cast<const sal_Int32*>(data))); + return OUString::number(*static_cast<const sal_Int32*>(data)); default: assert(false); // this cannot happen I hope break; |