From b09deb075319c1c19f91e3a6f64429b61682ebf8 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 28 Jul 2017 11:47:51 +0200 Subject: loplugin:constparams handle constructors had to change the structure of the plugin considerably, was too messy to structure it to do the calculations on a per-function basis Change-Id: I4edee7735f726101105c607368124a08dba21086 Reviewed-on: https://gerrit.libreoffice.org/40516 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../inc/extended/accessibleiconchoicectrl.hxx | 2 +- accessibility/inc/extended/accessiblelistbox.hxx | 2 +- .../source/extended/accessibleiconchoicectrl.cxx | 2 +- .../source/extended/accessiblelistbox.cxx | 2 +- basic/source/basmgr/basmgr.cxx | 4 +- basic/source/runtime/iosys.cxx | 8 +- comphelper/source/misc/backupfilehelper.cxx | 4 +- compilerplugins/clang/constparams.cxx | 248 ++++++++++++--------- compilerplugins/clang/test/constparams.cxx | 27 +++ connectivity/source/drivers/file/fcode.cxx | 2 +- connectivity/source/drivers/file/fcomp.cxx | 4 +- connectivity/source/drivers/firebird/Blob.cxx | 2 +- connectivity/source/drivers/firebird/Blob.hxx | 2 +- connectivity/source/drivers/firebird/Clob.cxx | 2 +- connectivity/source/drivers/firebird/Clob.hxx | 2 +- .../source/drivers/firebird/Connection.cxx | 4 +- .../source/drivers/firebird/Connection.hxx | 4 +- connectivity/source/drivers/firebird/Tables.hxx | 2 +- connectivity/source/drivers/firebird/Users.cxx | 2 +- connectivity/source/drivers/firebird/Users.hxx | 2 +- .../drivers/postgresql/pq_resultsetmetadata.cxx | 2 +- .../drivers/postgresql/pq_resultsetmetadata.hxx | 2 +- connectivity/source/inc/file/fcode.hxx | 2 +- connectivity/source/inc/file/fcomp.hxx | 4 +- cppcanvas/source/mtfrenderer/textaction.cxx | 24 +- .../source/primitive2d/sceneprimitive2d.cxx | 2 +- extensions/source/bibliography/datman.cxx | 4 +- extensions/source/bibliography/framectr.cxx | 2 +- .../source/config/ldap/ldapuserprofilebe.cxx | 2 +- .../source/config/ldap/ldapuserprofilebe.hxx | 2 +- extensions/source/update/ui/updatecheckui.cxx | 2 +- formula/source/core/api/FormulaCompiler.cxx | 2 +- framework/inc/uielement/menubarmanager.hxx | 4 +- framework/inc/xml/saxnamespacefilter.hxx | 2 +- framework/inc/xml/toolboxdocumenthandler.hxx | 2 +- framework/source/fwe/xml/saxnamespacefilter.cxx | 2 +- .../source/fwe/xml/toolboxdocumenthandler.cxx | 2 +- idl/inc/database.hxx | 4 +- idl/source/prj/database.cxx | 4 +- include/basic/basmgr.hxx | 4 +- include/linguistic/lngprophelp.hxx | 14 +- include/registry/registry.hxx | 4 +- include/sfx2/app.hxx | 2 +- include/sfx2/frame.hxx | 2 +- include/svl/stylepool.hxx | 2 +- include/svl/zformat.hxx | 4 +- include/vcl/FilterConfigItem.hxx | 4 +- include/vcl/filter/pdfdocument.hxx | 2 +- linguistic/source/convdicxml.hxx | 2 +- linguistic/source/lngprophelp.cxx | 14 +- sfx2/source/appl/appbas.cxx | 2 +- sfx2/source/appl/helpinterceptor.cxx | 2 +- sfx2/source/appl/helpinterceptor.hxx | 2 +- sfx2/source/appl/impldde.cxx | 4 +- sfx2/source/dialog/recfloat.cxx | 2 +- sfx2/source/doc/sfxbasemodel.cxx | 4 +- sfx2/source/inc/docundomanager.hxx | 2 +- sfx2/source/inc/recfloat.hxx | 2 +- sfx2/source/view/frame.cxx | 2 +- smoketest/libtest.cxx | 2 +- solenv/CompilerTest_compilerplugins_clang.mk | 1 + store/source/lockbyte.cxx | 8 +- svl/source/items/stylepool.cxx | 4 +- svl/source/numbers/numfmuno.cxx | 2 +- svl/source/numbers/numfmuno.hxx | 2 +- svl/source/numbers/zformat.cxx | 4 +- svtools/source/graphic/grfcache.cxx | 8 +- svtools/source/graphic/grfcache.hxx | 4 +- svtools/source/uno/treecontrolpeer.cxx | 2 +- sw/source/filter/ww8/ww8par5.cxx | 3 +- toolkit/source/awt/stylesettings.cxx | 2 +- .../source/controls/grid/sortablegriddatamodel.cxx | 2 +- vcl/inc/unx/glyphcache.hxx | 2 +- vcl/opengl/PackedTextureAtlas.cxx | 4 +- vcl/source/filter/FilterConfigItem.cxx | 4 +- vcl/source/filter/graphicfilter.cxx | 2 +- vcl/source/filter/ipdf/pdfdocument.cxx | 2 +- vcl/source/filter/jpeg/JpegWriter.cxx | 2 +- vcl/source/outdev/bitmap.cxx | 4 +- vcl/unx/generic/glyphs/glyphcache.cxx | 2 +- vcl/unx/generic/print/genprnpsp.cxx | 4 +- xmlscript/source/xmldlg_imexp/imp_share.hxx | 4 +- 82 files changed, 307 insertions(+), 240 deletions(-) create mode 100644 compilerplugins/clang/test/constparams.cxx diff --git a/accessibility/inc/extended/accessibleiconchoicectrl.hxx b/accessibility/inc/extended/accessibleiconchoicectrl.hxx index 3d83f7762bf9..b97e5bc70ab3 100644 --- a/accessibility/inc/extended/accessibleiconchoicectrl.hxx +++ b/accessibility/inc/extended/accessibleiconchoicectrl.hxx @@ -61,7 +61,7 @@ namespace accessibility @param _xParent is our parent accessible object */ - AccessibleIconChoiceCtrl( SvtIconChoiceCtrl& _rIconCtrl, + AccessibleIconChoiceCtrl( SvtIconChoiceCtrl const & _rIconCtrl, const css::uno::Reference< css::accessibility::XAccessible >& _xParent ); // XTypeProvider diff --git a/accessibility/inc/extended/accessiblelistbox.hxx b/accessibility/inc/extended/accessiblelistbox.hxx index 924eb9347d15..374d99ad5c77 100644 --- a/accessibility/inc/extended/accessiblelistbox.hxx +++ b/accessibility/inc/extended/accessiblelistbox.hxx @@ -74,7 +74,7 @@ namespace accessibility @param _xParent is our parent accessible object */ - AccessibleListBox( SvTreeListBox& _rListBox, + AccessibleListBox( SvTreeListBox const & _rListBox, const css::uno::Reference< css::accessibility::XAccessible >& _xParent ); // XTypeProvider diff --git a/accessibility/source/extended/accessibleiconchoicectrl.cxx b/accessibility/source/extended/accessibleiconchoicectrl.cxx index 6a2c77955b00..0f66fbc7d46c 100644 --- a/accessibility/source/extended/accessibleiconchoicectrl.cxx +++ b/accessibility/source/extended/accessibleiconchoicectrl.cxx @@ -44,7 +44,7 @@ namespace accessibility // Ctor() and Dtor() - AccessibleIconChoiceCtrl::AccessibleIconChoiceCtrl( SvtIconChoiceCtrl& _rIconCtrl, const Reference< XAccessible >& _xParent ) : + AccessibleIconChoiceCtrl::AccessibleIconChoiceCtrl( SvtIconChoiceCtrl const & _rIconCtrl, const Reference< XAccessible >& _xParent ) : VCLXAccessibleComponent( _rIconCtrl.GetWindowPeer() ), m_xParent ( _xParent ) diff --git a/accessibility/source/extended/accessiblelistbox.cxx b/accessibility/source/extended/accessiblelistbox.cxx index c19499de7dc2..8c5765835bb7 100644 --- a/accessibility/source/extended/accessiblelistbox.cxx +++ b/accessibility/source/extended/accessiblelistbox.cxx @@ -49,7 +49,7 @@ namespace accessibility // Ctor() and Dtor() - AccessibleListBox::AccessibleListBox( SvTreeListBox& _rListBox, const Reference< XAccessible >& _xParent ) : + AccessibleListBox::AccessibleListBox( SvTreeListBox const & _rListBox, const Reference< XAccessible >& _xParent ) : VCLXAccessibleComponent( _rListBox.GetWindowPeer() ), m_xParent( _xParent ) diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index 9189d7538df8..823e2a04fd63 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -438,7 +438,7 @@ BasicLibInfo* BasicLibInfo::Create( SotStorageStream& rSStream ) return pInfo; } -BasicManager::BasicManager( SotStorage& rStorage, const OUString& rBaseURL, StarBASIC* pParentFromStdLib, OUString* pLibPath, bool bDocMgr ) : mbDocMgr( bDocMgr ) +BasicManager::BasicManager( SotStorage& rStorage, const OUString& rBaseURL, StarBASIC* pParentFromStdLib, OUString const * pLibPath, bool bDocMgr ) : mbDocMgr( bDocMgr ) { Init(); @@ -604,7 +604,7 @@ void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo& rInfo ) SetGlobalUNOConstant( "DialogLibraries", uno::Any( mpImpl->maContainerInfo.mxDialogCont ) ); } -BasicManager::BasicManager( StarBASIC* pSLib, OUString* pLibPath, bool bDocMgr ) : mbDocMgr( bDocMgr ) +BasicManager::BasicManager( StarBASIC* pSLib, OUString const * pLibPath, bool bDocMgr ) : mbDocMgr( bDocMgr ) { Init(); DBG_ASSERT( pSLib, "BasicManager cannot be created with a NULL-Pointer!" ); diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx index 11c2806a4632..ab9a333ad5a8 100644 --- a/basic/source/runtime/iosys.cxx +++ b/basic/source/runtime/iosys.cxx @@ -292,8 +292,8 @@ class UCBStream : public SvStream Reference< XStream > xS; Reference< XSeekable > xSeek; public: - explicit UCBStream( Reference< XInputStream > & xIS ); - explicit UCBStream( Reference< XStream > & xS ); + explicit UCBStream( Reference< XInputStream > const & xIS ); + explicit UCBStream( Reference< XStream > const & xS ); virtual ~UCBStream() override; virtual std::size_t GetData( void* pData, std::size_t nSize ) override; virtual std::size_t PutData( const void* pData, std::size_t nSize ) override; @@ -302,13 +302,13 @@ public: virtual void SetSize( sal_uInt64 nSize ) override; }; -UCBStream::UCBStream( Reference< XInputStream > & rStm ) +UCBStream::UCBStream( Reference< XInputStream > const & rStm ) : xIS( rStm ) , xSeek( rStm, UNO_QUERY ) { } -UCBStream::UCBStream( Reference< XStream > & rStm ) +UCBStream::UCBStream( Reference< XStream > const & rStm ) : xS( rStm ) , xSeek( rStm, UNO_QUERY ) { diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx index 7f09fb4ef579..ebf93aeb8282 100644 --- a/comphelper/source/misc/backupfilehelper.cxx +++ b/comphelper/source/misc/backupfilehelper.cxx @@ -1197,7 +1197,7 @@ namespace PackedFileEntry( sal_uInt32 nFullFileSize, sal_uInt32 nCrc32, - FileSharedPtr& rFile, + FileSharedPtr const & rFile, bool bDoCompress) : mnFullFileSize(nFullFileSize), mnPackFileSize(nFullFileSize), @@ -1549,7 +1549,7 @@ namespace return bRetval; } - bool tryPush(FileSharedPtr& rFileCandidate, bool bCompress) + bool tryPush(FileSharedPtr const & rFileCandidate, bool bCompress) { sal_uInt64 nFileSize(0); diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx index 76b1b91784a8..93b325a06657 100644 --- a/compilerplugins/clang/constparams.cxx +++ b/compilerplugins/clang/constparams.cxx @@ -8,7 +8,8 @@ */ #include -#include +#include +#include #include #include "plugin.hxx" @@ -24,6 +25,10 @@ namespace { +static bool startswith(const std::string& rStr, const char* pSubStr) { + return rStr.compare(0, strlen(pSubStr), pSubStr) == 0; +} + class ConstParams: public RecursiveASTVisitor, public loplugin::Plugin { @@ -31,35 +36,69 @@ public: explicit ConstParams(InstantiationData const & data): Plugin(data) {} virtual void run() override { + std::string fn( compiler.getSourceManager().getFileEntryForID( + compiler.getSourceManager().getMainFileID())->getName() ); + normalizeDotDotInFilePath(fn); + if (startswith(fn, SRCDIR "/sal/") + || startswith(fn, SRCDIR "/bridges/") + || startswith(fn, SRCDIR "/binaryurp/") + || startswith(fn, SRCDIR "/stoc/") + || startswith(fn, WORKDIR "/YaccTarget/unoidl/source/sourceprovider-parser.cxx") + // some weird calling through a function pointer + || startswith(fn, SRCDIR "/svtools/source/table/defaultinputhandler.cxx") + // windows only + || startswith(fn, SRCDIR "/basic/source/sbx/sbxdec.cxx") + || startswith(fn, SRCDIR "/sfx2/source/doc/syspath.cxx") + // ignore this for now + || startswith(fn, SRCDIR "/libreofficekit") + ) + return; + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + + for (const ParmVarDecl *pParmVarDecl : interestingSet) { + if (cannotBeConstSet.find(pParmVarDecl) == cannotBeConstSet.end()) { + report( + DiagnosticsEngine::Warning, + "this parameter can be const", + pParmVarDecl->getLocStart()) + << pParmVarDecl->getSourceRange(); + auto functionDecl = parmToFunction[pParmVarDecl]; + if (functionDecl->getCanonicalDecl()->getLocation() != functionDecl->getLocation()) { + unsigned idx = pParmVarDecl->getFunctionScopeIndex(); + const ParmVarDecl* pOther = functionDecl->getCanonicalDecl()->getParamDecl(idx); + report( + DiagnosticsEngine::Note, + "canonical parameter declaration here", + pOther->getLocStart()) + << pOther->getSourceRange(); + } + } + } } - bool VisitFunctionDecl(FunctionDecl *); - bool VisitDeclRefExpr( const DeclRefExpr* ); + bool VisitFunctionDecl(const FunctionDecl *); + bool VisitDeclRefExpr(const DeclRefExpr *); private: bool checkIfCanBeConst(const Stmt*, const ParmVarDecl*); bool isPointerOrReferenceToConst(const QualType& qt); StringRef getFilename(const SourceLocation& loc); - bool mbInsideFunction; - std::set interestingSet; - std::set cannotBeConstSet; + std::unordered_set interestingSet; + std::unordered_map parmToFunction; + std::unordered_set cannotBeConstSet; }; -bool ConstParams::VisitFunctionDecl(FunctionDecl * functionDecl) +bool ConstParams::VisitFunctionDecl(const FunctionDecl * functionDecl) { - if (ignoreLocation(functionDecl) || !functionDecl->doesThisDeclarationHaveABody()) { + if (ignoreLocation(functionDecl) || !functionDecl->isThisDeclarationADefinition()) { return true; } // ignore stuff that forms part of the stable URE interface if (isInUnoIncludeFile(functionDecl)) { return true; } - // TODO ignore these for now, requires some extra work - if (isa(functionDecl)) { - return true; - } // TODO ignore template stuff for now if (functionDecl->getTemplatedKind() != FunctionDecl::TK_NonTemplate) { return true; @@ -82,11 +121,12 @@ bool ConstParams::VisitFunctionDecl(FunctionDecl * functionDecl) if (functionDecl->getLocation().isMacroID()) return true; - if (functionDecl->getIdentifier()) { + if (functionDecl->getIdentifier()) + { StringRef name = functionDecl->getName(); if (name == "yyerror" // ignore lex/yacc callback - // some function callbacks - // TODO should really use a two-pass algorithm to detect and ignore these automatically + // some function callbacks + // TODO should really use a two-pass algorithm to detect and ignore these automatically || name == "PDFSigningPKCS7PasswordCallback" || name == "VCLExceptionSignal_impl" || name == "parseXcsFile" @@ -114,6 +154,7 @@ bool ConstParams::VisitFunctionDecl(FunctionDecl * functionDecl) || name == "ImpGetEscDir" || name == "ImpGetPercent" || name == "ImpGetAlign" + || name == "write_function" // #ifdef win32 || name == "convert_slashes" // UNO component entry points @@ -129,22 +170,7 @@ bool ConstParams::VisitFunctionDecl(FunctionDecl * functionDecl) return true; } - StringRef aFileName = getFilename(functionDecl->getLocStart()); - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sal/") - || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/bridges/") - || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/binaryurp/") - || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/stoc/") - || loplugin::hasPathnamePrefix(aFileName, WORKDIR "/YaccTarget/unoidl/source/sourceprovider-parser.cxx") - // some weird calling through a function pointer - || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/svtools/source/table/defaultinputhandler.cxx") - // windows only - || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/basic/source/sbx/sbxdec.cxx") - || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sfx2/source/doc/syspath.cxx")) { - return true; - } - // calculate the ones we want to check - interestingSet.clear(); for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) { // ignore unused params if (pParmVarDecl->getName().empty()) @@ -165,48 +191,27 @@ bool ConstParams::VisitFunctionDecl(FunctionDecl * functionDecl) // const is meaningless when applied to function pointer types if (pParmVarDecl->getType()->isFunctionPointerType()) continue; + // ignore things with template params + if (pParmVarDecl->getType()->isInstantiationDependentType()) + continue; interestingSet.insert(pParmVarDecl); + parmToFunction[pParmVarDecl] = functionDecl; } - if (interestingSet.empty()) { - return true; - } - - mbInsideFunction = true; - cannotBeConstSet.clear(); - bool ret = RecursiveASTVisitor::TraverseStmt(functionDecl->getBody()); - mbInsideFunction = false; - for (const ParmVarDecl *pParmVarDecl : interestingSet) { - if (cannotBeConstSet.find(pParmVarDecl) == cannotBeConstSet.end()) { - report( - DiagnosticsEngine::Warning, - "this parameter can be const", - pParmVarDecl->getLocStart()) - << pParmVarDecl->getSourceRange(); - if (functionDecl->getCanonicalDecl()->getLocation() != functionDecl->getLocation()) { - unsigned idx = pParmVarDecl->getFunctionScopeIndex(); - ParmVarDecl* pOther = functionDecl->getCanonicalDecl()->getParamDecl(idx); - report( - DiagnosticsEngine::Note, - "canonical parameter declaration here", - pOther->getLocStart()) - << pOther->getSourceRange(); - } - } - } - return ret; + return true; } bool ConstParams::VisitDeclRefExpr( const DeclRefExpr* declRefExpr ) { - if (!mbInsideFunction) { + if (ignoreLocation(declRefExpr)) { return true; } - const ParmVarDecl* parmVarDecl = dyn_cast_or_null(declRefExpr->getDecl()); - if (!parmVarDecl) { + // ignore stuff that forms part of the stable URE interface + if (isInUnoIncludeFile(declRefExpr->getLocStart())) { return true; } - if (interestingSet.find(parmVarDecl) == interestingSet.end()) { + const ParmVarDecl* parmVarDecl = dyn_cast_or_null(declRefExpr->getDecl()); + if (!parmVarDecl) { return true; } // no need to check again if we have already eliminated this one @@ -218,13 +223,41 @@ bool ConstParams::VisitDeclRefExpr( const DeclRefExpr* declRefExpr ) return true; } -// Walk up from a DeclRefExpr to a ParamVarDecl, checking if the usage means that the -// ParamVarDecl can be const. +// Walk up from a statement that contains a DeclRefExpr, checking if the usage means that the +// related ParamVarDecl can be const. bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVarDecl) { const Stmt* parent = parentStmt( stmt ); - if (isa(parent)) { - const UnaryOperator* unaryOperator = dyn_cast(parent); + if (!parent) + { + // check if we're inside a CXXCtorInitializer + auto parentsRange = compiler.getASTContext().getParents(*stmt); + if ( parentsRange.begin() == parentsRange.end()) + return true; + auto cxxConstructorDecl = dyn_cast_or_null(parentsRange.begin()->get()); + if (!cxxConstructorDecl) + return true; + for ( auto cxxCtorInitializer : cxxConstructorDecl->inits()) + { + if (cxxCtorInitializer->isAnyMemberInitializer() && cxxCtorInitializer->getInit() == stmt) + { + // if the member is not pointer or ref to-const, we cannot make the param const + auto fieldDecl = cxxCtorInitializer->getAnyMember(); + auto tc = loplugin::TypeCheck(fieldDecl->getType()); + return tc.Pointer().Const() || tc.LvalueReference().Const(); + } + } + parmVarDecl->dump(); + stmt->dump(); + cxxConstructorDecl->dump(); + report( + DiagnosticsEngine::Warning, + "couldn't find the CXXCtorInitializer?", + stmt->getLocStart()) + << stmt->getSourceRange(); + return false; + } + if (auto unaryOperator = dyn_cast(parent)) { UnaryOperator::Opcode op = unaryOperator->getOpcode(); if (op == UO_AddrOf || op == UO_PreInc || op == UO_PostInc || op == UO_PreDec || op == UO_PostDec) { @@ -254,17 +287,15 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar return checkIfCanBeConst(parent, parmVarDecl); } return true; - } else if (isa(parent)) { - const CXXConstructExpr* constructExpr = dyn_cast(parent); + } else if (auto constructExpr = dyn_cast(parent)) { const CXXConstructorDecl * constructorDecl = constructExpr->getConstructor(); for (unsigned i = 0; i < constructExpr->getNumArgs(); ++i) { if (constructExpr->getArg(i) == stmt) { return isPointerOrReferenceToConst(constructorDecl->getParamDecl(i)->getType()); } } - } else if (isa(parent)) { - const CXXOperatorCallExpr* operatorCallExpr = dyn_cast(parent); - const CXXMethodDecl* calleeMethodDecl = dyn_cast(operatorCallExpr->getDirectCallee()); + } else if (auto operatorCallExpr = dyn_cast(parent)) { + const CXXMethodDecl* calleeMethodDecl = dyn_cast_or_null(operatorCallExpr->getDirectCallee()); if (calleeMethodDecl) { // unary operator if (calleeMethodDecl->getNumParams() == 0) { @@ -293,8 +324,7 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar } } } - } else if (isa(parent)) { - const CallExpr* callExpr = dyn_cast(parent); + } else if (auto callExpr = dyn_cast(parent)) { QualType functionType = callExpr->getCallee()->getType(); if (functionType->isFunctionPointerType()) { functionType = functionType->getPointeeType(); @@ -314,27 +344,29 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar } } const FunctionDecl* calleeFunctionDecl = callExpr->getDirectCallee(); - if (isa(parent)) { - const CXXMemberCallExpr* memberCallExpr = dyn_cast(parent); - const MemberExpr* memberExpr = dyn_cast(stmt); - if (memberExpr && memberCallExpr->getImplicitObjectArgument() == memberExpr->getBase()) - { - const CXXMethodDecl* calleeMethodDecl = dyn_cast(calleeFunctionDecl); - return calleeMethodDecl->isConst(); + if (calleeFunctionDecl) + { + if (auto memberCallExpr = dyn_cast(parent)) { + const MemberExpr* memberExpr = dyn_cast(stmt); + if (memberExpr && memberCallExpr->getImplicitObjectArgument() == memberExpr->getBase()) + { + const CXXMethodDecl* calleeMethodDecl = dyn_cast(calleeFunctionDecl); + return calleeMethodDecl->isConst(); + } } - } - // TODO could do better - if (calleeFunctionDecl->isVariadic()) { - return false; - } - if (callExpr->getCallee() == stmt) { - return true; - } - for (unsigned i = 0; i < callExpr->getNumArgs(); ++i) { - if (i >= calleeFunctionDecl->getNumParams()) // can happen in template code - break; - if (callExpr->getArg(i) == stmt) { - return isPointerOrReferenceToConst(calleeFunctionDecl->getParamDecl(i)->getType()); + // TODO could do better + if (calleeFunctionDecl->isVariadic()) { + return false; + } + if (callExpr->getCallee() == stmt) { + return true; + } + for (unsigned i = 0; i < callExpr->getNumArgs(); ++i) { + if (i >= calleeFunctionDecl->getNumParams()) // can happen in template code + break; + if (callExpr->getArg(i) == stmt) { + return isPointerOrReferenceToConst(calleeFunctionDecl->getParamDecl(i)->getType()); + } } } } else if (isa(parent)) { @@ -370,15 +402,20 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar return false; } else if (isa(parent)) { return false; + } else if (isa(parent)) { + return false; } else if (isa(parent)) { return true; - } else if (const ConditionalOperator* conditionalExpr = dyn_cast(parent)) { + } else if (auto conditionalExpr = dyn_cast(parent)) { if (conditionalExpr->getCond() == stmt) return true; return checkIfCanBeConst(parent, parmVarDecl); } else if (isa(parent)) { return false; // ??? - } else if (isa(parent)) { + } else if (auto cxxNewExpr = dyn_cast(parent)) { + for (auto pa : cxxNewExpr->placement_arguments()) + if (pa == stmt) + return false; return true; // because the ParamVarDecl must be a parameter to the expression, probably an array length } else if (auto lambdaExpr = dyn_cast(parent)) { for (auto it = lambdaExpr->capture_begin(); it != lambdaExpr->capture_end(); ++it) @@ -386,18 +423,21 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar if (it->capturesVariable() && it->getCapturedVar() == parmVarDecl) return it->getCaptureKind() != LCK_ByRef; } - /* sigh. just running this message will cause clang to crash (in sdext) - report( - DiagnosticsEngine::Warning, - "cannot handle this lambda", - parent->getLocStart()) - << parent->getSourceRange(); - parent->dump(); - parmVarDecl->dump(); - */ - return false; + return false; } else if (isa(parent)) { return true; + } else if (isa(parent)) { + return true; + } else if (isa(parent)) { + return false; + } else if (isa(parent)) { + return false; + } else if (isa(parent)) { + return false; + } else if (isa(parent)) { + return checkIfCanBeConst(parent, parmVarDecl); + } else if (isa(parent)) { + return true; } else { parent->dump(); parmVarDecl->dump(); diff --git a/compilerplugins/clang/test/constparams.cxx b/compilerplugins/clang/test/constparams.cxx new file mode 100644 index 000000000000..fd4ee2cd63f7 --- /dev/null +++ b/compilerplugins/clang/test/constparams.cxx @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +struct Class1 +{ + int const * m_f1; + Class1(int * f1) : m_f1(f1) {} // expected-error {{this parameter can be const [loplugin:constparams]}} +}; + +struct Class2 +{ + int * m_f2; + Class2(int * f2) : m_f2(f2) {} +}; +struct Class3 +{ + int * m_f2; + Class3(void * f2) : m_f2(static_cast(f2)) {} +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/connectivity/source/drivers/file/fcode.cxx b/connectivity/source/drivers/file/fcode.cxx index 69b1692735eb..6e3e29450fef 100644 --- a/connectivity/source/drivers/file/fcode.cxx +++ b/connectivity/source/drivers/file/fcode.cxx @@ -65,7 +65,7 @@ void OOperandValue::setValue(const ORowSetValue& _rVal) m_aValue = _rVal; } -OOperandParam::OOperandParam(OSQLParseNode* pNode, sal_Int32 _nPos) +OOperandParam::OOperandParam(OSQLParseNode const * pNode, sal_Int32 _nPos) : OOperandRow(static_cast(_nPos), DataType::VARCHAR) // Standard-Type { OSL_ENSURE(SQL_ISRULE(pNode,parameter),"Argument is not a parameter"); diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx index d922a5293022..1953fb5303a6 100644 --- a/connectivity/source/drivers/file/fcomp.cxx +++ b/connectivity/source/drivers/file/fcomp.cxx @@ -134,7 +134,7 @@ void OPredicateCompiler::start(OSQLParseNode const * pSQLParseNode) } -OOperand* OPredicateCompiler::execute(OSQLParseNode* pPredicateNode) +OOperand* OPredicateCompiler::execute(OSQLParseNode const * pPredicateNode) { OOperand* pOperand = nullptr; if (pPredicateNode->count() == 3 && // Expression is bracketed @@ -408,7 +408,7 @@ void OPredicateCompiler::execute_ISNULL(OSQLParseNode const * pPredicateNode) m_aCodeList.push_back(pOperator); } -OOperand* OPredicateCompiler::execute_Operand(OSQLParseNode* pPredicateNode) +OOperand* OPredicateCompiler::execute_Operand(OSQLParseNode const * pPredicateNode) { OOperand* pOperand = nullptr; diff --git a/connectivity/source/drivers/firebird/Blob.cxx b/connectivity/source/drivers/firebird/Blob.cxx index be4922d7f33c..b71c8844cb72 100644 --- a/connectivity/source/drivers/firebird/Blob.cxx +++ b/connectivity/source/drivers/firebird/Blob.cxx @@ -31,7 +31,7 @@ using namespace ::com::sun::star::uno; Blob::Blob(isc_db_handle* pDatabaseHandle, isc_tr_handle* pTransactionHandle, - ISC_QUAD& aBlobID): + ISC_QUAD const & aBlobID): Blob_BASE(m_aMutex), m_pDatabaseHandle(pDatabaseHandle), m_pTransactionHandle(pTransactionHandle), diff --git a/connectivity/source/drivers/firebird/Blob.hxx b/connectivity/source/drivers/firebird/Blob.hxx index eb8e282bf911..9afa09dec8fd 100644 --- a/connectivity/source/drivers/firebird/Blob.hxx +++ b/connectivity/source/drivers/firebird/Blob.hxx @@ -58,7 +58,7 @@ namespace connectivity public: Blob(isc_db_handle* pDatabaseHandle, isc_tr_handle* pTransactionHandle, - ISC_QUAD& aBlobID); + ISC_QUAD const & aBlobID); // ---- XBlob ---------------------------------------------------- virtual sal_Int64 SAL_CALL diff --git a/connectivity/source/drivers/firebird/Clob.cxx b/connectivity/source/drivers/firebird/Clob.cxx index 4f70a000a242..7e2d49727ed1 100644 --- a/connectivity/source/drivers/firebird/Clob.cxx +++ b/connectivity/source/drivers/firebird/Clob.cxx @@ -26,7 +26,7 @@ using namespace ::com::sun::star::uno; Clob::Clob(isc_db_handle* pDatabaseHandle, isc_tr_handle* pTransactionHandle, - ISC_QUAD& aBlobID): + ISC_QUAD const & aBlobID): Clob_BASE(m_aMutex), m_aBlob(new connectivity::firebird::Blob(pDatabaseHandle, pTransactionHandle, aBlobID)) { diff --git a/connectivity/source/drivers/firebird/Clob.hxx b/connectivity/source/drivers/firebird/Clob.hxx index b71bec19fa51..d435312f9f36 100644 --- a/connectivity/source/drivers/firebird/Clob.hxx +++ b/connectivity/source/drivers/firebird/Clob.hxx @@ -41,7 +41,7 @@ namespace connectivity public: Clob(isc_db_handle* pDatabaseHandle, isc_tr_handle* pTransactionHandle, - ISC_QUAD& aBlobID); + ISC_QUAD const & aBlobID); // ---- XClob ---------------------------------------------------- virtual sal_Int64 SAL_CALL diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index f6807cf2bbe1..d792ecb72fb0 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -349,7 +349,7 @@ void Connection::notifyDatabaseModified() IMPLEMENT_SERVICE_INFO(Connection, "com.sun.star.sdbc.drivers.firebird.Connection", "com.sun.star.sdbc.Connection") -Reference< XBlob> Connection::createBlob(ISC_QUAD* pBlobId) +Reference< XBlob> Connection::createBlob(ISC_QUAD const * pBlobId) { MutexGuard aGuard(m_aMutex); checkDisposed(Connection_BASE::rBHelper.bDisposed); @@ -362,7 +362,7 @@ Reference< XBlob> Connection::createBlob(ISC_QUAD* pBlobId) return xReturn; } -Reference< XClob> Connection::createClob(ISC_QUAD* pBlobId) +Reference< XClob> Connection::createClob(ISC_QUAD const * pBlobId) { MutexGuard aGuard(m_aMutex); checkDisposed(Connection_BASE::rBHelper.bDisposed); diff --git a/connectivity/source/drivers/firebird/Connection.hxx b/connectivity/source/drivers/firebird/Connection.hxx index 43bccf9ab8f8..70f5a417af42 100644 --- a/connectivity/source/drivers/firebird/Connection.hxx +++ b/connectivity/source/drivers/firebird/Connection.hxx @@ -211,11 +211,11 @@ namespace connectivity * @throws css::uno::RuntimeException */ css::uno::Reference< css::sdbc::XBlob> - createBlob(ISC_QUAD* pBlobID); + createBlob(ISC_QUAD const * pBlobID); /// @throws css::sdbc::SQLException /// @throws css::uno::RuntimeException css::uno::Reference< css::sdbc::XClob> - createClob(ISC_QUAD* pBlobID); + createClob(ISC_QUAD const * pBlobID); /** * Create and/or connect to the sdbcx Catalog. This is completely diff --git a/connectivity/source/drivers/firebird/Tables.hxx b/connectivity/source/drivers/firebird/Tables.hxx index e106b8b65c4d..d391ca8b0999 100644 --- a/connectivity/source/drivers/firebird/Tables.hxx +++ b/connectivity/source/drivers/firebird/Tables.hxx @@ -45,7 +45,7 @@ namespace connectivity Tables(const css::uno::Reference< css::sdbc::XDatabaseMetaData >& rMetaData, ::cppu::OWeakObject& rParent, ::osl::Mutex& rMutex, - ::connectivity::TStringVector& rNames) : sdbcx::OCollection(rParent, true, rMutex, rNames), m_xMetaData(rMetaData) {} + ::connectivity::TStringVector const & rNames) : sdbcx::OCollection(rParent, true, rMutex, rNames), m_xMetaData(rMetaData) {} // TODO: we should also implement XDataDescriptorFactory, XRefreshable, // XAppend, etc., but all are optional. diff --git a/connectivity/source/drivers/firebird/Users.cxx b/connectivity/source/drivers/firebird/Users.cxx index a887a679e7e8..edaa9edb6862 100644 --- a/connectivity/source/drivers/firebird/Users.cxx +++ b/connectivity/source/drivers/firebird/Users.cxx @@ -30,7 +30,7 @@ using namespace ::com::sun::star::uno; Users::Users(const uno::Reference< XDatabaseMetaData >& rMetaData, OWeakObject& rParent, Mutex& rMutex, - TStringVector& rNames) : + TStringVector const & rNames) : OCollection(rParent, true, rMutex, diff --git a/connectivity/source/drivers/firebird/Users.hxx b/connectivity/source/drivers/firebird/Users.hxx index 75ba14499eb5..a689e672b5bc 100644 --- a/connectivity/source/drivers/firebird/Users.hxx +++ b/connectivity/source/drivers/firebird/Users.hxx @@ -42,7 +42,7 @@ namespace connectivity Users(const css::uno::Reference< css::sdbc::XDatabaseMetaData >& rMetaData, ::cppu::OWeakObject& rParent, ::osl::Mutex& rMutex, - ::connectivity::TStringVector& rNames); + ::connectivity::TStringVector const & rNames); // TODO: we should also implement XDataDescriptorFactory, XRefreshable, // XAppend, etc., but all are optional. diff --git a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx index 6b46bd2f5654..06341803ba2b 100644 --- a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx @@ -117,7 +117,7 @@ ResultSetMetaData::ResultSetMetaData( const css::uno::Reference< css::sdbc::XResultSet > & origin, ResultSet * pResultSet, ConnectionSettings **ppSettings, - PGresult *pResult, + PGresult const *pResult, const OUString &schemaName, const OUString &tableName ) : m_xMutex( refMutex ), diff --git a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.hxx b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.hxx index 1beede2b835d..2c1b5e5e5965 100644 --- a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.hxx +++ b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.hxx @@ -94,7 +94,7 @@ public: const css::uno::Reference< css::sdbc::XResultSet > & origin, ResultSet *pResultSet, ConnectionSettings **pSettings, - PGresult *pResult, + PGresult const *pResult, const OUString &schemaName, const OUString &tableName ); diff --git a/connectivity/source/inc/file/fcode.hxx b/connectivity/source/inc/file/fcode.hxx index 8ac3676b26d0..40e0a1100c95 100644 --- a/connectivity/source/inc/file/fcode.hxx +++ b/connectivity/source/inc/file/fcode.hxx @@ -110,7 +110,7 @@ namespace connectivity class OOperandParam : public OOperandRow { public: - OOperandParam(connectivity::OSQLParseNode* pNode, sal_Int32 _nPos); + OOperandParam(connectivity::OSQLParseNode const * pNode, sal_Int32 _nPos); }; // Value operands diff --git a/connectivity/source/inc/file/fcomp.hxx b/connectivity/source/inc/file/fcomp.hxx index 0e8606002e6c..a20ce876fe03 100644 --- a/connectivity/source/inc/file/fcomp.hxx +++ b/connectivity/source/inc/file/fcomp.hxx @@ -59,7 +59,7 @@ namespace connectivity void dispose(); void start(connectivity::OSQLParseNode const * pSQLParseNode); - OOperand* execute(connectivity::OSQLParseNode* pPredicateNode); + OOperand* execute(connectivity::OSQLParseNode const * pPredicateNode); void Clean(); bool isClean() const {return m_aCodeList.empty();} @@ -81,7 +81,7 @@ namespace connectivity void execute_ISNULL(connectivity::OSQLParseNode const * pPredicateNode); /// @throws css::sdbc::SQLException /// @throws css::uno::RuntimeException - OOperand* execute_Operand(connectivity::OSQLParseNode* pPredicateNode); + OOperand* execute_Operand(connectivity::OSQLParseNode const * pPredicateNode); /// @throws css::sdbc::SQLException /// @throws css::uno::RuntimeException void execute_Fold(OSQLParseNode const * pPredicateNode); diff --git a/cppcanvas/source/mtfrenderer/textaction.cxx b/cppcanvas/source/mtfrenderer/textaction.cxx index 312550eac166..cdf90ef71eac 100644 --- a/cppcanvas/source/mtfrenderer/textaction.cxx +++ b/cppcanvas/source/mtfrenderer/textaction.cxx @@ -769,7 +769,7 @@ namespace cppcanvas const OUString& rText, sal_Int32 nStartPos, sal_Int32 nLen, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState ); @@ -781,7 +781,7 @@ namespace cppcanvas const OUString& rText, sal_Int32 nStartPos, sal_Int32 nLen, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState, const ::basegfx::B2DHomMatrix& rTextTransform ); @@ -833,7 +833,7 @@ namespace cppcanvas const OUString& rText, sal_Int32 nStartPos, sal_Int32 nLen, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState ) : mxFont( rState.xFont ), @@ -872,7 +872,7 @@ namespace cppcanvas const OUString& rText, sal_Int32 nStartPos, sal_Int32 nLen, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState, const ::basegfx::B2DHomMatrix& rTextTransform ) : @@ -1190,7 +1190,7 @@ namespace cppcanvas sal_Int32 nStartPos, sal_Int32 nLen, const uno::Sequence< double >& rOffsets, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState ); EffectTextArrayAction( const ::basegfx::B2DPoint& rStartPoint, @@ -1202,7 +1202,7 @@ namespace cppcanvas sal_Int32 nStartPos, sal_Int32 nLen, const uno::Sequence< double >& rOffsets, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState, const ::basegfx::B2DHomMatrix& rTextTransform ); @@ -1252,7 +1252,7 @@ namespace cppcanvas sal_Int32 nStartPos, sal_Int32 nLen, const uno::Sequence< double >& rOffsets, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState ) : mxTextLayout(), @@ -1292,7 +1292,7 @@ namespace cppcanvas sal_Int32 nStartPos, sal_Int32 nLen, const uno::Sequence< double >& rOffsets, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState, const ::basegfx::B2DHomMatrix& rTextTransform ) : @@ -1527,7 +1527,7 @@ namespace cppcanvas const ::basegfx::B2DRectangle& rOutlineBounds, const uno::Reference< rendering::XPolyPolygon2D >& rTextPoly, const uno::Sequence< double >& rOffsets, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState ); OutlineAction( const ::basegfx::B2DPoint& rStartPoint, @@ -1538,7 +1538,7 @@ namespace cppcanvas const ::basegfx::B2DRectangle& rOutlineBounds, const uno::Reference< rendering::XPolyPolygon2D >& rTextPoly, const uno::Sequence< double >& rOffsets, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState, const ::basegfx::B2DHomMatrix& rTextTransform ); @@ -1604,7 +1604,7 @@ namespace cppcanvas const ::basegfx::B2DRectangle& rOutlineBounds, const uno::Reference< rendering::XPolyPolygon2D >& rTextPoly, const uno::Sequence< double >& rOffsets, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState ) : mxTextPoly( rTextPoly ), @@ -1645,7 +1645,7 @@ namespace cppcanvas const ::basegfx::B2DRectangle& rOutlineBounds, const uno::Reference< rendering::XPolyPolygon2D >& rTextPoly, const uno::Sequence< double >& rOffsets, - VirtualDevice& rVDev, + VirtualDevice const & rVDev, const CanvasSharedPtr& rCanvas, const OutDevState& rState, const ::basegfx::B2DHomMatrix& rTextTransform ) : diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx index 32b3bc7c4c05..37879cd4a04b 100644 --- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx @@ -398,7 +398,7 @@ namespace drawinglayer public: explicit Executor( - std::shared_ptr& rTag, + std::shared_ptr const & rTag, processor3d::ZBufferProcessor3D* pZBufferProcessor3D, const primitive3d::Primitive3DContainer& rChildren3D) : comphelper::ThreadTask(rTag), diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx index 9890daa05654..9ae2804a36b3 100644 --- a/extensions/source/bibliography/datman.cxx +++ b/extensions/source/bibliography/datman.cxx @@ -237,8 +237,8 @@ public: virtual void dispose() override; }; -static sal_uInt16 lcl_FindLogicalName(BibConfig* pConfig , - const OUString& rLogicalColumnName) +static sal_uInt16 lcl_FindLogicalName(BibConfig const * pConfig , + const OUString& rLogicalColumnName) { for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++) { diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx index b5cfe93794b7..35e825f567ee 100644 --- a/extensions/source/bibliography/framectr.cxx +++ b/extensions/source/bibliography/framectr.cxx @@ -366,7 +366,7 @@ bool BibFrameController_Impl::SaveModified(const Reference< form::runtime::XForm return bResult; } -static vcl::Window* lcl_GetFocusChild( vcl::Window* pParent ) +static vcl::Window* lcl_GetFocusChild( vcl::Window const * pParent ) { sal_uInt16 nChildren = pParent->GetChildCount(); for( sal_uInt16 nChild = 0; nChild < nChildren; ++nChild) diff --git a/extensions/source/config/ldap/ldapuserprofilebe.cxx b/extensions/source/config/ldap/ldapuserprofilebe.cxx index 54d60e335c50..10f7ae002c47 100644 --- a/extensions/source/config/ldap/ldapuserprofilebe.cxx +++ b/extensions/source/config/ldap/ldapuserprofilebe.cxx @@ -157,7 +157,7 @@ bool LdapUserProfileBe::readLdapConfiguration( bool LdapUserProfileBe::getLdapStringParam( - uno::Reference& xAccess, + uno::Reference const & xAccess, const OUString& aLdapSetting, OUString& aServerParameter) { diff --git a/extensions/source/config/ldap/ldapuserprofilebe.hxx b/extensions/source/config/ldap/ldapuserprofilebe.hxx index 74838da874cf..5cca247809b2 100644 --- a/extensions/source/config/ldap/ldapuserprofilebe.hxx +++ b/extensions/source/config/ldap/ldapuserprofilebe.hxx @@ -116,7 +116,7 @@ class LdapUserProfileBe : private LdapProfileMutexHolder, public BackendBase uno::Reference const & context, LdapDefinition * definition, OUString * loggedOnUser); - static bool getLdapStringParam(uno::Reference& xAccess, + static bool getLdapStringParam(uno::Reference const & xAccess, const OUString& aLdapSetting, OUString& aServerParameter); diff --git a/extensions/source/update/ui/updatecheckui.cxx b/extensions/source/update/ui/updatecheckui.cxx index 2b62b30f1990..bf530dbaffd2 100644 --- a/extensions/source/update/ui/updatecheckui.cxx +++ b/extensions/source/update/ui/updatecheckui.cxx @@ -77,7 +77,7 @@ static OUString getImplementationName() namespace { -Image GetMenuBarIcon( MenuBar* pMBar ) +Image GetMenuBarIcon( MenuBar const * pMBar ) { OUString sResID; vcl::Window *pMBarWin = pMBar->GetWindow(); diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 1429951649e1..fce3e1b828c2 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -307,7 +307,7 @@ bool isRangeResultOpCode( OpCode eOp ) checked, bRight==true means opcodes for right side. If bRPN==true it doesn't matter. */ -bool isPotentialRangeType( FormulaToken* pToken, bool bRPN, bool bRight ) +bool isPotentialRangeType( FormulaToken const * pToken, bool bRPN, bool bRight ) { switch (pToken->GetType()) { diff --git a/framework/inc/uielement/menubarmanager.hxx b/framework/inc/uielement/menubarmanager.hxx index 77cb087f4f5a..bc782dbeda95 100644 --- a/framework/inc/uielement/menubarmanager.hxx +++ b/framework/inc/uielement/menubarmanager.hxx @@ -153,8 +153,8 @@ class MenuBarManager: struct MenuItemHandler { MenuItemHandler( sal_uInt16 aItemId, - css::uno::Reference< css::frame::XStatusListener >& xManager, - css::uno::Reference< css::frame::XDispatch >& rDispatch ) : + css::uno::Reference< css::frame::XStatusListener > const & xManager, + css::uno::Reference< css::frame::XDispatch > const & rDispatch ) : nItemId( aItemId ), xSubMenuManager( xManager ), xMenuItemDispatch( rDispatch ) {} diff --git a/framework/inc/xml/saxnamespacefilter.hxx b/framework/inc/xml/saxnamespacefilter.hxx index 3bea6c2380f8..c7a5041af7e2 100644 --- a/framework/inc/xml/saxnamespacefilter.hxx +++ b/framework/inc/xml/saxnamespacefilter.hxx @@ -36,7 +36,7 @@ class FWE_DLLPUBLIC SaxNamespaceFilter : public ::cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > { public: - SaxNamespaceFilter( css::uno::Reference< css::xml::sax::XDocumentHandler >& rSax1DocumentHandler ); + SaxNamespaceFilter( css::uno::Reference< css::xml::sax::XDocumentHandler > const & rSax1DocumentHandler ); virtual ~SaxNamespaceFilter() override; // XDocumentHandler diff --git a/framework/inc/xml/toolboxdocumenthandler.hxx b/framework/inc/xml/toolboxdocumenthandler.hxx index 36da36b9294c..7dc7133ec337 100644 --- a/framework/inc/xml/toolboxdocumenthandler.hxx +++ b/framework/inc/xml/toolboxdocumenthandler.hxx @@ -121,7 +121,7 @@ class FWE_DLLPUBLIC OWriteToolBoxDocumentHandler final public: OWriteToolBoxDocumentHandler( const css::uno::Reference< css::container::XIndexAccess >& rItemAccess, - css::uno::Reference< css::xml::sax::XDocumentHandler >& rDocumentHandler ); + css::uno::Reference< css::xml::sax::XDocumentHandler > const & rDocumentHandler ); ~OWriteToolBoxDocumentHandler(); /// @throws css::xml::sax::SAXException diff --git a/framework/source/fwe/xml/saxnamespacefilter.cxx b/framework/source/fwe/xml/saxnamespacefilter.cxx index f2f8169b3258..fc498248c987 100644 --- a/framework/source/fwe/xml/saxnamespacefilter.cxx +++ b/framework/source/fwe/xml/saxnamespacefilter.cxx @@ -35,7 +35,7 @@ using namespace ::com::sun::star::uno; namespace framework{ -SaxNamespaceFilter::SaxNamespaceFilter( Reference< XDocumentHandler >& rSax1DocumentHandler ) : +SaxNamespaceFilter::SaxNamespaceFilter( Reference< XDocumentHandler > const & rSax1DocumentHandler ) : m_xLocator( nullptr ), xDocumentHandler( rSax1DocumentHandler ), m_aXMLAttributeNamespace( "xmlns" ), diff --git a/framework/source/fwe/xml/toolboxdocumenthandler.cxx b/framework/source/fwe/xml/toolboxdocumenthandler.cxx index 633a057c574a..50fc7dfe4ad2 100644 --- a/framework/source/fwe/xml/toolboxdocumenthandler.cxx +++ b/framework/source/fwe/xml/toolboxdocumenthandler.cxx @@ -583,7 +583,7 @@ OUString OReadToolBoxDocumentHandler::getErrorLineString() OWriteToolBoxDocumentHandler::OWriteToolBoxDocumentHandler( const Reference< XIndexAccess >& rItemAccess, - Reference< XDocumentHandler >& rWriteDocumentHandler ) : + Reference< XDocumentHandler > const & rWriteDocumentHandler ) : m_xWriteDocumentHandler( rWriteDocumentHandler ), m_rItemAccess( rItemAccess ) { diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx index 7994aa51463a..3c102ff6a46a 100644 --- a/idl/inc/database.hxx +++ b/idl/inc/database.hxx @@ -58,8 +58,8 @@ class SvParseException : public std::exception { public: SvIdlError aError; - SvParseException( SvTokenStream & rInStm, const OString& rError ); - SvParseException( const OString& rError, SvToken& rTok ); + SvParseException( SvTokenStream const & rInStm, const OString& rError ); + SvParseException( const OString& rError, SvToken const & rTok ); }; diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx index 1a1057e797f2..7fb11d98d151 100644 --- a/idl/source/prj/database.cxx +++ b/idl/source/prj/database.cxx @@ -28,14 +28,14 @@ #include -SvParseException::SvParseException( SvTokenStream & rInStm, const OString& rError ) +SvParseException::SvParseException( SvTokenStream const & rInStm, const OString& rError ) { SvToken& rTok = rInStm.GetToken(); aError = SvIdlError( rTok.GetLine(), rTok.GetColumn() ); aError.SetText( rError ); }; -SvParseException::SvParseException( const OString& rError, SvToken& rTok ) +SvParseException::SvParseException( const OString& rError, SvToken const & rTok ) { aError = SvIdlError( rTok.GetLine(), rTok.GetColumn() ); aError.SetText( rError ); diff --git a/include/basic/basmgr.hxx b/include/basic/basmgr.hxx index 9cd3a502facb..5450228d4493 100644 --- a/include/basic/basmgr.hxx +++ b/include/basic/basmgr.hxx @@ -133,8 +133,8 @@ protected: virtual ~BasicManager() override; public: - BasicManager( SotStorage& rStorage, const OUString& rBaseURL, StarBASIC* pParentFromStdLib = nullptr, OUString* pLibPath = nullptr, bool bDocMgr = false ); - BasicManager( StarBASIC* pStdLib, OUString* pLibPath = nullptr, bool bDocMgr = false ); + BasicManager( SotStorage& rStorage, const OUString& rBaseURL, StarBASIC* pParentFromStdLib = nullptr, OUString const * pLibPath = nullptr, bool bDocMgr = false ); + BasicManager( StarBASIC* pStdLib, OUString const * pLibPath = nullptr, bool bDocMgr = false ); /** deletes the given BasicManager instance diff --git a/include/linguistic/lngprophelp.hxx b/include/linguistic/lngprophelp.hxx index 065a1c920ff9..6a52633f681b 100644 --- a/include/linguistic/lngprophelp.hxx +++ b/include/linguistic/lngprophelp.hxx @@ -93,7 +93,7 @@ protected: public: PropertyChgHelper( const css::uno::Reference< css::uno::XInterface > &rxSource, - css::uno::Reference< css::linguistic2::XLinguProperties > &rxPropSet, + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet, int nAllowedEvents ); virtual ~PropertyChgHelper() override; @@ -138,7 +138,7 @@ class PropertyHelper_Thes : public: PropertyHelper_Thes( const css::uno::Reference< css::uno::XInterface > &rxSource, - css::uno::Reference< css::linguistic2::XLinguProperties > &rxPropSet ); + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); virtual ~PropertyHelper_Thes() override; // XPropertyChangeListener @@ -158,7 +158,7 @@ class LNG_DLLPUBLIC PropertyHelper_Thesaurus public: PropertyHelper_Thesaurus( const css::uno::Reference< css::uno::XInterface > &rxSource, - css::uno::Reference< css::linguistic2::XLinguProperties > &rxPropSet ); + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); ~PropertyHelper_Thesaurus(); void AddAsPropListener(); void RemoveAsPropListener(); @@ -193,7 +193,7 @@ protected: public: PropertyHelper_Spell( const css::uno::Reference< css::uno::XInterface > &rxSource, - css::uno::Reference< css::linguistic2::XLinguProperties > &rxPropSet ); + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); virtual ~PropertyHelper_Spell() override; virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ) override; @@ -222,7 +222,7 @@ class LNG_DLLPUBLIC PropertyHelper_Spelling public: PropertyHelper_Spelling( const css::uno::Reference< css::uno::XInterface > &rxSource, - css::uno::Reference< css::linguistic2::XLinguProperties > &rxPropSet ); + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); ~PropertyHelper_Spelling(); void AddAsPropListener(); @@ -266,7 +266,7 @@ protected: public: PropertyHelper_Hyphen( const css::uno::Reference< css::uno::XInterface > &rxSource, - css::uno::Reference< css::linguistic2::XLinguProperties > &rxPropSet); + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet); virtual ~PropertyHelper_Hyphen() override; virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ) override; @@ -292,7 +292,7 @@ class LNG_DLLPUBLIC PropertyHelper_Hyphenation public: PropertyHelper_Hyphenation( const css::uno::Reference< css::uno::XInterface > &rxSource, - css::uno::Reference< css::linguistic2::XLinguProperties > &rxPropSet); + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet); ~PropertyHelper_Hyphenation(); void AddAsPropListener(); diff --git a/include/registry/registry.hxx b/include/registry/registry.hxx index e590c2354dd7..f8906668e253 100644 --- a/include/registry/registry.hxx +++ b/include/registry/registry.hxx @@ -554,7 +554,7 @@ public: This constructor is internal only. */ - inline RegistryKey(Registry& registry, + inline RegistryKey(Registry const & registry, RegKeyHandle hKey); protected: @@ -645,7 +645,7 @@ inline RegistryKey::RegistryKey() { } /// @cond INTERNAL -inline RegistryKey::RegistryKey(Registry& registry, RegKeyHandle hKey) +inline RegistryKey::RegistryKey(Registry const & registry, RegKeyHandle hKey) : m_registry(registry) , m_hImpl(hKey) { diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx index f0200fcfce31..ec1747a53cba 100644 --- a/include/sfx2/app.hxx +++ b/include/sfx2/app.hxx @@ -209,7 +209,7 @@ public: SAL_DLLPRIVATE void SignPDFExec_Impl(SfxRequest&); SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &); SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &); - SAL_DLLPRIVATE static void PropExec_Impl(SfxRequest &); + SAL_DLLPRIVATE static void PropExec_Impl(SfxRequest const &); SAL_DLLPRIVATE static void PropState_Impl(SfxItemSet &); SAL_DLLPRIVATE void OfaExec_Impl(SfxRequest &); SAL_DLLPRIVATE static void OfaState_Impl(SfxItemSet &); diff --git a/include/sfx2/frame.hxx b/include/sfx2/frame.hxx index 8ac02bee0829..94c46d6ad05d 100644 --- a/include/sfx2/frame.hxx +++ b/include/sfx2/frame.hxx @@ -182,7 +182,7 @@ class SFX2_DLLPUBLIC SfxFrameItem: public SfxPoolItem public: - SfxFrameItem( sal_uInt16 nWhich, SfxViewFrame *p ); + SfxFrameItem( sal_uInt16 nWhich, SfxViewFrame const *p ); SfxFrameItem( SfxFrame *p ); SfxFrameItem( sal_uInt16 nWhich, SfxFrame *p ); diff --git a/include/svl/stylepool.hxx b/include/svl/stylepool.hxx index fc8a6802d10f..497ae845a36b 100644 --- a/include/svl/stylepool.hxx +++ b/include/svl/stylepool.hxx @@ -31,7 +31,7 @@ class SVL_DLLPUBLIC StylePool final private: std::unique_ptr pImpl; public: - explicit StylePool( SfxItemSet* pIgnorableItems = nullptr ); + explicit StylePool( SfxItemSet const * pIgnorableItems = nullptr ); /** Insert a SfxItemSet into the style pool. diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx index 40ae9619950b..e2767fc83a5f 100644 --- a/include/svl/zformat.hxx +++ b/include/svl/zformat.hxx @@ -160,10 +160,10 @@ public: LanguageType& eLan ); // Copy ctor - SvNumberformat( SvNumberformat& rFormat ); + SvNumberformat( SvNumberformat const & rFormat ); // Copy ctor with exchange of format code string scanner (used in merge) - SvNumberformat( SvNumberformat& rFormat, ImpSvNumberformatScan& rSc ); + SvNumberformat( SvNumberformat const & rFormat, ImpSvNumberformatScan& rSc ); ~SvNumberformat(); diff --git a/include/vcl/FilterConfigItem.hxx b/include/vcl/FilterConfigItem.hxx index 654afae901ff..878e423c823f 100644 --- a/include/vcl/FilterConfigItem.hxx +++ b/include/vcl/FilterConfigItem.hxx @@ -57,8 +57,8 @@ class VCL_DLLPUBLIC FilterConfigItem public: FilterConfigItem( const OUString& rSubTree ); - FilterConfigItem( css::uno::Sequence< css::beans::PropertyValue >* pFilterData ); - FilterConfigItem( const OUString& rSubTree, css::uno::Sequence< css::beans::PropertyValue >* pFilterData ); + FilterConfigItem( css::uno::Sequence< css::beans::PropertyValue > const * pFilterData ); + FilterConfigItem( const OUString& rSubTree, css::uno::Sequence< css::beans::PropertyValue > const * pFilterData ); /// Writes config in destructor ~FilterConfigItem(); /// Writes config and sets unmodified state again. diff --git a/include/vcl/filter/pdfdocument.hxx b/include/vcl/filter/pdfdocument.hxx index 6a8a85958c88..410ce57e4b50 100644 --- a/include/vcl/filter/pdfdocument.hxx +++ b/include/vcl/filter/pdfdocument.hxx @@ -136,7 +136,7 @@ class VCL_DLLPUBLIC PDFReferenceElement : public PDFElement PDFNumberElement& m_rObject; public: - PDFReferenceElement(PDFDocument& rDoc, PDFNumberElement& rObject, PDFNumberElement& rGeneration); + PDFReferenceElement(PDFDocument& rDoc, PDFNumberElement& rObject, PDFNumberElement const & rGeneration); bool Read(SvStream& rStream) override; /// Assuming the reference points to a number object, return its value. double LookupNumber(SvStream& rStream) const; diff --git a/linguistic/source/convdicxml.hxx b/linguistic/source/convdicxml.hxx index 8463d190a0e2..68824a38266a 100644 --- a/linguistic/source/convdicxml.hxx +++ b/linguistic/source/convdicxml.hxx @@ -44,7 +44,7 @@ class ConvDicXMLExport : public SvXMLExport public: ConvDicXMLExport( ConvDic &rConvDic, const OUString &rFileName, - css::uno::Reference< css::xml::sax::XDocumentHandler > &rHandler) : + css::uno::Reference< css::xml::sax::XDocumentHandler > const &rHandler) : SvXMLExport ( comphelper::getProcessComponentContext(), "com.sun.star.lingu2.ConvDicXMLExport", rFileName, css::util::MeasureUnit::CM, rHandler ), rDic ( rConvDic ), diff --git a/linguistic/source/lngprophelp.cxx b/linguistic/source/lngprophelp.cxx index 2846569b172b..0bf1a52db3fc 100644 --- a/linguistic/source/lngprophelp.cxx +++ b/linguistic/source/lngprophelp.cxx @@ -56,7 +56,7 @@ static const int nCHCount = SAL_N_ELEMENTS(aCH); PropertyChgHelper::PropertyChgHelper( const Reference< XInterface > &rxSource, - Reference< XLinguProperties > &rxPropSet, + Reference< XLinguProperties > const &rxPropSet, int nAllowedEvents ) : PropertyChgHelperBase(), aPropNames (nCHCount), @@ -303,7 +303,7 @@ sal_Bool SAL_CALL PropertyHelper_Thes::PropertyHelper_Thes( const Reference< XInterface > &rxSource, - Reference< XLinguProperties > &rxPropSet ) : + Reference< XLinguProperties > const &rxPropSet ) : PropertyChgHelper ( rxSource, rxPropSet, 0 ) { SetDefaultValues(); @@ -336,7 +336,7 @@ static const char *aSP[] = PropertyHelper_Spell::PropertyHelper_Spell( const Reference< XInterface > & rxSource, - Reference< XLinguProperties > &rxPropSet ) : + Reference< XLinguProperties > const &rxPropSet ) : PropertyChgHelper ( rxSource, rxPropSet, AE_SPELLCHECKER ) { AddPropNames( aSP, SAL_N_ELEMENTS(aSP) ); @@ -517,7 +517,7 @@ static const char *aHP[] = PropertyHelper_Hyphen::PropertyHelper_Hyphen( const Reference< XInterface > & rxSource, - Reference< XLinguProperties > &rxPropSet ) : + Reference< XLinguProperties > const &rxPropSet ) : PropertyChgHelper ( rxSource, rxPropSet, AE_HYPHENATOR ) { AddPropNames( aHP, SAL_N_ELEMENTS(aHP) ); @@ -659,7 +659,7 @@ void PropertyHelper_Hyphen::SetTmpPropVals( const PropertyValues &rPropVals ) PropertyHelper_Thesaurus::PropertyHelper_Thesaurus( const css::uno::Reference< css::uno::XInterface > &rxSource, - css::uno::Reference< css::linguistic2::XLinguProperties > &rxPropSet ) + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ) { pInst = new PropertyHelper_Thes( rxSource, rxPropSet ); xPropHelper = pInst; @@ -686,7 +686,7 @@ void PropertyHelper_Thesaurus::SetTmpPropVals( const css::beans::PropertyValues PropertyHelper_Hyphenation::PropertyHelper_Hyphenation( const css::uno::Reference< css::uno::XInterface > &rxSource, - css::uno::Reference< css::linguistic2::XLinguProperties > &rxPropSet) + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet) { pInst = new PropertyHelper_Hyphen( rxSource, rxPropSet ); xPropHelper = pInst; @@ -740,7 +740,7 @@ bool PropertyHelper_Hyphenation::removeLinguServiceEventListener( PropertyHelper_Spelling::PropertyHelper_Spelling( const css::uno::Reference< css::uno::XInterface > &rxSource, - css::uno::Reference< css::linguistic2::XLinguProperties > &rxPropSet ) + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ) { pInst = new PropertyHelper_Spell( rxSource, rxPropSet ); xPropHelper = pInst; diff --git a/sfx2/source/appl/appbas.cxx b/sfx2/source/appl/appbas.cxx index c9184bbb6fd3..99d9573c1dc2 100644 --- a/sfx2/source/appl/appbas.cxx +++ b/sfx2/source/appl/appbas.cxx @@ -140,7 +140,7 @@ StarBASIC* SfxApplication::GetBasic() #endif } -void SfxApplication::PropExec_Impl( SfxRequest &rReq ) +void SfxApplication::PropExec_Impl( SfxRequest const &rReq ) { sal_uInt16 nSID = rReq.GetSlot(); switch ( nSID ) diff --git a/sfx2/source/appl/helpinterceptor.cxx b/sfx2/source/appl/helpinterceptor.cxx index 4e3db51d4125..03f81a25e358 100644 --- a/sfx2/source/appl/helpinterceptor.cxx +++ b/sfx2/source/appl/helpinterceptor.cxx @@ -278,7 +278,7 @@ void SAL_CALL HelpListener_Impl::disposing( const css::lang::EventObject& ) } HelpStatusListener_Impl::HelpStatusListener_Impl( - Reference < XDispatch > const & aDispatch, URL& rURL) + Reference < XDispatch > const & aDispatch, URL const & rURL) { aDispatch->addStatusListener(this, rURL); } diff --git a/sfx2/source/appl/helpinterceptor.hxx b/sfx2/source/appl/helpinterceptor.hxx index f557d35c82f7..6f3f4beadf35 100644 --- a/sfx2/source/appl/helpinterceptor.hxx +++ b/sfx2/source/appl/helpinterceptor.hxx @@ -140,7 +140,7 @@ private: public: HelpStatusListener_Impl( css::uno::Reference < css::frame::XDispatch > const & xDispatch, - css::util::URL& rURL); + css::util::URL const & rURL); virtual ~HelpStatusListener_Impl() override; virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; diff --git a/sfx2/source/appl/impldde.cxx b/sfx2/source/appl/impldde.cxx index d0d36941f590..ff7898eaded1 100644 --- a/sfx2/source/appl/impldde.cxx +++ b/sfx2/source/appl/impldde.cxx @@ -61,13 +61,13 @@ class SvDDELinkEditDialog : public ModalDialog DECL_LINK( EditHdl_Impl, Edit&, void ); public: - SvDDELinkEditDialog( vcl::Window* pParent, SvBaseLink* ); + SvDDELinkEditDialog( vcl::Window* pParent, SvBaseLink const * ); virtual ~SvDDELinkEditDialog() override; virtual void dispose() override; OUString GetCmd() const; }; -SvDDELinkEditDialog::SvDDELinkEditDialog( vcl::Window* pParent, SvBaseLink* pLink ) +SvDDELinkEditDialog::SvDDELinkEditDialog( vcl::Window* pParent, SvBaseLink const * pLink ) : ModalDialog( pParent, "LinkEditDialog", "sfx/ui/linkeditdialog.ui" ) { get(m_pOKButton, "ok"); diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx index f73a1949414d..ed05e0375d14 100644 --- a/sfx2/source/dialog/recfloat.cxx +++ b/sfx2/source/dialog/recfloat.cxx @@ -34,7 +34,7 @@ SFX_IMPL_FLOATINGWINDOW( SfxRecordingFloatWrapper_Impl, SID_RECORDING_FLOATWINDO SfxRecordingFloatWrapper_Impl::SfxRecordingFloatWrapper_Impl( vcl::Window* pParentWnd , sal_uInt16 nId , SfxBindings* pBind , - SfxChildWinInfo* pInfo ) + SfxChildWinInfo const * pInfo ) : SfxChildWindow( pParentWnd, nId ) , pBindings( pBind ) { diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 51b3cfbf2a32..19bccfb8efb7 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -339,11 +339,11 @@ class SfxOwnFramesLocker static vcl::Window* GetVCLWindow( const Reference< frame::XFrame >& xFrame ); public: - explicit SfxOwnFramesLocker( SfxObjectShell* ObjechShell ); + explicit SfxOwnFramesLocker( SfxObjectShell const * ObjechShell ); ~SfxOwnFramesLocker(); }; -SfxOwnFramesLocker::SfxOwnFramesLocker( SfxObjectShell* pObjectShell ) +SfxOwnFramesLocker::SfxOwnFramesLocker( SfxObjectShell const * pObjectShell ) { if ( !pObjectShell ) return; diff --git a/sfx2/source/inc/docundomanager.hxx b/sfx2/source/inc/docundomanager.hxx index 22b21b853eef..108de6fbaf1c 100644 --- a/sfx2/source/inc/docundomanager.hxx +++ b/sfx2/source/inc/docundomanager.hxx @@ -72,7 +72,7 @@ public: E_FULLY_ALIVE }; - SfxModelGuard( SfxBaseModel& i_rModel, const AllowedModelState i_eState = E_FULLY_ALIVE ) + SfxModelGuard( SfxBaseModel const & i_rModel, const AllowedModelState i_eState = E_FULLY_ALIVE ) : m_aGuard() { i_rModel.MethodEntryCheck( i_eState != E_INITIALIZING ); diff --git a/sfx2/source/inc/recfloat.hxx b/sfx2/source/inc/recfloat.hxx index d3bfd427949f..9862927bb492 100644 --- a/sfx2/source/inc/recfloat.hxx +++ b/sfx2/source/inc/recfloat.hxx @@ -30,7 +30,7 @@ public: SfxRecordingFloatWrapper_Impl( vcl::Window* pParent , sal_uInt16 nId , SfxBindings* pBindings , - SfxChildWinInfo* pInfo ); + SfxChildWinInfo const * pInfo ); virtual ~SfxRecordingFloatWrapper_Impl() override; SFX_DECL_CHILDWINDOW(SfxRecordingFloatWrapper_Impl); diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx index 73d7f562b1ee..a092eef150a5 100644 --- a/sfx2/source/view/frame.cxx +++ b/sfx2/source/view/frame.cxx @@ -395,7 +395,7 @@ void SfxFrame::RemoveTopFrame_Impl( SfxFrame* pFrame ) rArr.erase( it ); } -SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxViewFrame *p ) +SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxViewFrame const *p ) : SfxPoolItem( nWhichId ), pFrame( p ? &p->GetFrame() : nullptr ) { wFrame = pFrame; diff --git a/smoketest/libtest.cxx b/smoketest/libtest.cxx index 56996830b482..c7e897083482 100644 --- a/smoketest/libtest.cxx +++ b/smoketest/libtest.cxx @@ -45,7 +45,7 @@ return t.tv_sec*1000 + t.tv_usec/1000; } - bool IsAbsolutePath(char *pPath) + bool IsAbsolutePath(char const *pPath) { if (pPath[0] != '/') { diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk index a7429c2067d2..22bbb1fcc9a1 100644 --- a/solenv/CompilerTest_compilerplugins_clang.mk +++ b/solenv/CompilerTest_compilerplugins_clang.mk @@ -11,6 +11,7 @@ $(eval $(call gb_CompilerTest_CompilerTest,compilerplugins_clang)) $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \ compilerplugins/clang/test/casttovoid \ + compilerplugins/clang/test/constparams \ compilerplugins/clang/test/cppunitassertequals \ compilerplugins/clang/test/datamembershadow \ compilerplugins/clang/test/externvar \ diff --git a/store/source/lockbyte.cxx b/store/source/lockbyte.cxx index 581a515c2c3b..e4fc18071e0b 100644 --- a/store/source/lockbyte.cxx +++ b/store/source/lockbyte.cxx @@ -306,7 +306,7 @@ class FileLockBytes : public: /** Construction. */ - explicit FileLockBytes (FileHandle & rFile); + explicit FileLockBytes (FileHandle const & rFile); FileLockBytes(const FileLockBytes&) = delete; FileLockBytes& operator=(const FileLockBytes&) = delete; @@ -319,7 +319,7 @@ protected: } // namespace store -FileLockBytes::FileLockBytes (FileHandle & rFile) +FileLockBytes::FileLockBytes (FileHandle const & rFile) : m_hFile (rFile.m_handle), m_nSize (SAL_MAX_UINT32), m_xAllocator() { } @@ -534,7 +534,7 @@ class MappedLockBytes : public: /** Construction. */ - explicit MappedLockBytes (FileMapping & rMapping); + explicit MappedLockBytes (FileMapping const & rMapping); MappedLockBytes(const MappedLockBytes&) = delete; MappedLockBytes& operator=(const MappedLockBytes&) = delete; @@ -547,7 +547,7 @@ protected: } // namespace store -MappedLockBytes::MappedLockBytes (FileMapping & rMapping) +MappedLockBytes::MappedLockBytes (FileMapping const & rMapping) : m_pData (rMapping.m_pAddr), m_nSize (rMapping.m_nSize), m_nPageSize(0), m_hFile (rMapping.m_hFile) { } diff --git a/svl/source/items/stylepool.cxx b/svl/source/items/stylepool.cxx index cfc61ab4ed0e..15be4eb971ed 100644 --- a/svl/source/items/stylepool.cxx +++ b/svl/source/items/stylepool.cxx @@ -350,7 +350,7 @@ private: std::unique_ptr mpIgnorableItems; public: // #i86923# - explicit StylePoolImpl( SfxItemSet* pIgnorableItems ) + explicit StylePoolImpl( SfxItemSet const * pIgnorableItems ) : maRoot(), mpIgnorableItems( pIgnorableItems != nullptr ? pIgnorableItems->Clone( false ) @@ -444,7 +444,7 @@ IStylePoolIteratorAccess* StylePoolImpl::createIterator( bool bSkipUnusedItemSet // Ctor, Dtor and redirected methods of class StylePool, nearly inline ;-) // #i86923# -StylePool::StylePool( SfxItemSet* pIgnorableItems ) +StylePool::StylePool( SfxItemSet const * pIgnorableItems ) : pImpl( new StylePoolImpl( pIgnorableItems ) ) {} diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx index 9c014f06ccac..0ed49e83eeac 100644 --- a/svl/source/numbers/numfmuno.cxx +++ b/svl/source/numbers/numfmuno.cxx @@ -368,7 +368,7 @@ uno::Sequence SAL_CALL SvNumberFormatterServiceObj::getSupportedServic return { "com.sun.star.util.NumberFormatter" }; } -SvNumberFormatsObj::SvNumberFormatsObj( SvNumberFormatsSupplierObj& _rParent, ::comphelper::SharedMutex& _rMutex ) +SvNumberFormatsObj::SvNumberFormatsObj( SvNumberFormatsSupplierObj& _rParent, ::comphelper::SharedMutex const & _rMutex ) :rSupplier( _rParent ) ,m_aMutex( _rMutex ) { diff --git a/svl/source/numbers/numfmuno.hxx b/svl/source/numbers/numfmuno.hxx index 01c582594694..3885e2d4a17f 100644 --- a/svl/source/numbers/numfmuno.hxx +++ b/svl/source/numbers/numfmuno.hxx @@ -91,7 +91,7 @@ private: mutable ::comphelper::SharedMutex m_aMutex; public: - SvNumberFormatsObj(SvNumberFormatsSupplierObj& pParent, ::comphelper::SharedMutex& _rMutex); + SvNumberFormatsObj(SvNumberFormatsSupplierObj& pParent, ::comphelper::SharedMutex const & _rMutex); virtual ~SvNumberFormatsObj() override; diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 224190550edd..d12c3624e610 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -407,13 +407,13 @@ void SvNumberformat::ImpCopyNumberformat( const SvNumberformat& rFormat ) } } -SvNumberformat::SvNumberformat( SvNumberformat& rFormat ) +SvNumberformat::SvNumberformat( SvNumberformat const & rFormat ) : rScan(rFormat.rScan), bStarFlag( rFormat.bStarFlag ) { ImpCopyNumberformat( rFormat ); } -SvNumberformat::SvNumberformat( SvNumberformat& rFormat, ImpSvNumberformatScan& rSc ) +SvNumberformat::SvNumberformat( SvNumberformat const & rFormat, ImpSvNumberformatScan& rSc ) : rScan(rSc) , bStarFlag( rFormat.bStarFlag ) { diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx index 7684a08a1260..8c31a48375be 100644 --- a/svtools/source/graphic/grfcache.cxx +++ b/svtools/source/graphic/grfcache.cxx @@ -421,7 +421,7 @@ public: public: GraphicDisplayCacheEntry( const GraphicCacheEntry* pRefCacheEntry, - OutputDevice* pOut, const Point& rPt, const Size& rSz, + OutputDevice const * pOut, const Point& rPt, const Size& rSz, const GraphicObject& rObj, const GraphicAttr& rAttr, const BitmapEx& rBmpEx ) : mpRefCacheEntry( pRefCacheEntry ), @@ -434,7 +434,7 @@ public: } GraphicDisplayCacheEntry( const GraphicCacheEntry* pRefCacheEntry, - OutputDevice* pOut, const Point& rPt, const Size& rSz, + OutputDevice const * pOut, const Point& rPt, const Size& rSz, const GraphicObject& rObj, const GraphicAttr& rAttr, const GDIMetaFile& rMtf ) : mpRefCacheEntry( pRefCacheEntry ), @@ -1108,7 +1108,7 @@ OString GraphicCache::GetUniqueID( const GraphicObject& rObj ) const return aRet; } -bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz, +bool GraphicCache::CreateDisplayCacheObj( OutputDevice const * pOut, const Point& rPt, const Size& rSz, const GraphicObject& rObj, const GraphicAttr& rAttr, const BitmapEx& rBmpEx ) { @@ -1140,7 +1140,7 @@ bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& rPt, return bRet; } -bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz, +bool GraphicCache::CreateDisplayCacheObj( OutputDevice const * pOut, const Point& rPt, const Size& rSz, const GraphicObject& rObj, const GraphicAttr& rAttr, const GDIMetaFile& rMtf ) { diff --git a/svtools/source/graphic/grfcache.hxx b/svtools/source/graphic/grfcache.hxx index 4402573e84dc..ac6c1a8dbe49 100644 --- a/svtools/source/graphic/grfcache.hxx +++ b/svtools/source/graphic/grfcache.hxx @@ -107,7 +107,7 @@ public: ) const; bool CreateDisplayCacheObj( - OutputDevice* pOut, + OutputDevice const * pOut, const Point& rPt, const Size& rSz, const GraphicObject& rObj, @@ -116,7 +116,7 @@ public: ); bool CreateDisplayCacheObj( - OutputDevice* pOut, + OutputDevice const * pOut, const Point& rPt, const Size& rSz, const GraphicObject& rObj, diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx index 54e7d099ef77..b4ebeb666c70 100644 --- a/svtools/source/uno/treecontrolpeer.cxx +++ b/svtools/source/uno/treecontrolpeer.cxx @@ -73,7 +73,7 @@ public: class ImplContextGraphicItem : public SvLBoxContextBmp { public: - ImplContextGraphicItem( Image& rI1,Image& rI2, bool bExpanded) + ImplContextGraphicItem( Image const & rI1, Image const & rI2, bool bExpanded) : SvLBoxContextBmp(rI1, rI2, bExpanded) {} OUString msExpandedGraphicURL; diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 0cb452f12fdc..0a340b127d65 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -414,8 +414,7 @@ OUString GetWordDefaultDateStringAsUS(SvNumberFormatter* pFormatter, LanguageTyp //convert back to the correct language layout. const sal_uInt32 nIndex = pFormatter->GetFormatIndex(NF_DATE_SYSTEM_SHORT, nLang); - SvNumberformat aFormat = const_cast - (*(pFormatter->GetEntry(nIndex))); + SvNumberformat aFormat = *(pFormatter->GetEntry(nIndex)); aFormat.ConvertLanguage(*pFormatter, nLang, LANGUAGE_ENGLISH_US); OUString sParams(aFormat.GetFormatstring()); diff --git a/toolkit/source/awt/stylesettings.cxx b/toolkit/source/awt/stylesettings.cxx index f0e7375d9547..419216e66e23 100644 --- a/toolkit/source/awt/stylesettings.cxx +++ b/toolkit/source/awt/stylesettings.cxx @@ -80,7 +80,7 @@ namespace toolkit class StyleMethodGuard { public: - explicit StyleMethodGuard( WindowStyleSettings_Data& i_rData ) + explicit StyleMethodGuard( WindowStyleSettings_Data const & i_rData ) { if ( i_rData.pOwningWindow == nullptr ) throw DisposedException(); diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx index 90e50d9a0ac7..af96671af26f 100644 --- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx @@ -514,7 +514,7 @@ public: public: CellDataLessComparison( ::std::vector< Any > const & i_data, - ::comphelper::IKeyPredicateLess& i_predicate, + ::comphelper::IKeyPredicateLess const & i_predicate, bool const i_sortAscending ) :m_data( i_data ) diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx index 6c78ca519a1f..32c67d1f8e8a 100644 --- a/vcl/inc/unx/glyphcache.hxx +++ b/vcl/inc/unx/glyphcache.hxx @@ -198,7 +198,7 @@ private: class VCL_DLLPUBLIC FreetypeFontInstance : public LogicalFontInstance { public: - FreetypeFontInstance( FontSelectPattern& ); + FreetypeFontInstance( FontSelectPattern const & ); virtual ~FreetypeFontInstance() override; void SetFreetypeFont(FreetypeFont* p); diff --git a/vcl/opengl/PackedTextureAtlas.cxx b/vcl/opengl/PackedTextureAtlas.cxx index bd1b829427da..ee1ca827ccc7 100644 --- a/vcl/opengl/PackedTextureAtlas.cxx +++ b/vcl/opengl/PackedTextureAtlas.cxx @@ -26,7 +26,7 @@ struct Node bool mOccupied; explicit Node(int nWidth, int nHeight); - explicit Node(tools::Rectangle& aRectangle); + explicit Node(tools::Rectangle const & aRectangle); bool isLeaf(); Node* insert(int nWidth, int nHeight, int nPadding); @@ -39,7 +39,7 @@ Node::Node(int nWidth, int nHeight) , mOccupied(false) {} -Node::Node(tools::Rectangle& aRectangle) +Node::Node(tools::Rectangle const & aRectangle) : mRectangle(aRectangle) , mLeftNode() , mRightNode() diff --git a/vcl/source/filter/FilterConfigItem.cxx b/vcl/source/filter/FilterConfigItem.cxx index 2047ff882215..b0458df5430f 100644 --- a/vcl/source/filter/FilterConfigItem.cxx +++ b/vcl/source/filter/FilterConfigItem.cxx @@ -144,7 +144,7 @@ FilterConfigItem::FilterConfigItem( const OUString& rSubTree ) ImpInitTree( rSubTree ); } -FilterConfigItem::FilterConfigItem( css::uno::Sequence< css::beans::PropertyValue >* pFilterData ) +FilterConfigItem::FilterConfigItem( css::uno::Sequence< css::beans::PropertyValue > const * pFilterData ) : bModified(false) { if ( pFilterData ) @@ -152,7 +152,7 @@ FilterConfigItem::FilterConfigItem( css::uno::Sequence< css::beans::PropertyValu } FilterConfigItem::FilterConfigItem( const OUString& rSubTree, - css::uno::Sequence< css::beans::PropertyValue >* pFilterData ) + css::uno::Sequence< css::beans::PropertyValue > const * pFilterData ) { ImpInitTree( rSubTree ); diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index b99d5e0c8490..23070eb10622 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -2030,7 +2030,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r if( nFormat >= nFormatCount ) return ImplSetError( ERRCODE_GRFILTER_FORMATERROR ); - FilterConfigItem aConfigItem( const_cast*>(pFilterData) ); + FilterConfigItem aConfigItem( pFilterData ); OUString aFilterName( pConfig->GetExportFilterName( nFormat ) ); #ifndef DISABLE_DYNLOADING OUString aExternalFilterName(pConfig->GetExternalFilterName(nFormat, true)); diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index f6a8de05363c..a7ad2c73c897 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -2727,7 +2727,7 @@ PDFDocument& PDFObjectElement::GetDocument() return m_rDoc; } -PDFReferenceElement::PDFReferenceElement(PDFDocument& rDoc, PDFNumberElement& rObject, PDFNumberElement& rGeneration) +PDFReferenceElement::PDFReferenceElement(PDFDocument& rDoc, PDFNumberElement& rObject, PDFNumberElement const & rGeneration) : m_rDoc(rDoc), m_fObjectValue(rObject.GetValue()), m_fGenerationValue(rGeneration.GetValue()), diff --git a/vcl/source/filter/jpeg/JpegWriter.cxx b/vcl/source/filter/jpeg/JpegWriter.cxx index eff1bacd2ddb..1cf302312b22 100644 --- a/vcl/source/filter/jpeg/JpegWriter.cxx +++ b/vcl/source/filter/jpeg/JpegWriter.cxx @@ -109,7 +109,7 @@ JPEGWriter::JPEGWriter( SvStream& rStream, const css::uno::Sequence< css::beans: mbNative ( false ), mpExpWasGrey ( pExportWasGrey ) { - FilterConfigItem aConfigItem( const_cast*>(pFilterData) ); + FilterConfigItem aConfigItem( pFilterData ); mbGreys = aConfigItem.ReadInt32( "ColorMode", 0 ) != 0; mnQuality = aConfigItem.ReadInt32( "Quality", 75 ); maChromaSubsampling = aConfigItem.ReadInt32( "ChromaSubsamplingMode", 0 ); diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 071435544097..40ad7f23034d 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -718,7 +718,7 @@ struct LinearScaleContext std::unique_ptr mpMapXOffset; std::unique_ptr mpMapYOffset; - LinearScaleContext(tools::Rectangle& aDstRect, tools::Rectangle& aBitmapRect, + LinearScaleContext(tools::Rectangle const & aDstRect, tools::Rectangle& aBitmapRect, Size& aOutSize, long nOffX, long nOffY) : mpMapX(new long[aDstRect.GetWidth()]) @@ -882,7 +882,7 @@ struct TradScaleContext std::unique_ptr mpMapX; std::unique_ptr mpMapY; - TradScaleContext(tools::Rectangle& aDstRect, tools::Rectangle& aBitmapRect, + TradScaleContext(tools::Rectangle const & aDstRect, tools::Rectangle& aBitmapRect, Size& aOutSize, long nOffX, long nOffY) : mpMapX(new long[aDstRect.GetWidth()]) diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx index 5ca4abed98fe..c4c54ad0dffe 100644 --- a/vcl/unx/generic/glyphs/glyphcache.cxx +++ b/vcl/unx/generic/glyphs/glyphcache.cxx @@ -349,7 +349,7 @@ void FreetypeFont::GarbageCollect( long nMinLruIndex ) } } -FreetypeFontInstance::FreetypeFontInstance( FontSelectPattern& rFSD ) +FreetypeFontInstance::FreetypeFontInstance( FontSelectPattern const & rFSD ) : LogicalFontInstance( rFSD ) , mpFreetypeFont( nullptr ) {} diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx index d400e1d8178b..df5ea054809a 100644 --- a/vcl/unx/generic/print/genprnpsp.cxx +++ b/vcl/unx/generic/print/genprnpsp.cxx @@ -99,7 +99,7 @@ namespace public: // parent window, Query text, initial value - QueryString(vcl::Window*, OUString &, OUString &); + QueryString(vcl::Window*, OUString const &, OUString &); virtual ~QueryString() override { disposeOnce(); } virtual void dispose() override { @@ -113,7 +113,7 @@ namespace /* * QueryString */ - QueryString::QueryString(vcl::Window* pParent, OUString& rQuery, OUString& rRet) + QueryString::QueryString(vcl::Window* pParent, OUString const & rQuery, OUString& rRet) : ModalDialog(pParent, "QueryDialog", "vcl/ui/querydialog.ui" ) , m_rReturnValue( rRet ) diff --git a/xmlscript/source/xmldlg_imexp/imp_share.hxx b/xmlscript/source/xmldlg_imexp/imp_share.hxx index e3384abaef84..e0da693310ef 100644 --- a/xmlscript/source/xmldlg_imexp/imp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/imp_share.hxx @@ -152,8 +152,8 @@ public: css::uno::Reference const & xContext, css::uno::Reference const & xDialogModel, - std::shared_ptr< std::vector< OUString > >& pStyleNames, - std::shared_ptr< std::vector< css::uno::Reference< css::xml::input::XElement > > >& pStyles, + std::shared_ptr< std::vector< OUString > > const & pStyleNames, + std::shared_ptr< std::vector< css::uno::Reference< css::xml::input::XElement > > > const & pStyles, css::uno::Reference const & xDoc ) : _xContext( xContext ) , _pStyleNames( pStyleNames ) -- cgit