From 6299c8cae923198c55d47320fa8a89bbcd5b0f2b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 2 Nov 2021 14:32:10 +0200 Subject: loplugin:constparams Change-Id: Iebeb531fad5cc819b536788925cf8508737198b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124599 Tested-by: Jenkins Reviewed-by: Noel Grandin --- basic/source/comp/exprtree.cxx | 4 ++-- compilerplugins/clang/constparams.cxx | 20 +++++++++++--------- desktop/inc/lib/init.hxx | 2 +- desktop/source/lib/init.cxx | 2 +- include/svtools/valueset.hxx | 2 +- include/xmloff/XMLEventExport.hxx | 2 +- sc/qa/unit/ucalc_formula.cxx | 2 +- sd/inc/sdpage.hxx | 4 ++-- sd/source/core/sdpage_animations.cxx | 4 ++-- sd/source/filter/html/htmlex.cxx | 2 +- svtools/source/control/toolbarmenu.cxx | 2 +- svtools/source/control/valueset.cxx | 2 +- svx/source/svdraw/svdotextpathdecomposition.cxx | 2 +- vcl/backendtest/outputdevice/common.cxx | 2 +- vcl/inc/test/outputdevice.hxx | 2 +- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 2 +- xmloff/source/draw/ximpcustomshape.cxx | 2 +- xmloff/source/script/XMLEventExport.cxx | 2 +- 18 files changed, 31 insertions(+), 29 deletions(-) diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx index a18a740447ec..6b101ce81ca6 100644 --- a/basic/source/comp/exprtree.cxx +++ b/basic/source/comp/exprtree.cxx @@ -74,7 +74,7 @@ SbiExpression::~SbiExpression() { } // Are there parameters without brackets following? This may be a number, // a string, a symbol or also a comma (if the 1st parameter is missing) -static bool DoParametersFollow( SbiParser* p, SbiExprType eCurExpr, SbiToken eTok ) +static bool DoParametersFollow( const SbiParser* p, SbiExprType eCurExpr, SbiToken eTok ) { if( eTok == LPAREN ) { @@ -92,7 +92,7 @@ static bool DoParametersFollow( SbiParser* p, SbiExprType eCurExpr, SbiToken eTo } else // check for default params with reserved names ( e.g. names of tokens ) { - SbiTokenizer tokens( *static_cast(p) ); + SbiTokenizer tokens( *static_cast(p) ); // Urk the Next() / Peek() semantics are... weird tokens.Next(); if ( tokens.Peek() == ASSIGN ) diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx index b7c13750eb5b..950ae91e0b27 100644 --- a/compilerplugins/clang/constparams.cxx +++ b/compilerplugins/clang/constparams.cxx @@ -291,9 +291,11 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar { // check if we're inside a CXXCtorInitializer auto parentsRange = compiler.getASTContext().getParents(*stmt); + auto it = parentsRange.begin(); if ( parentsRange.begin() != parentsRange.end()) { - if (auto cxxConstructorDecl = dyn_cast_or_null(parentsRange.begin()->get())) + const Decl *decl = it->get(); + if (auto cxxConstructorDecl = dyn_cast_or_null(decl)) { for ( auto cxxCtorInitializer : cxxConstructorDecl->inits()) { @@ -317,18 +319,18 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar } } } - if (auto varDecl = dyn_cast_or_null(parentsRange.begin()->get())) + if (auto varDecl = dyn_cast_or_null(decl)) { return isOkForParameter(varDecl->getType()); } } - parmVarDecl->dump(); - stmt->dump(); - report( - DiagnosticsEngine::Warning, - "no parent?", - compat::getBeginLoc(stmt)) - << stmt->getSourceRange(); +// parmVarDecl->dump(); +// stmt->dump(); +// report( +// DiagnosticsEngine::Warning, +// "no parent?", +// compat::getBeginLoc(stmt)) +// << stmt->getSourceRange(); return false; } diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 337c0f23340c..b8918729cff9 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -175,7 +175,7 @@ namespace desktop { queue_type2::reverse_iterator toQueue2(queue_type1::reverse_iterator); void queue(const int type, CallbackData& data); void enqueueUpdatedTypes(); - void enqueueUpdatedType( int type, SfxViewShell* sourceViewShell, int viewId ); + void enqueueUpdatedType( int type, const SfxViewShell* sourceViewShell, int viewId ); /** we frequently want to scan the queue, and mostly when we do so, we only care about the element type so we split the queue in 2 to make the scanning cache friendly. */ diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 4ab45c346697..fe6fd88b1c7b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2189,7 +2189,7 @@ void CallbackFlushHandler::enqueueUpdatedTypes() } } -void CallbackFlushHandler::enqueueUpdatedType( int type, SfxViewShell* viewShell, int viewId ) +void CallbackFlushHandler::enqueueUpdatedType( int type, const SfxViewShell* viewShell, int viewId ) { OString payload = viewShell->getLOKPayload( type, viewId ); if(payload.isEmpty()) diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx index baee0108af9e..9fe1b885e686 100644 --- a/include/svtools/valueset.hxx +++ b/include/svtools/valueset.hxx @@ -233,7 +233,7 @@ private: // selected is returned SVT_DLLPRIVATE ValueSetItem* ImplGetDrawSelectItem(sal_uInt16 nItemId, const bool bFocus, tools::Rectangle& rRect); SVT_DLLPRIVATE void ImplDrawSelect(vcl::RenderContext& rRenderContext, - const tools::Rectangle& rRect, ValueSetItem* pItem, + const tools::Rectangle& rRect, const ValueSetItem* pItem, const bool bFocus, const bool bDrawSel, const bool bSelected, const bool bHover); SVT_DLLPRIVATE void ImplDrawSelect(vcl::RenderContext& rRenderContext); diff --git a/include/xmloff/XMLEventExport.hxx b/include/xmloff/XMLEventExport.hxx index 48198032377f..ad83390b6dc9 100644 --- a/include/xmloff/XMLEventExport.hxx +++ b/include/xmloff/XMLEventExport.hxx @@ -103,7 +103,7 @@ public: /// export a single event (writes element) void ExportSingleEvent( - css::uno::Sequence& rEventValues, + const css::uno::Sequence& rEventValues, const OUString& rApiEventName, bool bUseWhitespace = true ); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index af8d708279a2..9ad8705c0c45 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -95,7 +95,7 @@ void setExpandRefs(bool bExpand) pMod->SetInputOptions(aOpt); } -void testFormulaRefUpdateNameCopySheetCheckTab( ScDocument* pDoc, SCTAB nTab, bool bCheckNames ) +void testFormulaRefUpdateNameCopySheetCheckTab( const ScDocument* pDoc, SCTAB nTab, bool bCheckNames ) { if (bCheckNames) { diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx index ae97ff0b18e1..16315c219603 100644 --- a/sd/inc/sdpage.hxx +++ b/sd/inc/sdpage.hxx @@ -334,10 +334,10 @@ public: bool bEdit ) override; /** callback from the sd::View when a new paragraph for one object on this page is created */ - void onParagraphInserted( ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj ); + void onParagraphInserted( const ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj ); /** callback from the sd::View when a paragraph from one object on this page is removed */ - void onParagraphRemoving( ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj ); + void onParagraphRemoving( const ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj ); /** callback from the sd::View when an object just left text edit mode */ void onEndTextEdit( SdrObject* pObj ); diff --git a/sd/source/core/sdpage_animations.cxx b/sd/source/core/sdpage_animations.cxx index bb16cacdbb7a..34a049c3dc60 100644 --- a/sd/source/core/sdpage_animations.cxx +++ b/sd/source/core/sdpage_animations.cxx @@ -106,7 +106,7 @@ FadeEffect SdPage::GetFadeEffect() const } /** callback from the sd::View when a new paragraph for one object on this page is created */ -void SdPage::onParagraphInserted( ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj ) +void SdPage::onParagraphInserted( const ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj ) { if( mxAnimationNode.is() ) { @@ -121,7 +121,7 @@ void SdPage::onParagraphInserted( ::Outliner* pOutliner, Paragraph const * pPara } /** callback from the sd::View when a paragraph from one object on this page is removed */ -void SdPage::onParagraphRemoving( ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj ) +void SdPage::onParagraphRemoving( const ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj ) { if( mxAnimationNode.is() ) { diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx index 13f12dc69c2f..3e06c07fed38 100644 --- a/sd/source/filter/html/htmlex.cxx +++ b/sd/source/filter/html/htmlex.cxx @@ -304,7 +304,7 @@ OUString HtmlState::SetLink( const OUString& aLink, const OUString& aTarget ) namespace { -OUString getParagraphStyle( SdrOutliner* pOutliner, sal_Int32 nPara ) +OUString getParagraphStyle( const SdrOutliner* pOutliner, sal_Int32 nPara ) { SfxItemSet aParaSet( pOutliner->GetParaAttribs( nPara ) ); diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx index 3c95a6410d64..86edb4613c2d 100644 --- a/svtools/source/control/toolbarmenu.cxx +++ b/svtools/source/control/toolbarmenu.cxx @@ -35,7 +35,7 @@ using namespace ::com::sun::star::accessibility; namespace { -SystemWindow* GetTopMostParentSystemWindow(vcl::Window& rWindow) +SystemWindow* GetTopMostParentSystemWindow(const vcl::Window& rWindow) { // ->manually search topmost system window // required because their might be another system window between this and the top window diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index f8b0267316aa..b3bd235ef249 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -1233,7 +1233,7 @@ ValueSetItem* ValueSet::ImplGetDrawSelectItem(sal_uInt16 nItemId, const bool bFo } void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext, - const tools::Rectangle& rRect, ValueSetItem* pItem, + const tools::Rectangle& rRect, const ValueSetItem* pItem, const bool bFocus, const bool bDrawSel, const bool bSelected, const bool bHover) { diff --git a/svx/source/svdraw/svdotextpathdecomposition.cxx b/svx/source/svdraw/svdotextpathdecomposition.cxx index 4f3144d25851..8f04b356cef7 100644 --- a/svx/source/svdraw/svdotextpathdecomposition.cxx +++ b/svx/source/svdraw/svdotextpathdecomposition.cxx @@ -69,7 +69,7 @@ namespace bool mbRTL : 1; public: - explicit impPathTextPortion(DrawPortionInfo& rInfo) + explicit impPathTextPortion(const DrawPortionInfo& rInfo) : maOffset(rInfo.mrStartPos.X(), rInfo.mrStartPos.Y()), maText(rInfo.maText), mnTextStart(rInfo.mnTextStart), diff --git a/vcl/backendtest/outputdevice/common.cxx b/vcl/backendtest/outputdevice/common.cxx index 8a5b80cb8dec..c8e291f787ec 100644 --- a/vcl/backendtest/outputdevice/common.cxx +++ b/vcl/backendtest/outputdevice/common.cxx @@ -720,7 +720,7 @@ tools::Polygon OutputDeviceTestCommon::createClosedBezierLoop(const tools::Recta return aPolygon; } -basegfx::B2DPolygon OutputDeviceTestCommon::createOpenPolygon(tools::Rectangle& rRect, int nOffset) +basegfx::B2DPolygon OutputDeviceTestCommon::createOpenPolygon(const tools::Rectangle& rRect, int nOffset) { int nMidOffset = rRect.GetWidth() / 2; basegfx::B2DPolygon aPolygon{ diff --git a/vcl/inc/test/outputdevice.hxx b/vcl/inc/test/outputdevice.hxx index c63c97a1e48c..e205dfb80909 100644 --- a/vcl/inc/test/outputdevice.hxx +++ b/vcl/inc/test/outputdevice.hxx @@ -71,7 +71,7 @@ public: static tools::Polygon createDropShapePolygon(); static basegfx::B2DPolygon createHalfEllipsePolygon(); static tools::Polygon createClosedBezierLoop(const tools::Rectangle& rRect); - static basegfx::B2DPolygon createOpenPolygon(tools::Rectangle& rRect, int nOffset = 4); + static basegfx::B2DPolygon createOpenPolygon(const tools::Rectangle& rRect, int nOffset = 4); static void createHorizontalVerticalDiagonalLinePoints(tools::Rectangle rRect, Point& rHorizontalLinePoint1, Point& rHorizontalLinePoint2, diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index fd54128f5cc5..9bc82dfb6c92 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -4171,7 +4171,7 @@ static bool lcl_FindInCommand( return bRet; } -static OUString lcl_trim(OUString& sValue) +static OUString lcl_trim(const OUString& sValue) { // it seems, all kind of quotation marks are allowed around index type identifiers // TODO apply this on bookmarks, too, if needed diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx index ebaf15651950..cf794da63df6 100644 --- a/xmloff/source/draw/ximpcustomshape.cxx +++ b/xmloff/source/draw/ximpcustomshape.cxx @@ -426,7 +426,7 @@ static bool GetNextParameter( css::drawing::EnhancedCustomShapeParameter& rParam static void GetPosition3D( std::vector< css::beans::PropertyValue >& rDest, // e.g. draw:extrusion-viewpoint std::string_view rValue, const EnhancedCustomShapeTokenEnum eDestProp, - SvXMLUnitConverter& rUnitConverter ) + const SvXMLUnitConverter& rUnitConverter ) { drawing::Position3D aPosition3D; if ( rUnitConverter.convertPosition3D( aPosition3D, rValue ) ) diff --git a/xmloff/source/script/XMLEventExport.cxx b/xmloff/source/script/XMLEventExport.cxx index 285bd487c35b..5aed1c76c330 100644 --- a/xmloff/source/script/XMLEventExport.cxx +++ b/xmloff/source/script/XMLEventExport.cxx @@ -150,7 +150,7 @@ void XMLEventExport::ExportExt( Reference const & rAccess ) /// export a singular event and write container void XMLEventExport::ExportSingleEvent( - Sequence& rEventValues, + const Sequence& rEventValues, const OUString& rApiEventName, bool bUseWhitespace ) { -- cgit