summaryrefslogtreecommitdiff
path: root/compilerplugins
AgeCommit message (Collapse)Author
2022-12-06weld InformationDialog info dialogCaolán McNamara
Change-Id: I6a3631fe06a1b46164f01d706ecefd7252509382 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143740 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-12-06Resolves: tdf#121297 weld Presentation MinimizerCaolán McNamara
Change-Id: Ifdf1746bc9f6567a1aded233a4350f6828604c9e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143678 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-11-29New loplugin:crosscastStephan Bergmann
...inspired by 2fa426da15a12e2a63554247e3c1c3f8c0ec5c24 "Fix dynamic_cast after splitting OutputDevice and vcl::Window class hierarchies": "Find uses of dynamic_cast that cast between unrelated classes, which is suspicious and might indicate a bug. The heuristic used to consider two classes unrelated is that neither derives from the other (directly or indirectly) and they do not both virtually derive (directly or indirectly) from a common third class. Additionally, class definitions can be attributed with SAL_LOPLUGIN_ANNOTATE("crosscast") (from sal/types.h) to suppress false warnings about known-good cases casting from or to such a class." (quoting compilerplugins/clang/crosscast.cxx) This found two additional errors, 7a82ea5c79adee70eddf74ac53347544766a91b0 "Fix presumed typo" and fc6aa9e49973c845915754caf765ff57e5b0cd59 "fix assert", and one still-open case that looks like an error, see the TODO comment in sw/source/core/unocore/unodraw.cxx. In addition to that it flagged another 102 uses of dynamic_cast as suspicious, which have all been addressed, at least for now, by marking certain classes as SAL_LOPLUGIN_ANNOTATE("crosscast"), see below. (Where this commit also adds that generic SAL_LOPLUGIN_ANNOTATE mechanism to include/sal/types.h.) However, some of those annotations might benefit from further inspection and clean up similar to recent 8858962ec09478c203d43feb58f550bb36af37bb "Introduce ParagraphProeprtiesPropertyMap", 8467aa93e2038b3030e1add94e0ca6cc4ad44032 "Replace a dynamic_cast with UNO_QUERY", a534361141d69096d896e6e0552d19f3138eeeb3 "Fold OldBasicPassword into basic::SfxScriptLibraryContainer", and 589e03fb4c3b05bf3742c0cb8b366322ffdf1fa9 "[PATCH] Replace some dynamic_cast with UNO_QUERY". * canvas/source/cairo/cairo_repainttarget.hxx RepaintTarget: > canvas/source/cairo/cairo_cachedbitmap.cxx:62:34: error: suspicious dynamic cross cast from 'com::sun::star::rendering::XCanvas *' to 'RepaintTarget *' [loplugin:crosscast] > RepaintTarget* pTarget = dynamic_cast< RepaintTarget* >(rTargetCanvas.get()); * canvas/source/cairo/cairo_surfaceprovider.hxx SurfaceProvider: > canvas/source/cairo/cairo_canvashelper.cxx:301:45: error: suspicious dynamic cross cast from 'com::sun::star::rendering::XBitmap *' to 'SurfaceProvider *' [loplugin:crosscast] > SurfaceProvider* pSurfaceProvider = dynamic_cast<SurfaceProvider*>( xBitmap.get() ); * canvas/source/vcl/repainttarget.hxx RepaintTarget: > canvas/source/vcl/cachedbitmap.cxx:73:34: error: suspicious dynamic cross cast from 'com::sun::star::rendering::XCanvas *' to 'RepaintTarget *' [loplugin:crosscast] > RepaintTarget* pTarget = dynamic_cast< RepaintTarget* >(rTargetCanvas.get()); * chart2/inc/ChartModel.hxx ChartModel: > chart2/source/controller/dialogs/dlg_ChartType_UNO.cxx:82:31: error: suspicious dynamic cross cast from 'com::sun::star::awt::XWindow *' to 'ChartModel *' [loplugin:crosscast] > ChartModel* pChartModel = dynamic_cast<ChartModel*>(rParent.get()); * chart2/source/controller/inc/TabPageNotifiable.hxx TabPageNotifiable: > chart2/source/controller/dialogs/tp_RangeChooser.cxx:70:28: error: suspicious dynamic cross cast from 'weld::DialogController *' to 'TabPageNotifiable *' [loplugin:crosscast] > , m_pTabPageNotifiable(dynamic_cast<TabPageNotifiable*>(pController)) > chart2/source/controller/dialogs/tp_DataSource.cxx:171:28: error: suspicious dynamic cross cast from 'weld::DialogController *' to 'TabPageNotifiable *' [loplugin:crosscast] > , m_pTabPageNotifiable(dynamic_cast<TabPageNotifiable*>(pController)) * include/drawinglayer/primitive2d/svggradientprimitive2d.hxx SvgGradientHelper: > drawinglayer/source/primitive2d/svggradientprimitive2d.cxx:582:59: error: suspicious dynamic cross cast from 'const BasePrimitive2D *' to 'const SvgGradientHelper *' [loplugin:crosscast] > const SvgGradientHelper* pSvgGradientHelper = dynamic_cast< const SvgGradientHelper* >(&rPrimitive); > drawinglayer/source/primitive2d/svggradientprimitive2d.cxx:819:59: error: suspicious dynamic cross cast from 'const BasePrimitive2D *' to 'const SvgGradientHelper *' [loplugin:crosscast] > const SvgGradientHelper* pSvgGradientHelper = dynamic_cast< const SvgGradientHelper* >(&rPrimitive); * include/editeng/unotext.hxx SvxUnoTextRangeBase: > writerfilter/source/dmapper/DomainMapper_Impl.cxx:7645:62: error: suspicious dynamic cross cast from 'com::sun::star::text::XTextCursor *' to 'SvxUnoTextRangeBase *' [loplugin:crosscast] > SvxUnoTextRangeBase* pDrawText = dynamic_cast<SvxUnoTextRangeBase*>(xCrsr.get()); * include/embeddedobj/embeddedupdate.hxx EmbeddedUpdate: > svtools/source/misc/embedhlp.cxx:932:35: error: suspicious dynamic cross cast from 'com::sun::star::embed::XEmbeddedObject *' to 'embed::EmbeddedUpdate *' [loplugin:crosscast] > embed::EmbeddedUpdate* pObj = dynamic_cast<embed::EmbeddedUpdate*> (GetObject().get()); * include/oox/core/contexthandler2.hxx ContextHandler2Helper: > oox/source/core/contexthandler2.cxx:183:21: error: suspicious dynamic cross cast from 'const ContextHandler2Helper' to 'const ContextHandler &' [loplugin:crosscast] > ContextHandler( dynamic_cast< ContextHandler const & >( rParent ) ), * include/oox/mathml/export.hxx FormulaExportBase: > oox/source/export/shapes.cxx:2475:42: error: suspicious dynamic cross cast from 'com::sun::star::frame::XModel *' to 'oox::FormulaExportBase *' [loplugin:crosscast] > oox::FormulaExportBase *const pMagic(dynamic_cast<oox::FormulaExportBase*>(xMathModel.get())); * include/oox/mathml/import.hxx FormulaImportBase: > oox/source/drawingml/shape.cxx:1298:25: error: suspicious dynamic cross cast from 'com::sun::star::uno::XInterface *' to 'oox::FormulaImportBase *' [loplugin:crosscast] > dynamic_cast<oox::FormulaImportBase*>(xMathModel.get())); > writerfilter/source/ooxml/OOXMLFastContextHandler.cxx:2287:38: error: suspicious dynamic cross cast from 'SfxBaseModel' to 'oox::FormulaImportBase &' [loplugin:crosscast] > oox::FormulaImportBase& import = dynamic_cast<oox::FormulaImportBase&>(dynamic_cast<SfxBaseModel&>(*component)); > writerfilter/source/rtftok/rtfdocumentimpl.cxx:2973:33: error: suspicious dynamic cross cast from 'SfxBaseModel' to 'oox::FormulaImportBase &' [loplugin:crosscast] > auto& rImport = dynamic_cast<oox::FormulaImportBase&>( > writerfilter/source/dmapper/DomainMapper_Impl.cxx:3000:53: error: suspicious dynamic cross cast from 'com::sun::star::uno::XInterface *' to 'oox::FormulaImportBase *' [loplugin:crosscast] > if( oox::FormulaImportBase* formulaimport = dynamic_cast< oox::FormulaImportBase* >( xInterface.get())) * include/sfx2/Metadatable.hxx Metadatable: > sw/source/core/doc/docbm.cxx:1837:17: error: suspicious dynamic cross cast from 'const IBookmark *const' to 'const ::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable const* >(pBookmark)); > sw/source/core/doc/docbm.cxx:1924:13: error: suspicious dynamic cross cast from '::sw::mark::IBookmark *const' to '::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable* >(pBookmark)); > sw/source/core/doc/DocumentContentOperationsManager.cxx:342:21: error: suspicious dynamic cross cast from 'const sw::mark::IMark *const' to 'const ::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable const* >(pMark)); > sw/source/core/doc/DocumentContentOperationsManager.cxx:344:21: error: suspicious dynamic cross cast from '::sw::mark::IMark *const' to '::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable * >(pNewMark)); > sw/source/core/unocore/unobkm.cxx:381:12: error: suspicious dynamic cross cast from '::sw::mark::IMark *' to '::sfx2::Metadatable *' [loplugin:crosscast] > return dynamic_cast< ::sfx2::Metadatable* >(m_pImpl->m_pRegisteredBookmark); > sw/source/core/undo/rolbck.cxx:635:13: error: suspicious dynamic cross cast from 'const ::sw::mark::IBookmark *const' to 'const ::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable const* >(pBookmark)); > sw/source/core/undo/rolbck.cxx:713:13: error: suspicious dynamic cross cast from '::sw::mark::IBookmark *const' to '::sfx2::Metadatable *' [loplugin:crosscast] > dynamic_cast< ::sfx2::Metadatable* >(pBookmark)); * include/sfx2/digitalsignatures.hxx DigitalSignatures: > sfx2/source/doc/docfile.cxx:3999:25: error: suspicious dynamic cross cast from 'com::sun::star::security::XDocumentDigitalSignatures *' to 'sfx2::DigitalSignatures *' [loplugin:crosscast] > auto xModelSigner = dynamic_cast<sfx2::DigitalSignatures*>(xSigner.get()); * include/sfx2/sidebar/IContextChangeReceiver.hxx IContextChangeReceiver: > sfx2/source/sidebar/SidebarPanelBase.cxx:105:11: error: suspicious dynamic cross cast from 'pointer' (aka 'PanelLayout *') to 'IContextChangeReceiver *' [loplugin:crosscast] > = dynamic_cast<IContextChangeReceiver*>(mxControl.get()); * include/sfx2/sidebar/ILayoutableWindow.hxx ILayoutableWindow: > sfx2/source/sidebar/SidebarPanelBase.cxx:164:44: error: suspicious dynamic cross cast from 'pointer' (aka 'PanelLayout *') to 'ILayoutableWindow *' [loplugin:crosscast] > ILayoutableWindow* pLayoutableWindow = dynamic_cast<ILayoutableWindow*>(mxControl.get()); * include/sfx2/sidebar/SidebarModelUpdate.hxx SidebarModelUpdate: > sfx2/source/sidebar/SidebarPanelBase.cxx:189:40: error: suspicious dynamic cross cast from 'pointer' (aka 'PanelLayout *') to 'SidebarModelUpdate *' [loplugin:crosscast] > SidebarModelUpdate* pModelUpdate = dynamic_cast<SidebarModelUpdate*>(mxControl.get()); * include/sfx2/xmldump.hxx XmlDump: > svtools/source/misc/embedhlp.cxx:290:27: error: suspicious dynamic cross cast from 'com::sun::star::util::XCloseable *' to 'sfx2::XmlDump *' [loplugin:crosscast] > auto pComponent = dynamic_cast<sfx2::XmlDump*>(mxObj->getComponent().get()); * include/svl/stylesheetuser.hxx StyleSheetUser: > sd/source/core/stlsheet.cxx:294:48: error: suspicious dynamic cross cast from 'SfxListener *' to 'svl::StyleSheetUser *' [loplugin:crosscast] > const svl::StyleSheetUser* const pUser(dynamic_cast<svl::StyleSheetUser*>(pListener)); * include/svl/undo.hxx SfxRepeatTarget: > starmath/source/action.cxx:45:5: error: suspicious dynamic cross cast from 'SfxRepeatTarget' to 'SmDocShell &' [loplugin:crosscast] > dynamic_cast< SmDocShell & >(rDocSh).SetFormat(aNewFormat); * include/svx/ipolypolygoneditorcontroller.hxx IPolyPolygonEditorController: > sd/source/ui/view/drbezob.cxx:127:22: error: suspicious dynamic cross cast from 'sd::SmartTag *' to 'IPolyPolygonEditorController *' [loplugin:crosscast] > pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() ); > sd/source/ui/view/drbezob.cxx:216:26: error: suspicious dynamic cross cast from 'sd::SmartTag *' to 'IPolyPolygonEditorController *' [loplugin:crosscast] > pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() ); * include/vcl/IContext.hxx IContext: > vcl/source/window/builder.cxx:3650:54: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IContext *' [loplugin:crosscast] > vcl::IContext* pContextControl = dynamic_cast<vcl::IContext*>(pCurrentChild.get()); * include/vcl/ITiledRenderable.hxx ITiledRenderable: > In file included from test/source/a11y/swaccessibletestbase.cxx:10: > In file included from include/test/a11y/swaccessibletestbase.hxx:22: > include/test/a11y/accessibletestbase.hxx:54:15: error: suspicious dynamic cross cast from 'com::sun::star::lang::XComponent *' to 'vcl::ITiledRenderable *' [loplugin:crosscast] > = dynamic_cast<vcl::ITiledRenderable*>(mxDocument.get()); * include/vcl/NotebookbarContextControl.hxx NotebookbarContextControl: > vcl/source/control/notebookbar.cxx:113:33: error: suspicious dynamic cross cast from 'vcl::Window *' to 'NotebookbarContextControl *' [loplugin:crosscast] > pContextContainer = dynamic_cast<NotebookbarContextControl*>(m_pUIBuilder->get<Window>(OUStringToOString(aName, RTL_TEXTENCODING_UTF8))); * include/vcl/gdimetafiletools.hxx MetafileAccessor: > vcl/source/gdi/impgraph.cxx:716:61: error: suspicious dynamic cross cast from 'drawinglayer::primitive2d::BasePrimitive2D *' to 'const MetafileAccessor *' [loplugin:crosscast] > const MetafileAccessor* pMetafileAccessor = dynamic_cast< const MetafileAccessor* >(pUnoPrimitive->getBasePrimitive2D().get()); * include/vcl/syswin.hxx VclBuilderContainer: > vcl/source/app/salvtables.cxx:7465:11: error: suspicious dynamic cross cast from 'vcl::Window *' to 'VclBuilderContainer *' [loplugin:crosscast] > = dynamic_cast<VclBuilderContainer*>(m_aOwnedToplevel.get())) * include/vcl/toolkit/field.hxx NumericFormatter: > vcl/source/window/builder.cxx:583:37: error: suspicious dynamic cross cast from 'vcl::Window *' to 'NumericFormatter *' [loplugin:crosscast] > NumericFormatter *pTarget = dynamic_cast<NumericFormatter*>(get(elem.m_sID)); * include/vcl/transfer.hxx DragSourceHelper: > svx/source/sdr/contact/sdrmediawindow.cxx:163:47: error: suspicious dynamic cross cast from 'vcl::Window *' to 'DragSourceHelper *' [loplugin:crosscast] > DragSourceHelper* pDragSourceHelper = dynamic_cast< DragSourceHelper* >( pWindow ); * include/vcl/transfer.hxx DropTargetHelper: > svx/source/sdr/contact/sdrmediawindow.cxx:126:47: error: suspicious dynamic cross cast from 'vcl::Window *' to 'DropTargetHelper *' [loplugin:crosscast] > DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow ); > svx/source/sdr/contact/sdrmediawindow.cxx:145:47: error: suspicious dynamic cross cast from 'vcl::Window *' to 'DropTargetHelper *' [loplugin:crosscast] > DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow ); * include/vcl/wizardmachine.hxx IWizardPageController: > vcl/source/control/wizardmachine.cxx:1274:46: error: suspicious dynamic cross cast from 'BuilderPage *' to 'IWizardPageController *' [loplugin:crosscast] > IWizardPageController* pController = dynamic_cast<IWizardPageController*>(pCurrentPage); * include/xmloff/settingsstore.hxx DocumentSettingsSerializer: > xmloff/source/draw/sdxmlimp.cxx:540:15: error: suspicious dynamic cross cast from 'com::sun::star::beans::XPropertySet *' to 'DocumentSettingsSerializer *' [loplugin:crosscast] > pFilter = dynamic_cast<DocumentSettingsSerializer *>(xProps.get()); > xmloff/source/draw/sdxmlexp.cxx:2474:41: error: suspicious dynamic cross cast from 'com::sun::star::beans::XPropertySet *' to 'DocumentSettingsSerializer *' [loplugin:crosscast] > DocumentSettingsSerializer *pFilter(dynamic_cast<DocumentSettingsSerializer *>(xProps.get())); * include/xmloff/xmlimp.hxx SvXMLImport: > sdext/source/pdfimport/sax/emitcontext.cxx:45:37: error: suspicious dynamic cross cast from 'com::sun::star::xml::sax::XDocumentHandler *' to 'SvXMLImport *' [loplugin:crosscast] > if (SvXMLImport *pFastHandler = dynamic_cast<SvXMLImport*>(m_xDocHdl.get())) > writerperfect/source/common/DocumentHandler.cxx:118:37: error: suspicious dynamic cross cast from 'com::sun::star::xml::sax::XDocumentHandler *' to 'SvXMLImport *' [loplugin:crosscast] > if (SvXMLImport* pFastHandler = dynamic_cast<SvXMLImport*>(mxHandler.get())) * reportdesign/inc/RptObject.hxx OObjectBase: > reportdesign/source/ui/report/ViewsWindow.cxx:843:53: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObjBase = dynamic_cast<OObjectBase*>(pObj); > reportdesign/source/core/sdr/ReportUndoFactory.cxx:30:25: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(&rObject); > reportdesign/source/core/sdr/RptPage.cxx:62:29: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(GetObj(i)); > reportdesign/source/core/sdr/RptPage.cxx:77:30: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pBase = dynamic_cast<OObjectBase*>(GetObj(nPos)); > reportdesign/source/core/sdr/RptPage.cxx:116:28: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObject = dynamic_cast< OObjectBase* >(SdrObject::getSdrObjectFromXShape( _xObject )); > reportdesign/source/core/sdr/RptPage.cxx:184:32: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObjectBase = dynamic_cast< OObjectBase* >( pObj ); > reportdesign/source/core/sdr/ReportDrawPage.cxx:60:29: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj); > reportdesign/source/ui/report/dlgedfunc.cxx:455:25: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(_pOverlappedObj); > reportdesign/source/ui/report/SectionView.cxx:177:37: error: suspicious dynamic cross cast from 'SdrObject' to 'OObjectBase &' [loplugin:crosscast] > OObjectBase& rBaseObj = dynamic_cast<OObjectBase&>(*pObj); > reportdesign/source/ui/report/ReportSection.cxx:338:29: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(pSdrObject); > reportdesign/source/ui/report/ReportSection.cxx:513:38: error: suspicious dynamic cross cast from 'SdrObject' to 'OObjectBase &' [loplugin:crosscast] > OObjectBase& rBase = dynamic_cast<OObjectBase&>(*pObject); > reportdesign/source/ui/report/ReportSection.cxx:644:33: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(pDlgEdObj); > reportdesign/source/ui/report/ReportSection.cxx:663:35: error: suspicious dynamic cross cast from 'const SdrObject *' to 'const OObjectBase *' [loplugin:crosscast] > const OObjectBase* pObj = dynamic_cast<const OObjectBase*>(pDlgEdObj); > reportdesign/source/ui/report/propbrw.cxx:286:33: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObj = dynamic_cast<OObjectBase*>(pCurrent); > reportdesign/source/ui/report/ViewsWindow.cxx:843:53: error: suspicious dynamic cross cast from 'SdrObject *' to 'OObjectBase *' [loplugin:crosscast] > OObjectBase* pObjBase = dynamic_cast<OObjectBase*>(pObj); * sc/source/ui/inc/IAnyRefDialog.hxx IAnyRefDialog: > sc/source/ui/app/scmod.cxx:1607:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/app/scmod.cxx:1646:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/app/scmod.cxx:1697:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/app/scmod.cxx:1766:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/app/scmod.cxx:1813:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/app/scmod.cxx:1853:38: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/view/tabview3.cxx:470:30: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(xDlgController.get()); > sc/source/ui/view/tabview3.cxx:2053:42: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); > sc/source/ui/view/tabvwsh4.cxx:210:46: error: suspicious dynamic cross cast from 'element_type *' (aka 'SfxDialogController *') to 'IAnyRefDialog *' [loplugin:crosscast] > IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pController.get()); * sd/source/filter/eppt/epptbase.hxx PPTExBulletProvider: > sd/source/filter/eppt/pptx-epptbase.cxx:497:74: error: suspicious dynamic cross cast from 'PPTWriterBase *' to 'PPTExBulletProvider *' [loplugin:crosscast] > maStyleSheetList.emplace_back( new PPTExStyleSheet( nDefaultTab, dynamic_cast<PPTExBulletProvider*>(this) ) ); * sdext/source/presenter/PresenterViewFactory.hxx CachablePresenterView: > sdext/source/presenter/PresenterViewFactory.cxx:218:36: error: suspicious dynamic cross cast from 'com::sun::star::drawing::framework::XResource *' to 'CachablePresenterView *' [loplugin:crosscast] > CachablePresenterView* pView = dynamic_cast<CachablePresenterView*>(rxView.get()); > sdext/source/presenter/PresenterViewFactory.cxx:274:23: error: suspicious dynamic cross cast from 'com::sun::star::drawing::framework::XView *' to 'CachablePresenterView *' [loplugin:crosscast] > = dynamic_cast<CachablePresenterView*>(iView->second.first.get()); > sdext/source/presenter/PresenterViewFactory.cxx:325:40: error: suspicious dynamic cross cast from 'com::sun::star::drawing::framework::XView *' to 'CachablePresenterView *' [loplugin:crosscast] > CachablePresenterView* pView = dynamic_cast<CachablePresenterView*>(xView.get()); * slideshow/source/inc/cursormanager.hxx CursorManager: > slideshow/source/engine/slide/userpaintoverlay.cxx:449:49: error: suspicious dynamic cross cast from 'CursorManager' to 'Slide &' [loplugin:crosscast] > dynamic_cast<Slide&>(rContext.mrCursorManager), * svx/source/inc/celltypes.hxx TableDesignUser: > svx/source/table/tabledesign.cxx:267:38: error: suspicious dynamic cross cast from 'com::sun::star::util::XModifyListener *' to 'TableDesignUser *' [loplugin:crosscast] > TableDesignUser* pUser = dynamic_cast< TableDesignUser* >( it.next().get() ); * svx/source/inc/tablemodel.hxx ICellRange: > svx/source/table/tablemodel.cxx:285:26: error: suspicious dynamic cross cast from 'com::sun::star::table::XCellRange *' to 'ICellRange *' [loplugin:crosscast] > ICellRange* pRange = dynamic_cast< ICellRange* >( rRange.get() ); * sw/inc/IDocumentUndoRedo.hxx IDocumentUndoRedo: > sw/source/uibase/shells/drwtxtsh.cxx:585:38: error: suspicious dynamic cross cast from 'SfxUndoManager *' to 'IDocumentUndoRedo *' [loplugin:crosscast] > auto* pUndoManager = dynamic_cast<IDocumentUndoRedo*>(GetUndoManager()); * sw/inc/IMark.hxx IFieldmark: > sw/source/core/doc/docbm.cxx:1415:15: error: suspicious dynamic cross cast from 'sw::mark::MarkBase *const' to 'IFieldmark *' [loplugin:crosscast] > : dynamic_cast<IFieldmark*>(*pFieldmark); > sw/source/core/doc/docbm.cxx:1437:16: error: suspicious dynamic cross cast from 'sw::mark::MarkBase *' to 'IFieldmark *' [loplugin:crosscast] > return dynamic_cast<IFieldmark*>(pFieldmark); > sw/source/core/doc/docbm.cxx:1570:37: error: suspicious dynamic cross cast from 'sw::mark::MarkBase *' to 'IFieldmark *' [loplugin:crosscast] > IFieldmark *pMark = dynamic_cast<IFieldmark*>(*aIter); * sw/inc/calbck.hxx BroadcastingModify: > sw/source/core/attr/swatrset.cxx:228:29: error: suspicious dynamic cross cast from 'const sw::BroadcastingModify *' to 'const sw::FormatDropDefiner *' [loplugin:crosscast] > auto pDropDefiner = dynamic_cast<const sw::FormatDropDefiner*>(pModify); > sw/source/core/txtnode/OnlineAccessibilityCheck.cxx:38:28: error: suspicious dynamic cross cast from 'SwNode *' to 'sw::BroadcastingModify *' [loplugin:crosscast] > auto* pBroadcast = dynamic_cast<sw::BroadcastingModify*>(m_pNode); * sw/inc/contentindex.hxx SwContentIndexReg: > sw/source/core/doc/DocumentRedlineManager.cxx:56:20: error: suspicious dynamic cross cast from 'SwNode *' to 'SwContentIndexReg *' [loplugin:crosscast] > assert(dynamic_cast<SwContentIndexReg*>(&pPos->GetNode()) * sw/source/core/inc/flowfrm.hxx SwFlowFrame: > sw/source/core/layout/frmtool.cxx:3044:35: error: suspicious dynamic cross cast from 'SwFrame *' to 'SwFlowFrame *' [loplugin:crosscast] > SwFlowFrame *pFlowFrame = dynamic_cast<SwFlowFrame*>(pSibling); * sw/source/uibase/inc/FrameControl.hxx ISwFrameControl: > sw/source/uibase/docvw/FrameControlsManager.cxx:283:15: error: suspicious dynamic cross cast from 'vcl::Window *' to 'ISwFrameControl *' [loplugin:crosscast] > mpIFace = dynamic_cast<ISwFrameControl *>( pWindow.get() ); * vcl/inc/IPrioritable.hxx IPrioritable: > vcl/source/control/NotebookbarPopup.cxx:40:37: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IPrioritable *' [loplugin:crosscast] > vcl::IPrioritable* pChild = dynamic_cast<vcl::IPrioritable*>(GetChild(0)); > vcl/source/control/PriorityHBox.cxx:89:43: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IPrioritable *' [loplugin:crosscast] > vcl::IPrioritable* pPrioritable = dynamic_cast<vcl::IPrioritable*>(pChild); > vcl/source/control/PriorityHBox.cxx:127:32: error: suspicious dynamic cross cast from 'vcl::IPrioritable *' to 'vcl::Window *' [loplugin:crosscast] > vcl::Window* pWindow = dynamic_cast<vcl::Window*>(pPrioritable); > vcl/source/control/PriorityHBox.cxx:142:32: error: suspicious dynamic cross cast from 'vcl::IPrioritable *' to 'vcl::Window *' [loplugin:crosscast] > vcl::Window* pWindow = dynamic_cast<vcl::Window*>(*pChildR); > vcl/source/control/PriorityHBox.cxx:186:43: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IPrioritable *' [loplugin:crosscast] > vcl::IPrioritable* pPrioritable = dynamic_cast<vcl::IPrioritable*>(pChild); > vcl/source/window/NotebookBarAddonsMerger.cxx:128:19: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IPrioritable *' [loplugin:crosscast] > = dynamic_cast<vcl::IPrioritable*>(pOptionalParent.get()); > ovcl/source/window/builder.cxx:3643:55: error: suspicious dynamic cross cast from 'vcl::Window *' to 'vcl::IPrioritable *' [loplugin:crosscast] > vcl::IPrioritable* pPrioritable = dynamic_cast<vcl::IPrioritable*>(pCurrentChild.get()); * vcl/inc/jsdialog/jsdialogbuilder.hxx BaseJSWidget: > vcl/jsdialog/executor.cxx:41:26: error: suspicious dynamic cross cast from 'weld::Widget *' to 'BaseJSWidget *' [loplugin:crosscast] > if (auto pJSWidget = dynamic_cast<BaseJSWidget*>(pWidget)) > vcl/jsdialog/executor.cxx:49:26: error: suspicious dynamic cross cast from 'weld::Widget *' to 'BaseJSWidget *' [loplugin:crosscast] > if (auto pJSWidget = dynamic_cast<BaseJSWidget*>(pWidget)) > vcl/jsdialog/executor.cxx:155:49: error: suspicious dynamic cross cast from 'weld::MenuButton *' to 'BaseJSWidget *' [loplugin:crosscast] > BaseJSWidget* pMenuButton = dynamic_cast<BaseJSWidget*>(pButton); * vcl/inc/unx/x11/x11gdiimpl.h X11GraphicsImpl: > vcl/unx/generic/gdi/salgdi.cxx:387:36: error: suspicious dynamic cross cast from 'pointer' (aka 'SalGraphicsImpl *') to 'X11GraphicsImpl *' [loplugin:crosscast] > if( X11GraphicsImpl* x11Impl = dynamic_cast< X11GraphicsImpl* >( mxImpl.get())) * xmlsecurity/inc/certificate.hxx Certificate: > xmlsecurity/source/helper/documentsignaturemanager.cxx:334:33: error: suspicious dynamic cross cast from 'com::sun::star::security::XCertificate *' to 'xmlsecurity::Certificate *' [loplugin:crosscast] > if (auto pCertificate = dynamic_cast<xmlsecurity::Certificate*>(xCert.get())) > xmlsecurity/source/helper/documentsignaturemanager.cxx:381:33: error: suspicious dynamic cross cast from 'com::sun::star::security::XCertificate *' to 'xmlsecurity::Certificate *' [loplugin:crosscast] > if (auto pCertificate = dynamic_cast<xmlsecurity::Certificate*>(xCert.get())) > xmlsecurity/source/component/documentdigitalsignatures.cxx:688:28: error: suspicious dynamic cross cast from 'com::sun::star::security::XCertificate *' to 'xmlsecurity::Certificate *' [loplugin:crosscast] > auto pAuthor = dynamic_cast<xmlsecurity::Certificate*>(xAuthor.get()); > xmlsecurity/source/component/documentdigitalsignatures.cxx:689:26: error: suspicious dynamic cross cast from 'com::sun::star::security::XCertificate *' to 'xmlsecurity::Certificate *' [loplugin:crosscast] > auto pCert = dynamic_cast<xmlsecurity::Certificate*>(xCert.get()); > xmlsecurity/qa/unit/signing/signing.cxx:130:29: error: suspicious dynamic cross cast from 'com::sun::star::security::XCertificate *' to 'xmlsecurity::Certificate *' [loplugin:crosscast] > auto pCertificate = dynamic_cast<xmlsecurity::Certificate*>(xCertificate.get()); Change-Id: If4f9efd8c012d0f650fe670450cf7ac0c8978036 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143458 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-25Fold OldBasicPassword into basic::SfxScriptLibraryContainerStephan Bergmann
Change-Id: Iaeaf30f63760185a2b1dd72feb980b94d9931d55 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143253 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-23Fix loplugin:redundantcast check for same-type dynamic_castStephan Bergmann
...when the target type is a reference type and the source and target type have different cv qualifiers. (And fix the fallout. And make the tests cover that somewhat more exhaustively; and while at it also test that the plugin can cope with dynamic_cast to void pointers, which is the only legitimate case where a dynamic_cast can involve types that are not (pointers or references to) non-class types.) Change-Id: Ia568ddb5dbc4a84c275db172791c345d95964857 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143133 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-22loplugin:unusedfields update the post-process scriptNoel Grandin
(*) ignore temporary fields in lambdas (*) don't ignore the vcl/weld stuff anymore Change-Id: I4cda18f779588409891a2b2f8b1371e60f9b9ac0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143090 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-11-18Related tdf#104597, tdf#151546: Introduce comphelper::string::reverseCodePointsStephan Bergmann
69e9925ded584113e52f84ef0ed7c224079fa061 "sdext.pdfimport: resolves tdf#104597: RTL script text runs are reversed" and f6004e1c457ddab5e0c91e6159875d25130b108a "tdf#151546: RTL text is reversed (Writer pdfimport)" had introduced two calls to comphelper::string::reverseString into sdext. That function reverts on the basis of individual UTF-16 code units, not on the basis of Unicode code points. And while at least some pre-existing callers of that function want the former semantics (see below), these two new callers in sdext apparently want the latter semantics. Therefore, introduce an additional function comphelper::string::reverseCodePoints with the latter semantics. I identified three other places that call comphelper::string::reverseString: * SbRtl_StrReverse in basic/source/runtime/methods1.cxx apparently implements some StrReverse Basic function, where a (presumably non-existing) Basic spec would need to decide which of the two semantics is called for. So leave it alone for now. * SvtFileDialog::IsolateFilterFromPath_Impl in fpicker/source/office/iodlg.cxx reverts a string, operates on it, then reverts (parts of) it back. Whether or not that is the most elegant code, using the latter semantics here would apparently be wrong, as double invocation of comphelper::string::reverseCodePoints is not idempotent when the input is a malformed sequence of UTF-16 code units containing a low surrogate followed by a high surrogate. * AccessibleCell::getCellName in svx/source/table/accessiblecell.cxx apparently always operates on a string consisting only of Latin uppercase letters A--Z, for which both semantics are equivalent. (So we can just as well stick with the simpler comphelper::string::reverseString here.) (Extending the tests in comphelper/qa/string/test_string.cxx ran into an issue where loplugin:stringliteralvar warns about deliberate uses of sal_Unicode arrays rather than UTF-16 string literals wrapped in OUStringLiteral, as those arrays deliberately contain malformed UTF-16 code unit sequences and thus converting them into UTF-16 string literals might be considered inappropriate, see the newly added comment at StringLiteralVar::isPotentiallyInitializedWithMalformedUtf16 in compilerplugins/clang/stringliteralvar.cxx for details. So that loplugin had to be improved here, too.) Change-Id: I641cc32c76b0c5f6339ae44d8aa85df0022ffb05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142949 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-11New loplugin:constmoveStephan Bergmann
"Find occurrences of std::move on const-qualified types. While there might theoretically be legitimate uses for such (for which this plugin would generate false positives and would need to be updated), in practice they tend to point at suspicious code that should be cleaned up in some way." (All issues found for a Linux build have already been addressed with eleven recent commits mentioning in their commit messages: "I came across this code with an upcoming loplugin:constmove that flags suspicious uses of std::move involving const-qualified types.") Change-Id: I891a66eb0ec5f9b7d93536bbccea0359893383df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142589 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-06-Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): compilerpluginsStephan Bergmann
Change-Id: I9a4d20cd42d6c836aa74837688a272f849d9d373 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142322 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-05loplugin:stringconcatauto: There's no dangling-ref issue with O[U]StringNumberStephan Bergmann
...so it's unclear why 2f5f45921b05904a4be1ff633be09c62cb44ff08 "support O(U)String::number() for fast string concatenation" added that here. On the contrary, variables of type OStringNumber can be useful replacements for calls to std::sprintf (which started to emit deprecation warnings with macOS 13 SDK now), so this is in preparation for follow-up commits that will replace many uses of that across the code base with various alternatives. Change-Id: I6f8508d49dc84773c50f4c33dba38fe08c4c8969 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142318 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-10-26Adapt compilerplugins to recent Clang 16 trunk changeStephan Bergmann
<https://github.com/llvm/llvm-project/commit/1acffe81ee9117691812b9bf8747c03354177d15> "NFC: [clang] Template argument cleanups." Change-Id: I84bc276c21efcc11643ae7003e0fee6c7592130f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141860 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-10-22loplugin:unusedmethodsNoel Grandin
Change-Id: I3c94d68cb85adc2005a5a5e3b03a311732f782c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141617 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-10-21loplugin:referencecasting look for a new patternNoel Grandin
Change-Id: Ib7ded8db2c513909159f0876389f63b60082a529 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141618 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-10-21loplugin:unnecessaryvirtualNoel Grandin
Make the script filter out more external code Change-Id: I131da451e148e193552ead7c1441b06b726df619 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141616 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-10-18Adapt compilerplugins to recent Clang 16 trunk changeStephan Bergmann
<https://github.com/llvm/llvm-project/commit/bcd9ba2b7e64f6ce54defd2fa73fc8e0fee5707c> "[clang] Track the templated entity in type substitution." Change-Id: I314d1567512dc0332b3c61c95978b0230f52b274 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141462 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-10-17loplugin:redundantcast look for redundant dynamic_cast<T&>Noel Grandin
Change-Id: If5a8e74b7ede80b782b584b4f62ec1b8713fd86d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141445 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-10-14Clean up loplugin:stringviewStephan Bergmann
...after 3d236177be255b2027a997bfc12fe0833ca9a2f7 "Deduplicate O(U)StringConcatenation" changed OStringConcat and OUStringConcat into aliases (so they will get looked through by loplugin::TypeCheck::Struct's use of getAs<clang::RecordType> in compilerplugins/clang/check.hxx), but apparently forgot to drop their respective checks here. (That the then-added check for StringConcat works as intended is verified by compilerplugins/clang/test/stringview.cxx, btw.) Change-Id: I3f8e26998d0a55704f0433a818493ef541fd05eb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141370 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-10-14Clean up loplugin:stringaddStephan Bergmann
...after 3d236177be255b2027a997bfc12fe0833ca9a2f7 "Deduplicate O(U)StringConcatenation" changed OStringConcat and OUStringConcat into aliases (so they can never show up here in a "getUnqualifiedDesugareType"), but apparently forgot to drop their respective checks here. (That the then-added check for StringConcat works as intended is verified by compilerplugins/clang/test/stringadd.cxx, btw.) Change-Id: I2b589d977dbf2a384348cb7ee62acce30031ccec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141364 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-10-14Fix loplugin:stringconcatautoStephan Bergmann
...after af2879e434fa0dc6b2a626617ed865e4f66eb5ad "Deduplicate stringconcat more" changed the *StringNumberBase::toAsciiUperCase return typr from O[U]StringNumber to the underlying StringNumberBase. (And where that commit had added some odd check for a non-existing "StringNumber" type to compilerplugins/clang/stringconcatauto.cxx, presumably in error.) Change-Id: I622e6ae30fcec8f081c978eaf67ffb716a10ee4e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141363 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-10-13Drop now-redundant %selectStephan Bergmann
...after 3d236177be255b2027a997bfc12fe0833ca9a2f7 "Deduplicate O(U)StringConcatenation" Change-Id: Ib45d021da2bb5745055fa0cdebfd700680bfb787 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141304 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-10-13Adapt CompilerTest_compilerplugins_clang to recent ClangStephan Bergmann
...where at least my recent Clang 16 trunk build now started to fail after af2879e434fa0dc6b2a626617ed865e4f66eb5ad "Deduplicate stringconcat more" with > error: 'error' diagnostics expected but not seen: > File compilerplugins/clang/test/stringview.cxx Line 171 (directive at compilerplugins/clang/test/stringview.cxx:170): instead of an '{{(rtl::)?}}OString' constructed from a 'OStringConcat<rtl::OString, rtl::OString>' (aka 'StringConcat<char, rtl::OString, rtl::OString>'), pass a 'std::string_view' via 'rtl::Concat2View' [loplugin:stringview] > File compilerplugins/clang/test/stringview.cxx Line 196 (directive at compilerplugins/clang/test/stringview.cxx:195): instead of an '{{(rtl::)?}}OUString' constructed from a 'OUStringConcat<rtl::OUString, rtl::OUString>' (aka 'StringConcat<char16_t, rtl::OUString, rtl::OUString>'), pass a 'std::u16string_view' via 'rtl::Concat2View' [loplugin:stringview] > error: 'error' diagnostics seen but not expected: > File compilerplugins/clang/test/stringview.cxx Line 171: instead of an 'OString' constructed from a 'OStringConcat<OString, OString>' (aka 'StringConcat<char, rtl::OString, rtl::OString>'), pass a 'std::string_view' via 'rtl::Concat2View' [loplugin:stringview] > File compilerplugins/clang/test/stringview.cxx Line 196: instead of an 'OUString' constructed from a 'OUStringConcat<OUString, OUString>' (aka 'StringConcat<char16_t, rtl::OUString, rtl::OUString>'), pass a 'std::u16string_view' via 'rtl::Concat2View' [loplugin:stringview] > 4 errors generated. > make[1]: *** [solenv/gbuild/LinkTarget.mk:337: workdir/CxxObject/compilerplugins/clang/test/stringview.o] Error 1 Change-Id: I0b8c7d4a012c40c2c2c3cc8a9e55c52f45e8cfc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141295 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-10-13Deduplicate stringconcat moreMike Kaganski
In the process, drop ToStringHelper::allowO(U)StringConcat, because we can deduce this information from ToStringHelper's addData itself. To do that, addData was converted to ToStringHelper::operator(), which allows to use std::is_invocable_v on the helper class. Change-Id: Ic77878ca0ff65ada8c0a942191bc11de15b9ad2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141254 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-10-12tdf#147021 REVERT Use std::size() instead of SAL_N_ELEMENTS() macrojsala
Reverting this changes made by error. See https://gerrit.libreoffice.org/c/core/+/136263/6/compilerplugins/clang/test/constvars.cxx#25 Change-Id: Ica49759682adf55a1f0cef2a842acab603c62dac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141259 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins
2022-10-11Deduplicate O(U)StringConcatenationMike Kaganski
And use an overloaded helper function with a better (?) unified name to show that the result is not an O(U)String. Change-Id: I8956338b05d02bf46a6185828130ea8ef145d46b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141203 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-09-25unwrap SwDelChr to plain SfxHintBjoern Michaelsen
Change-Id: Ief37a8025181b6cc8a6e484e2726d8a8d92f57ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140567 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
2022-09-25unwrap SwInsText to a plain SfxHintBjoern Michaelsen
- also add some constnesss and move some things to private Change-Id: I67a45e1326361b5a8f7e320b3525e74e93b1ef12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140556 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
2022-09-24unwrap SwDelText to a plain SfxHintBjoern Michaelsen
Change-Id: I559f8f1e837830426e820dace6226618c5e0fc62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140210 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
2022-09-23remove some dead codeNoel Grandin
after commit 590796ca0866168e3129d2abd0a0197114cddcdc Author: Noel Grandin <noelgrandin@gmail.com> Date: Wed Sep 21 20:44:42 2022 +0200 convert TrueTypeTable to C++ class Change-Id: I5c656011ebe37529788cea6a749c07ada2378385 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140433 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-21Extend loplugin:redundantcast to some suspicious reinterpret_castStephan Bergmann
Change-Id: I5534939bfbea67d216a17891722a683c53621d36 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140303 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-09-14new loplugin refcountingbaseNoel Grandin
Look for classes that have more than one ref-counting base class. A situation which is going to cause trouble. Which reveals that sdr::table::Cell has two different ref-counting bases, so rather make SdrText extends OWeakObject, which means that Cell can just have one ref-counting base, Change-Id: I8d968270f7b449cff2f29da0bd48fa17181c68c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139807 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-08Clean up some #includesStephan Bergmann
...after 9e7e95a57b7c16941d9fdc59f806c1f9e4263379 "tdf#147021 Use std::size() instead of SAL_N_ELEMENTS() macro" (and somewhat pedantically use the canonical <iterator> for std::size, even though the existing <vector> defines it, too) Change-Id: Iacf0a0619b496bfe7c6abb0a812b6a1b3eed40c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139653 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-09-08loplugin:unnecessaryvirtualNoel Grandin
Change-Id: I4461ca826960b194cf45ae4917093f3273b3b0a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139643 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-08loplugin:virtualdeadNoel Grandin
Change-Id: Iceb6916bcc8c211a72fccfa4bbcbb22c96a72050 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139642 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-05vcl: Rename LongPress event to GestureLongPressPovilas Kanapickas
We have 5 gesture types: GestureZoom, GestureRotate, GesturePan, GestureSwipe and LongPress. For consistency all of these will use Gesture as a prefix to reduce confusion and for easier grepping throughout the codebase. Change-Id: I8b9e245d011203a19c1172f9833c172f65382cab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139244 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-05vcl: Rename Swipe event to GestureSwipePovilas Kanapickas
We have 5 gesture types: GestureZoom, GestureRotate, GesturePan, Swipe and LongPress. For consistency all of these will use Gesture as a prefix to reduce confusion and for easier grepping throughout the codebase. Change-Id: I8b9e245d011203a19c1172f9833c172f65382caa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139243 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-05vcl: Rename Gesture event to GesturePanPovilas Kanapickas
We have 5 gesture types: GestureZoom, GestureRotate, Gesture (for panning), Swipe and LongPress. For consistency all of these will use Gesture as a prefix to reduce confusion and for easier grepping throughout the codebase. Change-Id: I8b9e245d011203a19c1172f9833c172f65382ca9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139241 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-04tdf#147021 Use std::size() instead of SAL_N_ELEMENTS() macrojsala
Change associated for by std::find_if in sqlbison.y Also change some integer by std::size_t Change-Id: I0d2100fbd7c22729da6ce0462c6cc093e0767fb4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136263 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
2022-08-29ref-count SdrObjectNoel Grandin
Which means we can get rid of the majestic hack of ScCaptionPtr Previously, SdrObject was manually managed, and the ownership passed around in very complicated fashion. Notes: (*) SvxShape has a strong reference to SdrObject, where previously it had a weak reference. It is now strong since otherwise the SdrObject will go away very eagerly. (*) SdrObject still has a weak reference to SvxShape (*) In the existing places that an SdrObject is being deleted, we now just clear the reference (*) instead of SwVirtFlyDrawObj removing itself from the page that contains inside it's destructor, make the call site do the removing from the page. (*) Needed to take the SolarMutex in UndoManagerHelper_Impl::impl_clear because this can be called from UNO (e.g. sfx2_complex JUnit test) and the SdrObjects need the SolarMutex when destructing. (*) handle a tricky situation with SwDrawVirtObj in the SwDrawModel destructor because the existing code wants mpDrawObj in SwAnchoredObject to be sometimes owning, sometimes not, which results in a cycle with the new code. Change-Id: I4d79df1660e386388e5d51030653755bca02a163 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138837 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-18Move tools/diagnose_ex.h to comphelper/diagnose_ex.hxxStephan Bergmann
...so that its TOOLS_WARN_EXCEPTION can be used in comphelper/source/misc/logging.cxx in a follow-up commit. (And while at it, rename from diangose_ex.h to the more appropriate diagnose_ex.hxx. The comphelper module is sufficiently low-level for this immediate use case, so use that at least for now; o3tl might be even more suitable but doesn't have a Library until now. Also, for the immediate use case it would have sufficed to only break DbgGetCaughtException, exceptionToString, TOOLS_WARN_EXCEPTION, TOOLS_WARN_EXCEPTION_IF, and TOOLS_INFO_EXCEPTION out of include/tools/diagnose_ex.h into an additional new include/comphelper/diagnose_ex.hxx, but its probably easier overall to just move the complete include file as is.) Change-Id: I9f3222d4ccf1a9ac29d7eb9ba1530d53e2affaee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138451 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-08-18loplugin:moveitNoel Grandin
Change-Id: I34de7408553e4ca702cab9aa611c03dc60b9b6a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138472 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-13loplugin:unusedmethodsNoel Grandin
tweak the python script to code with some clang weirdnes Change-Id: I88fc9f901748ff44af2b67704cc437b770ef0737 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138196 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-12loplugin:unusedfieldsNoel Grandin
Change-Id: I8d15b380cd02237f688b8946530e1f024b698e90 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138195 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-10loplugin:passstuffbyrefNoel Grandin
Change-Id: Ib2b2650da7abc9260897f9b5aad619a0ea6ae941 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138052 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-08Adapt to changed clang::LambdaCapture::getCapturedVar return typeStephan Bergmann
...where <https://github.com/llvm/llvm-project/commit/127bf44385424891eb04cff8e52d3f157fc2cb7c> "[Clang][C++20] Support capturing structured bindings in lambdas" on Clang 16 trunk changed the return type from VarDecl to ValueDecl, causing > compilerplugins/clang/reducevarscope.cxx:541:26: error: no matching member function for call to 'erase' > maVarDeclMap.erase(varDecl); > ~~~~~~~~~~~~~^~~~~ > /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/unordered_map.h:740:7: note: candidate function not viable: no known conversion from 'ValueDecl *' to 'const_iterator' (aka '_Node_const_iterator<std::pair<const clang::VarDecl *const, (anonymous namespace)::ReduceVarScope::DepthInfo>, __constant_iterators::value, __hash_cached::value>') for 1st argument > erase(const_iterator __position) > ^ > /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/unordered_map.h:745:7: note: candidate function not viable: no known conversion from 'ValueDecl *' to 'iterator' (aka '_Node_iterator<std::pair<const clang::VarDecl *const, (anonymous namespace)::ReduceVarScope::DepthInfo>, __constant_iterators::value, __hash_cached::value>') for 1st argument > erase(iterator __position) > ^ > /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/unordered_map.h:762:7: note: candidate function not viable: cannot convert from base class pointer 'ValueDecl *' to derived class pointer 'const key_type' (aka 'const clang::VarDecl *const') for 1st argument > erase(const key_type& __x) > ^ > /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/unordered_map.h:780:7: note: candidate function not viable: requires 2 arguments, but 1 was provided > erase(const_iterator __first, const_iterator __last) > ^ etc. Change-Id: I79b062ca604435bc83a58eeb32df673e6c658bd6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137984 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-08-08Adapt to changes in llvm::OptionalStephan Bergmann
<https://github.com/llvm/llvm-project/commit/3c49576417bab1b07764aa0b22664cbc8d3c3f53> "[ADT] Add has_value, value, value_or to llvm::Optional" is in Clang 15, and <https://github.com/llvm/llvm-project/commit/b5f8d42efe3e246d582d4a1a328fac915e4ce8dc> "[ADT] Deprecate Optional::{hasValue,getValue} (NFC)" is in Clang 16 trunk, causing > In file included from compilerplugins/clang/sharedvisitor/sharedvisitor.cxx:95: > compilerplugins/clang/pointerbool.cxx:118:21: error: 'hasValue' is deprecated: Use has_value instead. [-Werror,-Wdeprecated-declarations] > if (ret.hasValue() && (ret.getValue() == 1 || ret.getValue() == 0)) > ^ > ~/llvm/inst/include/llvm/ADT/Optional.h:324:5: note: 'hasValue' has been explicitly marked deprecated here > [[deprecated("Use has_value instead.")]] constexpr bool hasValue() const { > ^ etc. Change-Id: I377effe29fc6752484d2870b9a0fd66fddc26bfc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137982 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-08-04Adapt test to LLVM 16 trunk libc++Stephan Bergmann
...see <https://github.com/llvm/llvm-project/commit/309aed306817e5b1a302d8f757231c734cf71370> "[libc++] Implement P1423R3 (char8_t backward compatibility remediation)" causing > error: 'error' diagnostics seen but not expected: > compilerplugins/clang/test/getstr.cxx Line 43: overload resolution selected deleted operator '<<' Change-Id: Ic2fb9409cf3033300aca6717a8db7889e9d03c6a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137786 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-07-28remove unused SETBULLETTEXT flag in editengJustin Luth
Already unused in initial import. Change-Id: I423442a2b036c64727af608fa667f1f8a427391f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137542 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
2022-07-25loplugin:moveitNoel Grandin
make the plugin more conservative, so we see less false+ (although we also miss some possibilities in the process) Change-Id: I91b1806271e7f802d7459834ab7bcc569047da3a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137342 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-14Adapt to Clang 15 trunk increase in ElabortatedType sugarStephan Bergmann
...<https://github.com/llvm/llvm-project/commit/bdc6974f92304f4ed542241b9b89ba58ba6b20aa> "[clang] Implement ElaboratedType sugaring for types written bare". For one, it caused diagnostics to now emit 'OString' instead of 'rtl::OUString' etc., which required adapting a number of tests. For another, some tests started to fail because the relevant plugins didn't expect ElaboratedType sugar in places where it now occurs: > error: 'error' diagnostics expected but not seen: > File compilerplugins/clang/test/redundantcast.cxx Line 297: redundant cstyle cast from 'Enum1' to 'Enum1' [loplugin:redundantcast] > File compilerplugins/clang/test/redundantcast.cxx Line 308: redundant cstyle cast from 'Enum1' to 'Enum1' [loplugin:redundantcast] > error: 'error' diagnostics expected but not seen: > File compilerplugins/clang/test/referencecasting.cxx Line 25 (directive at compilerplugins/clang/test/referencecasting.cxx:24): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 37 (directive at compilerplugins/clang/test/referencecasting.cxx:36): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 48 (directive at compilerplugins/clang/test/referencecasting.cxx:47): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 100 (directive at compilerplugins/clang/test/referencecasting.cxx:99): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 120 (directive at compilerplugins/clang/test/referencecasting.cxx:119): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 188 (directive at compilerplugins/clang/test/referencecasting.cxx:187): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 200 (directive at compilerplugins/clang/test/referencecasting.cxx:199): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 206 (directive at compilerplugins/clang/test/referencecasting.cxx:205): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > error: 'error' diagnostics seen but not expected: > File compilerplugins/clang/test/typedefparam.cxx Line 42: function param 1 at definition site does not match function param at declaration site, 'FooT *' (aka 'test2::Foo *') vs 'struct Foo *' [loplugin:typedefparam] > File compilerplugins/clang/test/typedefparam.cxx Line 55: function param 1 at definition site does not match function param at declaration site, 'FooT *' (aka 'test3::Foo *') vs 'Foo *' [loplugin:typedefparam] > error: 'note' diagnostics seen but not expected: > File compilerplugins/clang/test/typedefparam.cxx Line 40: declaration site here [loplugin:typedefparam] > File compilerplugins/clang/test/typedefparam.cxx Line 53: declaration site here [loplugin:typedefparam] Hopefully, there are not too many places in our plugins left that similarly don't expect ElaboratedType sugar in certain places, but which are not covered by tests. At least, a full build didn't turn up any further false positives, but there may of course be false negatives now that would go undetected. Change-Id: I9bfb1cfb57df5f6e228b512c19c664d48285b675 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137049 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-07-14loplugin:moveitNoel Grandin
Change-Id: I2702e716dc669ffbb870d36d060e110288d7a744 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137043 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>