diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-18 09:43:04 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-18 16:02:25 +0200 |
commit | 65ae6af9f460b1a28f3e07480347ff7f90adae38 (patch) | |
tree | 49bfeb1e25724d3b5539b7b5843d38b7531cf65f | |
parent | c7d1bb119d88faaafb53d65ad8907ede97d89c8c (diff) |
loplugin:unusedvarsglobal
tackle some read-only vars.
Mark some of them const to make it obvious they are not really used, and
to make the constantparam plugin see more data.
Change-Id: Ia25927745866746aa1aa9d5affd5857ad9f9ee24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100895
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
24 files changed, 77 insertions, 63 deletions
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index f004cce017d8..be4a5f52afa8 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -3690,9 +3690,7 @@ SbUnoServiceCtor::~SbUnoServiceCtor() SbxInfo* SbUnoServiceCtor::GetInfo() { - SbxInfo* pRet = nullptr; - - return pRet; + return nullptr; } diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index 2b7628f7a0ab..c2979f13f5b3 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -311,10 +311,10 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject( OUString aRet; enum ObjectType eObjectType = OBJECTTYPE_UNKNOWN; - OUString aObjectID; + const OUString aObjectID; OUString aParentParticle; - OUString aDragMethodServiceName; - OUString aDragParameterString; + const OUString aDragMethodServiceName; + const OUString aDragParameterString; try { @@ -393,10 +393,10 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject( OUString aRet; enum ObjectType eObjectType = OBJECTTYPE_UNKNOWN; - OUString aObjectID; + const OUString aObjectID; OUString aParentParticle; - OUString aDragMethodServiceName; - OUString aDragParameterString; + const OUString aDragMethodServiceName; + const OUString aDragParameterString; try { diff --git a/compilerplugins/clang/unusedvarsglobal.cxx b/compilerplugins/clang/unusedvarsglobal.cxx index e5ca57c4ba5a..4619bd3617c5 100644 --- a/compilerplugins/clang/unusedvarsglobal.cxx +++ b/compilerplugins/clang/unusedvarsglobal.cxx @@ -243,6 +243,8 @@ bool UnusedVarsGlobal::VisitVarDecl(const VarDecl* varDecl) return true; if (varDecl->isConstexpr()) return true; + if (varDecl->isExceptionVariable()) + return true; if (!varDecl->getLocation().isValid() || ignoreLocation(varDecl)) return true; // ignore stuff that forms part of the stable URE interface @@ -267,6 +269,8 @@ bool UnusedVarsGlobal::VisitDeclRefExpr(const DeclRefExpr* declRefExpr) return true; if (varDecl->isConstexpr()) return true; + if (varDecl->isExceptionVariable()) + return true; varDecl = varDecl->getCanonicalDecl(); if (!varDecl->getLocation().isValid() || ignoreLocation(varDecl)) return true; diff --git a/compilerplugins/clang/unusedvarsglobal.py b/compilerplugins/clang/unusedvarsglobal.py index 1231edf9bd18..cfc83ad7e8f4 100755 --- a/compilerplugins/clang/unusedvarsglobal.py +++ b/compilerplugins/clang/unusedvarsglobal.py @@ -65,7 +65,13 @@ for d in definitionSet: continue if vartype in ["OpenCLInitialZone", "pyuno::PyThreadDetach", "SortRefUpdateSetter", "oglcanvas::TransformationPreserver"]: continue - if vartype in ["StackHack"]: + if vartype in ["StackHack", "osl::MutexGuard", "accessibility::SolarMethodGuard"]: + continue + if vartype in ["osl::ClearableMutexGuard", "comphelper::OExternalLockGuard", "osl::Guard< ::osl::Mutex>"]: + continue + if vartype in ["comphelper::OContextEntryGuard", "Guard<class osl::Mutex>", "basic::LibraryContainerMethodGuard"]: + continue + if vartype in ["canvas::CanvasBase::MutexType"]: continue definitionSet2.add(d) @@ -83,12 +89,35 @@ writeonlySet = set() for d in definitionSet2: if d in readFromSet or d in untouchedSet: continue + varname = d[1] + vartype = defToTypeMap[d] + if "Alive" in varname: + continue + if "Keep" in varname: + continue + if vartype.endswith(" &"): + continue writeonlySet.add(d) readonlySet = set() for d in definitionSet2: if d in writeToSet or d in untouchedSet: continue + varname = d[1] + vartype = defToTypeMap[d] + if "Dummy" in varname: + continue + if "Empty" in varname: + continue + if varname in ["aOldValue", "aNewValue"]: + continue + if "Exception" in vartype and vartype.endswith(" &"): + continue + if "exception" in vartype and vartype.endswith(" &"): + continue + # TODO for now, focus on the simple stuff + if not (vartype in ["rtl::OUString", "Bool"]): + continue readonlySet.add(d) # sort the results using a "natural order" so sequences like [item1,item2,item10] sort nicely diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx index 3d9df9849fc3..84460e2984db 100644 --- a/cui/source/dialogs/about.cxx +++ b/cui/source/dialogs/about.cxx @@ -158,7 +158,7 @@ OUString AboutDialog::GetVersionString() { OUString AboutDialog::GetBuildString() { - OUString sDefault; + const OUString sDefault; OUString sBuildId(utl::Bootstrap::getBuildVersion(sDefault)); if (sBuildId.isEmpty()) sBuildId = utl::Bootstrap::getBuildIdData(sDefault); @@ -271,4 +271,4 @@ IMPL_LINK_NOARG(AboutDialog, HandleClick, weld::Button &, void) { vcl::unohelper::TextDataObject::CopyStringTo(sInfo, xClipboard); } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx index 58ccf42e3965..5832e8321c53 100644 --- a/cui/source/options/optdict.cxx +++ b/cui/source/options/optdict.cxx @@ -585,10 +585,8 @@ bool SvxEditDictionaryDialog::NewDelHdl(const weld::Widget* pBtn) { if (pBtn == m_xDeletePB.get()) { - OUString aStr; - - m_xWordED->set_text(aStr); - m_xReplaceED->set_text(aStr); + m_xWordED->set_text(""); + m_xReplaceED->set_text(""); m_xDeletePB->set_sensitive(false); int nEntry = m_pWordsLB->get_selected_index(); diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index c82875ece77d..a51ed1f32b6b 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -1404,9 +1404,8 @@ void OfaAutocorrExceptPage::RefillReplaceBoxes(bool bFromReset, } m_xDoubleCapsLB->clear(); m_xAbbrevLB->clear(); - OUString sTemp; - m_xAbbrevED->set_text(sTemp); - m_xDoubleCapsED->set_text(sTemp); + m_xAbbrevED->set_text(""); + m_xDoubleCapsED->set_text(""); if(aStringsTable.find(eLang) != aStringsTable.end()) { diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 30116199123c..78f152166acd 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -720,22 +720,21 @@ std::string extractPrivateKey(const std::string & privateKey) OUString lcl_getCurrentDocumentMimeType(LibLODocument_Impl* pDocument) { - OUString aMimeType; SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(pDocument->mxComponent.get()); if (!pBaseModel) - return aMimeType; + return ""; SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); if (!pObjectShell) - return aMimeType; + return ""; SfxMedium* pMedium = pObjectShell->GetMedium(); if (!pMedium) - return aMimeType; + return ""; auto pFilter = pMedium->GetFilter(); if (!pFilter) - return aMimeType; + return ""; return pFilter->GetMimeType(); } diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx index 8395315883f8..f2f337e56bad 100644 --- a/sc/source/core/data/stlpool.cxx +++ b/sc/source/core/data/stlpool.cxx @@ -212,7 +212,7 @@ void ScStyleSheetPool::CreateStandardStyles() Color aColBlack ( COL_BLACK ); OUString aStr; sal_Int32 nStrLen; - OUString aHelpFile;//which text??? + const OUString aHelpFile;//which text??? SfxItemSet* pSet = nullptr; SfxItemSet* pHFSet = nullptr; SvxSetItem* pHFSetItem = nullptr; diff --git a/sc/source/filter/oox/querytablebuffer.cxx b/sc/source/filter/oox/querytablebuffer.cxx index 8d5ec052d139..883e0cd90041 100644 --- a/sc/source/filter/oox/querytablebuffer.cxx +++ b/sc/source/filter/oox/querytablebuffer.cxx @@ -246,14 +246,13 @@ void QueryTable::finalizeImport() PropertySet aDocProps( getDocument() ); Reference< XAreaLinks > xAreaLinks( aDocProps.getAnyProperty( PROP_AreaLinks ), UNO_QUERY_THROW ); CellAddress aDestPos( aDestRange.aStart.Tab(), aDestRange.aStart.Col(), aDestRange.aStart.Row() ); - OUString aFilterName = "calc_HTML_WebQuery"; - OUString aFilterOptions; - xAreaLinks->insertAtPosition( aDestPos, aFileUrl, aTables, aFilterName, aFilterOptions ); + const OUString aFilterName = "calc_HTML_WebQuery"; + xAreaLinks->insertAtPosition( aDestPos, aFileUrl, aTables, aFilterName, /*aFilterOptions*/"" ); // set refresh interval (convert minutes to seconds) sal_Int32 nRefreshPeriod = xConnection->getModel().mnInterval * 60; if( nRefreshPeriod > 0 ) { - PropertySet aPropSet( lclFindAreaLink( xAreaLinks, aDestRange.aStart, aFileUrl, aTables, aFilterName, aFilterOptions ) ); + PropertySet aPropSet( lclFindAreaLink( xAreaLinks, aDestRange.aStart, aFileUrl, aTables, aFilterName, /*aFilterOptions*/"" ) ); aPropSet.setProperty( PROP_RefreshPeriod, nRefreshPeriod ); } } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 1c35e014a6c8..d2f7250f8a95 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2142,7 +2142,7 @@ void ScXMLExport::AddStyleFromColumn(const uno::Reference<beans::XPropertySet>& aItr->maValue >>= rIsVisible; } - OUString sParent; + const OUString sParent; if (pOldName) { if (GetAutoStylePool()->AddNamed(*pOldName, XmlStyleFamily::TABLE_COLUMN, sParent, aPropStates)) @@ -2171,7 +2171,7 @@ void ScXMLExport::AddStyleFromRow(const uno::Reference<beans::XPropertySet>& xRo if(aPropStates.empty()) return; - OUString sParent; + const OUString sParent; if (pOldName) { if (GetAutoStylePool()->AddNamed(*pOldName, XmlStyleFamily::TABLE_ROW, sParent, aPropStates)) diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 1eda36788038..5ffe1d83d205 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -3887,15 +3887,14 @@ void ScInputHandler::InputCommand( const CommandEvent& rCEvt ) if (eMode==SC_INPUT_NONE) if (pTableView || pTopView) { - OUString aStrLoP; if (pTableView) { - pTableView->GetEditEngine()->SetText( aStrLoP ); + pTableView->GetEditEngine()->SetText( "" ); pTableView->SetSelection( ESelection(0,0, 0,0) ); } if (pTopView) { - pTopView->GetEditEngine()->SetText( aStrLoP ); + pTopView->GetEditEngine()->SetText( "" ); pTopView->SetSelection( ESelection(0,0, 0,0) ); } } diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx index c9221ac68b78..9726b70c4316 100644 --- a/sc/source/ui/pagedlg/areasdlg.cxx +++ b/sc/source/ui/pagedlg/areasdlg.cxx @@ -450,10 +450,9 @@ IMPL_LINK(ScPrintAreasDlg, Impl_BtnHdl, weld::Button&, rBtn, void) { if ( Impl_CheckRefStrings() ) { - OUString aStr; - SfxStringItem aPrintArea( SID_CHANGE_PRINTAREA, aStr ); - SfxStringItem aRepeatRow( FN_PARAM_2, aStr ); - SfxStringItem aRepeatCol( FN_PARAM_3, aStr ); + SfxStringItem aPrintArea( SID_CHANGE_PRINTAREA, "" ); + SfxStringItem aRepeatRow( FN_PARAM_2, "" ); + SfxStringItem aRepeatCol( FN_PARAM_3, "" ); // Printing area changed? diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 7eb550dea115..f23ae2024a9e 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -124,7 +124,7 @@ void SdDrawDocument::CreateLayoutTemplates() { SdStyleSheetPool* pSSPool = static_cast<SdStyleSheetPool*>(GetStyleSheetPool()); SfxStyleSheetBase* pSheet = nullptr; - OUString aHelpFile; + const OUString aHelpFile; OUString aStdName(SdResId(STR_STANDARD_STYLESHEET_NAME)); // Default style diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx index e5f1ddf8cf7a..2419eaa354f9 100644 --- a/sd/source/core/stlpool.cxx +++ b/sd/source/core/stlpool.cxx @@ -197,7 +197,7 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(const OUString& rLayoutName, bool * outline levels **************************************************************************/ OUString aName(STR_LAYOUT_OUTLINE); - OUString aHelpFile; + const OUString aHelpFile; SvxLRSpaceItem aSvxLRSpaceItem( EE_PARA_LRSPACE ); SvxULSpaceItem aSvxULSpaceItem( EE_PARA_ULSPACE ); @@ -820,7 +820,7 @@ void SdStyleSheetPool::CreateLayoutSheetList(const OUString& rLayoutName, SdStyl void SdStyleSheetPool::CreatePseudosIfNecessary() { OUString aName; - OUString aHelpFile; + const OUString aHelpFile; SfxStyleSheetBase* pSheet = nullptr; SfxStyleSheetBase* pParent = nullptr; diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index 1ecd4aa48efe..c3508ec217fc 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -1341,7 +1341,6 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper, if( eFill == drawing::FillStyle_SOLID || eFill == drawing::FillStyle_NONE ) { - OUString aName; SfxItemSet aSet( mrDoc.GetPool() ); bool bClosed = pPickObj->IsClosedObj(); ::sd::Window* pWin = mpViewSh->GetActiveWindow(); @@ -1367,12 +1366,12 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper, { // area fill if(eFill == drawing::FillStyle_SOLID ) - aSet.Put(XFillColorItem(aName, aColor)); + aSet.Put(XFillColorItem("", aColor)); aSet.Put( XFillStyleItem( eFill ) ); } else - aSet.Put( XLineColorItem( aName, aColor ) ); + aSet.Put( XLineColorItem( "", aColor ) ); // add text color pPickObj->SetMergedItemSetAndBroadcast( aSet ); diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index 097cc20b4bdb..95126d996288 100644 --- a/sfx2/source/view/classificationhelper.cxx +++ b/sfx2/source/view/classificationhelper.cxx @@ -624,9 +624,8 @@ const OUString& SfxClassificationHelper::GetAbbreviatedBACName(const OUString& s OUString SfxClassificationHelper::GetBACNameForIdentifier(const OUString& sIdentifier) { - OUString aRet; if (sIdentifier.isEmpty()) - return aRet; + return ""; for (const auto& category : m_pImpl->m_aCategories) { @@ -634,7 +633,7 @@ OUString SfxClassificationHelper::GetBACNameForIdentifier(const OUString& sIdent return category.m_aName; } - return aRet; + return ""; } OUString SfxClassificationHelper::GetHigherClass(const OUString& first, const OUString& second) diff --git a/svtools/source/dialogs/prnsetup.cxx b/svtools/source/dialogs/prnsetup.cxx index 1e55295b20b8..6b95d7fb1bb7 100644 --- a/svtools/source/dialogs/prnsetup.cxx +++ b/svtools/source/dialogs/prnsetup.cxx @@ -260,7 +260,7 @@ void PrinterSetupDialog::ImplSetInfo() } else { - OUString aTempStr; + const OUString aTempStr; m_xFiType->set_label( aTempStr ); m_xFiLocation->set_label( aTempStr ); m_xFiComment->set_label( aTempStr ); diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx index 0b44f16af1ff..65d2c95ea6a6 100644 --- a/svx/source/dialog/imapwnd.cxx +++ b/svx/source/dialog/imapwnd.cxx @@ -551,8 +551,7 @@ sal_Int8 IMapWindow::ExecuteDrop( const ExecuteDropEvent& rEvt ) if (mxDropTargetHelper->IsDropFormatSupported(SotClipboardFormatId::NETSCAPE_BOOKMARK)) { - const OUString aString; - INetBookmark aBookMark( aString, aString ); + INetBookmark aBookMark( "", "" ); SdrObject* pSdrObj = GetHitSdrObj( rEvt.maPosPixel ); if( pSdrObj && TransferableDataHelper( rEvt.maDropEvent.Transferable ).GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aBookMark ) ) diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx index 352faf0b1caa..4533981056ad 100644 --- a/svx/source/gallery2/galbrws2.cxx +++ b/svx/source/gallery2/galbrws2.cxx @@ -790,12 +790,11 @@ void GalleryBrowser2::ImplUpdateViews( sal_uInt16 nSelectionId ) mxListView->freeze(); - OUString sCreateOnDemand; sal_uInt32 nCount = mpCurTheme->GetObjectCount(); for (sal_uInt32 i = 0; i < nCount; ++i) { mxIconView->InsertItem(i + 1); // skip reserved id 0 - mxListView->append(OUString::number(i), sCreateOnDemand); // create on-demand in VisRowsScrolledHdl + mxListView->append(OUString::number(i), ""); // create on-demand in VisRowsScrolledHdl if (i == nAlwaysUpToDate) // fill in the first block UpdateRows(false); diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 7050efc0a320..00aea5871b1c 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -3773,7 +3773,8 @@ void SwHTMLParser::NewFontAttr( HtmlTokenId nToken ) OSL_ENSURE( !nSize == !nFontHeight, "HTML-Font-Size != Font-Height" ); - OUString aFontName, aStyleName; + OUString aFontName; + const OUString aStyleName; FontFamily eFamily = FAMILY_DONTKNOW; // family and pitch, FontPitch ePitch = PITCH_DONTKNOW; // if not found rtl_TextEncoding eEnc = osl_getThreadTextEncoding(); diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx index d92a02790ee0..67783bb1cbe8 100644 --- a/tools/source/inet/inetmime.cxx +++ b/tools/source/inet/inetmime.cxx @@ -1103,7 +1103,6 @@ OUString INetMIME::decodeHeaderFieldBody(const OString& rBody) for (const char * p = pBegin; p != pEnd;) { - OUString sEncodedText; if (*p == '=' /* && bStartEncodedWord */) { const char * q = p + 1; @@ -1362,9 +1361,6 @@ OUString INetMIME::decodeHeaderFieldBody(const OString& rBody) } } - if (!sEncodedText.isEmpty()) - sDecoded.append(sEncodedText); - if (p == pEnd) break; diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx index cb83e51c8204..643c4aa71445 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx @@ -204,15 +204,14 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un // create control uno::Sequence< beans::PropertyValue > aProps; - OUString sHelpUrl; sal_uInt16 nItemType = 0; if( m_bIsMenu ) { - aProps = CreateMenuItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu, true, true ); + aProps = CreateMenuItemData( sCommandUrl, "", sLabel, nItemType, aSubMenu, true, true ); } else { - aProps = CreateToolbarItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu, true/*isVisible*/, 0/*nStyle*/ ); + aProps = CreateToolbarItemData( sCommandUrl, "", sLabel, nItemType, aSubMenu, true/*isVisible*/, 0/*nStyle*/ ); } diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index 3de864c42434..d438400c4540 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -1882,7 +1882,7 @@ XMLParaContext::XMLParaContext( GetImport().GetTextImport()->GetTextPAttrTokenMap(); bool bHaveXmlId( false ); - OUString aCondStyleName, sClassNames; + OUString aCondStyleName; sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; for( sal_Int16 i=0; i < nAttrCount; i++ ) @@ -1967,8 +1967,6 @@ XMLParaContext::XMLParaContext( if( !aCondStyleName.isEmpty() ) sStyleName = aCondStyleName; - else if( !sClassNames.isEmpty() ) - sStyleName = sClassNames.getToken( 0, ' ' ); } void XMLParaContext::EndElement() |