forked from amazingfate/loongoffice
...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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐🫘: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:⭐🫘: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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:⭐: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>
700 lines
22 KiB
C++
700 lines
22 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* 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/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
* with this work for additional information regarding copyright
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
*/
|
|
|
|
/*
|
|
* This file is part of LibreOffice published API.
|
|
*/
|
|
|
|
#ifndef INCLUDED_SAL_TYPES_H
|
|
#define INCLUDED_SAL_TYPES_H
|
|
|
|
#include "sal/config.h"
|
|
|
|
#include <stddef.h>
|
|
|
|
#include "sal/macros.h"
|
|
#include "sal/typesizes.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef unsigned char sal_Bool;
|
|
# define sal_False ((sal_Bool)0)
|
|
# define sal_True ((sal_Bool)1)
|
|
|
|
/* char is assumed to always be 1 byte long */
|
|
typedef signed char sal_Int8;
|
|
typedef unsigned char sal_uInt8;
|
|
|
|
#if SAL_TYPES_SIZEOFSHORT == 2
|
|
typedef signed short sal_Int16;
|
|
typedef unsigned short sal_uInt16;
|
|
#else
|
|
#error "Could not find 16-bit type, add support for your architecture"
|
|
#endif
|
|
|
|
#if SAL_TYPES_SIZEOFLONG == 4
|
|
typedef signed long sal_Int32;
|
|
typedef unsigned long sal_uInt32;
|
|
#define SAL_PRIdINT32 "ld"
|
|
#define SAL_PRIuUINT32 "lu"
|
|
#define SAL_PRIxUINT32 "lx"
|
|
#define SAL_PRIXUINT32 "lX"
|
|
#elif SAL_TYPES_SIZEOFINT == 4
|
|
typedef signed int sal_Int32;
|
|
typedef unsigned int sal_uInt32;
|
|
#define SAL_PRIdINT32 "d"
|
|
#define SAL_PRIuUINT32 "u"
|
|
#define SAL_PRIxUINT32 "x"
|
|
#define SAL_PRIXUINT32 "X"
|
|
#else
|
|
#error "Could not find 32-bit type, add support for your architecture"
|
|
#endif
|
|
|
|
#ifdef _MSC_VER
|
|
typedef __int64 sal_Int64;
|
|
typedef unsigned __int64 sal_uInt64;
|
|
|
|
/* The following are macros that will add the 64 bit constant suffix. */
|
|
#define SAL_CONST_INT64(x) x##i64
|
|
#define SAL_CONST_UINT64(x) x##ui64
|
|
|
|
#define SAL_PRIdINT64 "I64d"
|
|
#define SAL_PRIuUINT64 "I64u"
|
|
#define SAL_PRIxUINT64 "I64x"
|
|
#define SAL_PRIXUINT64 "I64X"
|
|
#elif defined (__GNUC__)
|
|
#if SAL_TYPES_SIZEOFLONG == 8
|
|
typedef signed long int sal_Int64;
|
|
typedef unsigned long int sal_uInt64;
|
|
|
|
|
|
/* The following are macros that will add the 64 bit constant suffix. */
|
|
#define SAL_CONST_INT64(x) x##l
|
|
#define SAL_CONST_UINT64(x) x##ul
|
|
|
|
#define SAL_PRIdINT64 "ld"
|
|
#define SAL_PRIuUINT64 "lu"
|
|
#define SAL_PRIxUINT64 "lx"
|
|
#define SAL_PRIXUINT64 "lX"
|
|
#elif SAL_TYPES_SIZEOFLONGLONG == 8
|
|
typedef signed long long sal_Int64;
|
|
typedef unsigned long long sal_uInt64;
|
|
|
|
/* The following are macros that will add the 64 bit constant suffix. */
|
|
#define SAL_CONST_INT64(x) x##ll
|
|
#define SAL_CONST_UINT64(x) x##ull
|
|
|
|
#define SAL_PRIdINT64 "lld"
|
|
#define SAL_PRIuUINT64 "llu"
|
|
#define SAL_PRIxUINT64 "llx"
|
|
#define SAL_PRIXUINT64 "llX"
|
|
#else
|
|
#error "Could not find 64-bit type, add support for your architecture"
|
|
#endif
|
|
#else
|
|
#error "Please define the 64-bit types for your architecture/compiler in include/sal/types.h"
|
|
#endif
|
|
|
|
#if defined LIBO_INTERNAL_ONLY && defined __cplusplus
|
|
#define SAL_UNICODE_NOTEQUAL_WCHAR_T
|
|
typedef char16_t sal_Unicode;
|
|
#elif defined(_WIN32)
|
|
typedef wchar_t sal_Unicode;
|
|
#else
|
|
#define SAL_UNICODE_NOTEQUAL_WCHAR_T
|
|
typedef sal_uInt16 sal_Unicode;
|
|
#endif
|
|
|
|
typedef void * sal_Handle;
|
|
|
|
/* sal_Size should currently be the native width of the platform */
|
|
#if SAL_TYPES_SIZEOFPOINTER == 4
|
|
typedef sal_uInt32 sal_Size;
|
|
typedef sal_Int32 sal_sSize;
|
|
#elif SAL_TYPES_SIZEOFPOINTER == 8
|
|
typedef sal_uInt64 sal_Size;
|
|
typedef sal_Int64 sal_sSize;
|
|
#else
|
|
#error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
|
|
#endif
|
|
|
|
/* sal_PtrDiff holds the result of a pointer subtraction */
|
|
#if SAL_TYPES_SIZEOFPOINTER == 4
|
|
typedef sal_Int32 sal_PtrDiff;
|
|
#elif SAL_TYPES_SIZEOFPOINTER == 8
|
|
typedef sal_Int64 sal_PtrDiff;
|
|
#else
|
|
#error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
|
|
#endif
|
|
|
|
/* printf-style conversion specification length modifiers for size_t and
|
|
ptrdiff_t (most platforms support C99, MSC has its own extension) */
|
|
#if defined(_MSC_VER)
|
|
#define SAL_PRI_SIZET "I"
|
|
#define SAL_PRI_PTRDIFFT "I"
|
|
#else
|
|
#define SAL_PRI_SIZET "z"
|
|
#define SAL_PRI_PTRDIFFT "t"
|
|
#endif
|
|
|
|
/* sal_IntPtr, sal_uIntPtr are integer types designed to hold pointers so that any valid
|
|
* pointer to void can be converted to this type and back to a pointer to void and the
|
|
* result will compare to the original pointer */
|
|
#if SAL_TYPES_SIZEOFPOINTER == 4
|
|
typedef sal_Int32 sal_IntPtr;
|
|
typedef sal_uInt32 sal_uIntPtr;
|
|
#define SAL_PRIdINTPTR SAL_PRIdINT32
|
|
#define SAL_PRIuUINTPTR SAL_PRIuUINT32
|
|
#define SAL_PRIxUINTPTR SAL_PRIxUINT32
|
|
#define SAL_PRIXUINTPTR SAL_PRIXUINT32
|
|
#elif SAL_TYPES_SIZEOFPOINTER == 8
|
|
typedef sal_Int64 sal_IntPtr;
|
|
typedef sal_uInt64 sal_uIntPtr;
|
|
#define SAL_PRIdINTPTR SAL_PRIdINT64
|
|
#define SAL_PRIuUINTPTR SAL_PRIuUINT64
|
|
#define SAL_PRIxUINTPTR SAL_PRIxUINT64
|
|
#define SAL_PRIXUINTPTR SAL_PRIXUINT64
|
|
#else
|
|
#error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
|
|
#endif
|
|
|
|
/* The following SAL_MIN_INTn defines codify the assumption that the signed
|
|
* sal_Int types use two's complement representation. Defining them as
|
|
* "-0x7F... - 1" instead of as "-0x80..." prevents warnings about applying the
|
|
* unary minus operator to unsigned quantities.
|
|
*/
|
|
#define SAL_MIN_INT8 ((sal_Int8) (-0x7F - 1))
|
|
#define SAL_MAX_INT8 ((sal_Int8) 0x7F)
|
|
#define SAL_MAX_UINT8 ((sal_uInt8) 0xFF)
|
|
#define SAL_MIN_INT16 ((sal_Int16) (-0x7FFF - 1))
|
|
#define SAL_MAX_INT16 ((sal_Int16) 0x7FFF)
|
|
#define SAL_MAX_UINT16 ((sal_uInt16) 0xFFFF)
|
|
#define SAL_MIN_INT32 ((sal_Int32) (-0x7FFFFFFF - 1))
|
|
#define SAL_MAX_INT32 ((sal_Int32) 0x7FFFFFFF)
|
|
#define SAL_MAX_UINT32 ((sal_uInt32) 0xFFFFFFFF)
|
|
#define SAL_MIN_INT64 ((sal_Int64) (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1))
|
|
#define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF))
|
|
#define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF))
|
|
|
|
#if SAL_TYPES_SIZEOFPOINTER == 4
|
|
#define SAL_MAX_SSIZE SAL_MAX_INT32
|
|
#define SAL_MAX_SIZE SAL_MAX_UINT32
|
|
#elif SAL_TYPES_SIZEOFPOINTER == 8
|
|
#define SAL_MAX_SSIZE SAL_MAX_INT64
|
|
#define SAL_MAX_SIZE SAL_MAX_UINT64
|
|
#endif
|
|
|
|
#define SAL_MAX_ENUM 0x7fffffff
|
|
|
|
#if defined(_MSC_VER)
|
|
# define SAL_DLLPUBLIC_EXPORT __declspec(dllexport)
|
|
# define SAL_JNI_EXPORT __declspec(dllexport)
|
|
# define SAL_DLLPUBLIC_IMPORT __declspec(dllimport)
|
|
# define SAL_DLLPRIVATE
|
|
# define SAL_DLLPUBLIC_TEMPLATE
|
|
# define SAL_DLLPUBLIC_RTTI
|
|
# define SAL_CALL __cdecl
|
|
#elif defined SAL_UNX
|
|
# if defined(__GNUC__)
|
|
# if defined(DISABLE_DYNLOADING)
|
|
# define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("hidden")))
|
|
# define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
|
|
# define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("hidden")))
|
|
# define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
|
|
# define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("hidden")))
|
|
# define SAL_DLLPUBLIC_RTTI
|
|
# else
|
|
# define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default")))
|
|
# define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
|
|
# define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("default")))
|
|
# define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
|
|
# define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default")))
|
|
# if defined __clang__
|
|
# if __has_attribute(type_visibility)
|
|
# define SAL_DLLPUBLIC_RTTI __attribute__ ((type_visibility("default")))
|
|
# else
|
|
# define SAL_DLLPUBLIC_RTTI __attribute__ ((visibility("default")))
|
|
# endif
|
|
# else
|
|
# define SAL_DLLPUBLIC_RTTI
|
|
# endif
|
|
# endif
|
|
# else
|
|
# define SAL_DLLPUBLIC_EXPORT
|
|
# define SAL_JNI_EXPORT
|
|
# define SAL_DLLPUBLIC_IMPORT
|
|
# define SAL_DLLPRIVATE
|
|
# define SAL_DLLPUBLIC_TEMPLATE
|
|
# define SAL_DLLPUBLIC_RTTI
|
|
# endif
|
|
# define SAL_CALL
|
|
#else
|
|
# error("unknown platform")
|
|
#endif
|
|
|
|
/**
|
|
Exporting the symbols necessary for exception handling on GCC.
|
|
|
|
These macros are used for inline declarations of exception classes, as in
|
|
rtl/malformeduriexception.hxx.
|
|
*/
|
|
#if defined(__GNUC__)
|
|
# if defined(DISABLE_DYNLOADING)
|
|
# define SAL_EXCEPTION_DLLPUBLIC_EXPORT __attribute__((visibility("default")))
|
|
# else
|
|
# define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT
|
|
# endif
|
|
# define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE
|
|
#else
|
|
# define SAL_EXCEPTION_DLLPUBLIC_EXPORT
|
|
# define SAL_EXCEPTION_DLLPRIVATE
|
|
#endif
|
|
|
|
/** Use this as markup for functions and methods whose return value must be
|
|
checked.
|
|
|
|
Compilers that support a construct of this nature will emit a compile
|
|
time warning on unchecked return value.
|
|
*/
|
|
#if defined LIBO_INTERNAL_ONLY && defined __cplusplus
|
|
#define SAL_WARN_UNUSED_RESULT [[nodiscard]]
|
|
#elif (defined __GNUC__ \
|
|
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))) \
|
|
|| defined __clang__
|
|
# define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
|
#else
|
|
# define SAL_WARN_UNUSED_RESULT
|
|
#endif
|
|
|
|
/** Use this for pure virtual classes, e.g. class SAL_NO_VTABLE Foo { ...
|
|
This hinders the compiler from setting a generic vtable stating that
|
|
a pure virtual function was called and thus slightly reduces code size.
|
|
*/
|
|
#ifdef _MSC_VER
|
|
# define SAL_NO_VTABLE __declspec(novtable)
|
|
#else
|
|
# define SAL_NO_VTABLE
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
# pragma pack(push, 8)
|
|
#endif
|
|
|
|
/** This is the binary specification of a SAL sequence.
|
|
*/
|
|
typedef struct _sal_Sequence
|
|
{
|
|
/** reference count of sequence<br>
|
|
*/
|
|
sal_Int32 nRefCount;
|
|
/** element count<br>
|
|
*/
|
|
sal_Int32 nElements;
|
|
/** elements array<br>
|
|
*/
|
|
char elements[1];
|
|
} sal_Sequence;
|
|
|
|
#define SAL_SEQUENCE_HEADER_SIZE ((sal_Size) offsetof(sal_Sequence,elements))
|
|
|
|
#if defined( _WIN32)
|
|
#pragma pack(pop)
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif /* __cplusplus */
|
|
|
|
/** Nothrow specification for C functions.
|
|
|
|
This is a macro so it can expand to nothing in C code.
|
|
*/
|
|
#if defined __cplusplus
|
|
#if __cplusplus >= 201103L
|
|
#define SAL_THROW_EXTERN_C() noexcept
|
|
#else
|
|
#define SAL_THROW_EXTERN_C() throw ()
|
|
#endif
|
|
#else
|
|
#define SAL_THROW_EXTERN_C()
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
|
|
/** To markup destructors that coverity warns might throw exceptions
|
|
which won't throw in practice, or where std::terminate is
|
|
an acceptable response if they do
|
|
*/
|
|
#if defined(LIBO_INTERNAL_ONLY) && defined(__COVERITY__)
|
|
# define COVERITY_NOEXCEPT_FALSE noexcept(false)
|
|
#else
|
|
# define COVERITY_NOEXCEPT_FALSE
|
|
#endif
|
|
|
|
enum __sal_NoAcquire
|
|
{
|
|
/** definition of a no acquire enum for ctors
|
|
*/
|
|
SAL_NO_ACQUIRE
|
|
};
|
|
|
|
namespace com { namespace sun { namespace star { } } }
|
|
|
|
/** short-circuit extra-verbose API namespaces
|
|
|
|
@since LibreOffice 4.0
|
|
*/
|
|
namespace css = ::com::sun::star;
|
|
|
|
/** C++11 "= delete" feature.
|
|
|
|
For LIBO_INTERNAL_ONLY, calling a deleted function will cause a compile-time
|
|
error, while otherwise it will only cause a link-time error as the declared
|
|
function is not defined.
|
|
|
|
@since LibreOffice 4.1
|
|
*/
|
|
#if defined LIBO_INTERNAL_ONLY
|
|
#define SAL_DELETED_FUNCTION = delete
|
|
#else
|
|
#define SAL_DELETED_FUNCTION
|
|
#endif
|
|
|
|
/** C++11 "override" feature.
|
|
|
|
For LIBO_INTERNAL_ONLY, force the method to override an existing method in
|
|
parent, error out if the method with the correct signature does not exist.
|
|
|
|
@since LibreOffice 4.1
|
|
*/
|
|
#if defined LIBO_INTERNAL_ONLY
|
|
#define SAL_OVERRIDE override
|
|
#else
|
|
#define SAL_OVERRIDE
|
|
#endif
|
|
|
|
/** C++11 "constexpr" feature.
|
|
|
|
For LIBO_INTERNAL_ONLY, declare that it's possible to evaluate the value
|
|
at compile time.
|
|
|
|
@since LibreOffice 7.2
|
|
*/
|
|
#if defined LIBO_INTERNAL_ONLY
|
|
#define SAL_CONSTEXPR constexpr
|
|
#else
|
|
#define SAL_CONSTEXPR
|
|
#endif
|
|
|
|
/** Macro for C++11 "noexcept" vs. "throw ()" exception specification.
|
|
|
|
The latter has been removed completely from C++20.
|
|
|
|
@since LibreOffice 7.2
|
|
*/
|
|
#if __cplusplus >= 201103L
|
|
#define SAL_NOEXCEPT noexcept
|
|
#else
|
|
#define SAL_NOEXCEPT throw ()
|
|
#endif
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
namespace sal {
|
|
|
|
/**
|
|
A static_cast between integral types, to avoid C++ compiler warnings.
|
|
|
|
In C++ source code, use sal::static_int_cast<T>(n) instead of
|
|
static_cast<T>(n) whenever a compiler warning about integral type problems
|
|
shall be silenced. That way, source code that needs to be modified when the
|
|
type of any of the expressions involved in the compiler warning is changed
|
|
can be found more easily.
|
|
|
|
Both template arguments T1 and T2 must be integral types.
|
|
*/
|
|
template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) {
|
|
return static_cast< T1 >(n);
|
|
}
|
|
|
|
}
|
|
|
|
#else /* __cplusplus */
|
|
|
|
/**
|
|
A cast between integer types, to avoid C compiler warnings.
|
|
|
|
In C source code, use SAL_INT_CAST(type, expr) instead of ((type) (expr))
|
|
whenever a compiler warning about integer type problems shall be silenced.
|
|
That way, source code that needs to be modified when the type of any of the
|
|
expressions involved in the compiler warning is changed can be found more
|
|
easily.
|
|
|
|
The argument 'type' must be an integer type and the argument 'expr' must be
|
|
an integer expression. Both arguments are evaluated exactly once.
|
|
*/
|
|
#define SAL_INT_CAST(type, expr) ((type) (expr))
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
/**
|
|
Use as follows:
|
|
SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);
|
|
*/
|
|
|
|
#if defined __GNUC__ || defined __clang__
|
|
#if defined LIBO_INTERNAL_ONLY
|
|
# define SAL_DEPRECATED(message) __attribute__((deprecated(message)))
|
|
#else
|
|
# define SAL_DEPRECATED(message) __attribute__((deprecated))
|
|
#endif
|
|
#elif defined(_MSC_VER)
|
|
# define SAL_DEPRECATED(message) __declspec(deprecated(message))
|
|
#else
|
|
# define SAL_DEPRECATED(message)
|
|
#endif
|
|
|
|
/**
|
|
This macro is used in cppumaker-generated include files, to tag entities that
|
|
are marked as @deprecated in UNOIDL.
|
|
|
|
It causes deprecation warnings to be generated in external code, but for now
|
|
is silenced in internal code. It would need some substantial clean-up of
|
|
internal code to fix all warnings/errors generated by it. (Once that is
|
|
done, it can become a synonym for SAL_DEPRECATED under LIBO_INTERNAL_ONLY,
|
|
too. Completely removing the macro then would be incompatible, in case there
|
|
are include files still around generated with a cppumaker that emitted it.)
|
|
*/
|
|
#ifdef LIBO_INTERNAL_ONLY
|
|
# define SAL_DEPRECATED_INTERNAL(message)
|
|
#else
|
|
# define SAL_DEPRECATED_INTERNAL(message) SAL_DEPRECATED(message)
|
|
#endif
|
|
|
|
/**
|
|
Use as follows:
|
|
SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
|
\::std::auto_ptr<X> ...
|
|
SAL_WNODEPRECATED_DECLARATIONS_POP
|
|
*/
|
|
|
|
#if defined LIBO_INTERNAL_ONLY && defined __GNUC__
|
|
#define SAL_WNODEPRECATED_DECLARATIONS_PUSH \
|
|
_Pragma(SAL_STRINGIFY_ARG(GCC diagnostic push)) \
|
|
_Pragma(SAL_STRINGIFY_ARG(GCC diagnostic ignored "-Wdeprecated-declarations"))
|
|
#define SAL_WNODEPRECATED_DECLARATIONS_POP \
|
|
_Pragma(SAL_STRINGIFY_ARG(GCC diagnostic pop))
|
|
#else
|
|
# define SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
|
# define SAL_WNODEPRECATED_DECLARATIONS_POP
|
|
#endif
|
|
|
|
/**
|
|
Use as follows:
|
|
|
|
SAL_WNOUNREACHABLE_CODE_PUSH
|
|
|
|
function definition
|
|
|
|
SAL_WNOUNREACHABLE_CODE_POP
|
|
|
|
Useful in cases where the compiler is "too clever" like when doing
|
|
link-time code generation, and noticing that a called function
|
|
always throws, and fixing the problem cleanly so that it produces
|
|
no warnings in normal non-LTO compilations either is not easy.
|
|
|
|
*/
|
|
|
|
#ifdef _MSC_VER
|
|
#define SAL_WNOUNREACHABLE_CODE_PUSH \
|
|
__pragma(warning(push)) \
|
|
__pragma(warning(disable:4702)) \
|
|
__pragma(warning(disable:4722))
|
|
#define SAL_WNOUNREACHABLE_CODE_POP \
|
|
__pragma(warning(pop))
|
|
#else
|
|
/* Add definitions for GCC and Clang if needed */
|
|
#define SAL_WNOUNREACHABLE_CODE_PUSH
|
|
#define SAL_WNOUNREACHABLE_CODE_POP
|
|
#endif
|
|
|
|
/** Annotate unused but required C++ function parameters.
|
|
|
|
An unused parameter is required if the function needs to adhere to a given
|
|
type (e.g., if its address is assigned to a function pointer of a specific
|
|
type, or if it is called from template code). This annotation helps static
|
|
analysis tools suppress false warnings. In the case of virtual functions
|
|
(where unused required parameters are common, too), the annotation is not
|
|
required (as static analysis tools can themselves derive the information
|
|
whether a function is virtual).
|
|
|
|
Use the annotation in function definitions like
|
|
|
|
void f(SAL_UNUSED_PARAMETER int) {}
|
|
|
|
C does not allow unnamed parameters, anyway, so a function definition like
|
|
the above needs to be written there as
|
|
|
|
void f(int dummy) { (void) dummy; / * avoid warnings * / }
|
|
|
|
without a SAL_UNUSED_PARAMETER annotation.
|
|
|
|
@since LibreOffice 3.6
|
|
*/
|
|
#if defined __cplusplus
|
|
#if defined __GNUC__ || defined __clang__
|
|
#define SAL_UNUSED_PARAMETER __attribute__ ((unused))
|
|
#else
|
|
#define SAL_UNUSED_PARAMETER
|
|
#endif
|
|
#endif
|
|
|
|
/**
|
|
|
|
Annotate classes where a compiler should warn if an instance is unused.
|
|
|
|
The compiler cannot warn about unused instances if they have non-trivial
|
|
or external constructors or destructors. Classes marked with SAL_WARN_UNUSED
|
|
will be warned about.
|
|
|
|
@since LibreOffice 4.0
|
|
|
|
*/
|
|
|
|
#if defined LIBO_INTERNAL_ONLY && (defined __GNUC__ || defined __clang__)
|
|
#define SAL_WARN_UNUSED __attribute__((warn_unused))
|
|
#else
|
|
#define SAL_WARN_UNUSED
|
|
#endif
|
|
|
|
/// @cond INTERNAL
|
|
|
|
#if defined __GNUC__ || defined __clang__
|
|
// Macro to try to catch and warn on assignments inside expr.
|
|
# define SAL_DETAIL_BOOLEAN_EXPR(expr) \
|
|
__extension__ ({ \
|
|
int sal_boolean_var_; \
|
|
if (expr) \
|
|
sal_boolean_var_ = 1; \
|
|
else \
|
|
sal_boolean_var_ = 0; \
|
|
sal_boolean_var_; \
|
|
})
|
|
|
|
/** An optimization annotation: denotes that expression is likely to be true.
|
|
|
|
Use it to annotate paths that we think are likely eg.
|
|
if (SAL_LIKELY(ptr != nullptr))
|
|
// this path is the one that is ~always taken.
|
|
|
|
@since LibreOffice 5.2
|
|
|
|
Returns: the boolean value of expr (expressed as either int 1 or 0)
|
|
*/
|
|
# define SAL_LIKELY(expr) __builtin_expect(SAL_DETAIL_BOOLEAN_EXPR((expr)), 1)
|
|
|
|
/** An optimization annotation: denotes that expression is unlikely to be true.
|
|
|
|
Use it to annotate paths that we think are likely eg.
|
|
if (SAL_UNLIKELY(ptr != nullptr))
|
|
// this path is the one that is ~never taken.
|
|
|
|
@since LibreOffice 5.2
|
|
|
|
Returns: the boolean value of expr (expressed as either int 1 or 0)
|
|
*/
|
|
# define SAL_UNLIKELY(expr) __builtin_expect(SAL_DETAIL_BOOLEAN_EXPR((expr)), 0)
|
|
|
|
/** An optimization annotation: tells the compiler to work harder at this code
|
|
|
|
If the SAL_HOT annotation is present on a function or a label then
|
|
subsequent code statements may have more aggressive compiler
|
|
optimization and in-lining work performed on them.
|
|
|
|
In addition this code can end up in a special section, to be
|
|
grouped with other frequently used code.
|
|
|
|
@since LibreOffice 5.2
|
|
*/
|
|
# define SAL_HOT __attribute__((hot))
|
|
|
|
/** An optimization annotation: tells the compiler to work less on this code
|
|
|
|
If the SAL_COLD annotation is present on a function or a label then
|
|
subsequent code statements are unlikely to be performed except in
|
|
exceptional circumstances, and optimizing for code-size rather
|
|
than performance is preferable.
|
|
|
|
In addition this code can end up in a special section, to be grouped
|
|
with (and away from) other more frequently used code, to improve
|
|
locality of reference.
|
|
|
|
@since LibreOffice 5.2
|
|
*/
|
|
# define SAL_COLD __attribute__((cold))
|
|
#else
|
|
# define SAL_LIKELY(expr) (expr)
|
|
# define SAL_UNLIKELY(expr) (expr)
|
|
# define SAL_HOT
|
|
# define SAL_COLD
|
|
#endif
|
|
|
|
/// @endcond
|
|
|
|
/// @cond INTERNAL
|
|
/** Annotate pointer-returning functions to indicate that such a pointer
|
|
is never nullptr.
|
|
|
|
Note that MSVC supports this feature via it's SAL _Ret_notnull_
|
|
annotation, but since it's in a completely different place on
|
|
the function declaration, it's a little hard to support both.
|
|
|
|
@since LibreOffice 5.5
|
|
*/
|
|
#ifndef __has_attribute
|
|
#define __has_attribute(x) 0
|
|
#endif
|
|
|
|
#if defined LIBO_INTERNAL_ONLY && ((defined __GNUC__ && !defined __clang__) || (defined __clang__ && __has_attribute(returns_nonnull)))
|
|
#define SAL_RETURNS_NONNULL __attribute__((returns_nonnull))
|
|
#else
|
|
#define SAL_RETURNS_NONNULL
|
|
#endif
|
|
/// @endcond
|
|
|
|
#if defined LIBO_INTERNAL_ONLY
|
|
// An annotation mechanism used by some loplugins. The id argument must be an ordinary string
|
|
// literal. For Clang, this expands to a clang::annotate attribute with an annotation consisting of
|
|
// the concatenation of a "loplugin:" prefix and the given id suffix. For non-Clang, this expands
|
|
// to nothing to avoid e.g. -Wattributes from GCC's -Wall.
|
|
#if defined __clang__
|
|
#define SAL_LOPLUGIN_ANNOTATE(id) [[clang::annotate("loplugin:" id)]]
|
|
#else
|
|
#define SAL_LOPLUGIN_ANNOTATE(id)
|
|
#endif
|
|
#endif
|
|
|
|
#endif // INCLUDED_SAL_TYPES_H
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|