diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-11-19 16:32:49 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-11-22 12:57:32 +0100 |
commit | f853ec317f6af1b8c65cc5bd758371689c75118d (patch) | |
tree | b86d729bf9a9465ee619ead3b5635efa62a1804e /vbahelper | |
parent | f31d36966bceb90e261cbecd42634bde4448d527 (diff) |
Extend loplugin:external to warn about classes
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend
loplugin:external to warn about enums".
Cases where free functions were moved into an unnamed namespace along with a
class, to not break ADL, are in:
filter/source/svg/svgexport.cxx
sc/source/filter/excel/xelink.cxx
sc/source/filter/excel/xilink.cxx
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
All other free functions mentioning moved classes appear to be harmless and not
give rise to (silent, even) ADL breakage. (One remaining TODO in
compilerplugins/clang/external.cxx is that derived classes are not covered by
computeAffectedTypes, even though they could also be affected by ADL-breakage---
but don't seem to be in any acutal case across the code base.)
For friend declarations using elaborate type specifiers, like
class C1 {};
class C2 { friend class C1; };
* If C2 (but not C1) is moved into an unnamed namespace, the friend declaration
must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see
C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither
qualified nor a template-id and the declaration is a function or an
elaborated-type-specifier, the lookup to determine whether the entity has been
previously declared shall not consider any scopes outside the innermost
enclosing namespace.")
* If C1 (but not C2) is moved into an unnamed namespace, the friend declaration
must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882>
"elaborated-type-specifier friend not looked up in unnamed namespace".
Apart from that, to keep changes simple and mostly mechanical (which should help
avoid regressions), out-of-line definitions of class members have been left in
the enclosing (named) namespace. But explicit specializations of class
templates had to be moved into the unnamed namespace to appease
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of
template from unnamed namespace using unqualified-id in enclosing namespace".
Also, accompanying declarations (of e.g. typedefs or static variables) that
could arguably be moved into the unnamed namespace too have been left alone.
And in some cases, mention of affected types in blacklists in other loplugins
needed to be adapted.
And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which
is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is
not moved into an unnamed namespace (because it is declared in
sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about
such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler
doesn’t give this warning for types defined in the main .C file, as those are
unlikely to have multiple definitions."
(<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The
warned-about classes also don't have multiple definitions in the given test, so
disable the warning when including the .cxx.
Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4
Reviewed-on: https://gerrit.libreoffice.org/83239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vbahelper')
-rw-r--r-- | vbahelper/source/msforms/vbacontrol.cxx | 11 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbacontrols.cxx | 3 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbalistcontrolhelper.cxx | 4 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbamultipage.cxx | 4 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbaapplicationbase.cxx | 8 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbacommandbarcontrols.cxx | 6 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbacommandbarhelper.cxx | 4 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbacommandbars.cxx | 3 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbadocumentsbase.cxx | 8 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbashaperange.cxx | 4 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbashapes.cxx | 4 |
11 files changed, 59 insertions, 0 deletions
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx index aa386fdae3e7..1e877c66d063 100644 --- a/vbahelper/source/msforms/vbacontrol.cxx +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -97,6 +97,8 @@ ScVbaControl::getWindowPeer() return xWinPeer; } +namespace { + //ScVbaControlListener class ScVbaControlListener: public cppu::WeakImplHelper< lang::XEventListener > { @@ -108,6 +110,8 @@ public: virtual void SAL_CALL disposing( const lang::EventObject& rEventObject ) override; }; +} + ScVbaControlListener::ScVbaControlListener( ScVbaControl *pTmpControl ): pControl( pTmpControl ) { } @@ -430,6 +434,7 @@ void SAL_CALL ScVbaControl::setTag( const OUString& aTag ) return OORGBToXLRGB( nForeColor ); } +namespace { struct PointerStyles { @@ -437,6 +442,8 @@ struct PointerStyles PointerStyle const loPointStyle; }; +} + // 1 -> 1 map of styles ( some dubious choices in there though ) PointerStyles const styles[] = { /// assuming pointer default is Arrow @@ -759,6 +766,8 @@ void ScVbaControl::setLocked( bool bLocked ) m_xProps->setPropertyValue( "ReadOnly" , uno::makeAny( bLocked ) ); } +namespace { + class ControlProviderImpl : public cppu::WeakImplHelper< XControlProvider > { uno::Reference< uno::XComponentContext > m_xCtx; @@ -767,6 +776,8 @@ public: virtual uno::Reference< msforms::XControl > SAL_CALL createControl( const uno::Reference< drawing::XControlShape >& xControl, const uno::Reference< frame::XModel >& xDocOwner ) override; }; +} + uno::Reference< msforms::XControl > SAL_CALL ControlProviderImpl::createControl( const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< frame::XModel >& xDocOwner ) { diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index 01abc34f67dd..c3cf49b86f0d 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -42,6 +42,8 @@ using namespace ooo::vba; typedef std::unordered_map< OUString, sal_Int32 > ControlIndexMap; +namespace { + class ControlArrayWrapper : public ::cppu::WeakImplHelper< container::XNameAccess, container::XIndexAccess > { uno::Reference< awt::XControlContainer > mxDialog; @@ -190,6 +192,7 @@ public: }; +} static uno::Reference<container::XIndexAccess > lcl_controlsWrapper( const uno::Reference< awt::XControl >& xDlg ) diff --git a/vbahelper/source/msforms/vbalistcontrolhelper.cxx b/vbahelper/source/msforms/vbalistcontrolhelper.cxx index dfbbb19a3bde..b1601f99ec43 100644 --- a/vbahelper/source/msforms/vbalistcontrolhelper.cxx +++ b/vbahelper/source/msforms/vbalistcontrolhelper.cxx @@ -26,6 +26,8 @@ using namespace com::sun::star; using namespace ooo::vba; +namespace { + class ListPropListener : public PropListener { private: @@ -40,6 +42,8 @@ public: virtual css::uno::Any getValueEvent() override; }; +} + ListPropListener::ListPropListener( const uno::Reference< beans::XPropertySet >& xProps, const uno::Any& pvargIndex, const uno::Any& pvarColumn ) : m_xProps( xProps ), m_pvargIndex( pvargIndex ), m_pvarColumn( pvarColumn ) { } diff --git a/vbahelper/source/msforms/vbamultipage.cxx b/vbahelper/source/msforms/vbamultipage.cxx index 18c74ffdff30..58ca2182cda6 100644 --- a/vbahelper/source/msforms/vbamultipage.cxx +++ b/vbahelper/source/msforms/vbamultipage.cxx @@ -27,6 +27,8 @@ using namespace ooo::vba; const OUString SVALUE( "MultiPageValue" ); +namespace { + class PagesImpl : public cppu::WeakImplHelper< container::XIndexAccess > { sal_Int32 const mnPages; @@ -52,6 +54,8 @@ public: } }; +} + ScVbaMultiPage::ScVbaMultiPage( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 94c3419f6e2a..bf7ac741563c 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -60,6 +60,8 @@ using namespace ::ooo::vba; typedef ::std::pair< OUString, ::std::pair< double, double > > VbaTimerInfo; +namespace { + class VbaTimer { Timer m_aTimer; @@ -115,6 +117,8 @@ public: DECL_LINK( MacroCallHdl, Timer*, void ); }; +} + IMPL_LINK_NOARG(VbaTimer, MacroCallHdl, Timer *, void) { if ( m_aTimerInfo.second.second == 0 || GetNow() < m_aTimerInfo.second.second ) @@ -136,6 +140,8 @@ IMPL_LINK_NOARG(VbaTimer, MacroCallHdl, Timer *, void) {} } +namespace { + struct VbaTimerInfoHash { size_t operator()( const VbaTimerInfo& rTimerInfo ) const @@ -148,6 +154,8 @@ struct VbaTimerInfoHash } }; +} + typedef std::unordered_map< VbaTimerInfo, std::unique_ptr<VbaTimer>, VbaTimerInfoHash > VbaTimerHashMap; struct VbaApplicationBase_Impl final diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx index f789a487f6b2..cb83e51c8204 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx @@ -23,6 +23,8 @@ using namespace com::sun::star; using namespace ooo::vba; +namespace { + class CommandBarControlEnumeration : public ::cppu::WeakImplHelper< container::XEnumeration > { //uno::Reference< uno::XComponentContext > m_xContext; @@ -45,6 +47,8 @@ public: } }; +} + ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef const & pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const OUString& sResourceUrl ) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl ) { m_bIsMenu = sResourceUrl == ITEM_MENUBAR_URL; @@ -243,6 +247,7 @@ ScVbaCommandBarControls::getServiceNames() return aServiceNames; } +namespace { class VbaDummyIndexAccess : public ::cppu::WeakImplHelper< container::XIndexAccess > { @@ -260,6 +265,7 @@ public: { return false; } }; +} VbaDummyCommandBarControls::VbaDummyCommandBarControls( const uno::Reference< XHelperInterface >& xParent, diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx index aa18d1b0dc49..f2926139aea9 100644 --- a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx @@ -41,6 +41,8 @@ using namespace ooo::vba; typedef std::map< OUString, OUString > MSO2OOCommandbarMap; +namespace { + class MSO2OOCommandbarHelper final { private: @@ -83,6 +85,8 @@ public: } }; +} + MSO2OOCommandbarHelper* MSO2OOCommandbarHelper::pMSO2OOCommandbarHelper = nullptr; diff --git a/vbahelper/source/vbahelper/vbacommandbars.cxx b/vbahelper/source/vbahelper/vbacommandbars.cxx index be173f49b2a7..332249049b84 100644 --- a/vbahelper/source/vbahelper/vbacommandbars.cxx +++ b/vbahelper/source/vbahelper/vbacommandbars.cxx @@ -31,6 +31,7 @@ using namespace com::sun::star; using namespace ooo::vba; +namespace { class CommandBarEnumeration : public ::cppu::WeakImplHelper< container::XEnumeration > { @@ -71,6 +72,8 @@ public: } }; +} + ScVbaCommandBars::ScVbaCommandBars( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< frame::XModel >& xModel ) : CommandBars_BASE( xParent, xContext, xIndexAccess ) { m_pCBarHelper.reset( new VbaCommandBarHelper( mxContext, xModel ) ); diff --git a/vbahelper/source/vbahelper/vbadocumentsbase.cxx b/vbahelper/source/vbahelper/vbadocumentsbase.cxx index 1ba2bb1a0b0f..d0951b0c13e7 100644 --- a/vbahelper/source/vbahelper/vbadocumentsbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentsbase.cxx @@ -56,6 +56,8 @@ typedef std::vector < uno::Reference< frame::XModel > > Documents; // #FIXME clearly this is a candidate for some sort of helper base class as // this is a copy of SelectedSheetsEnum ( vbawindow.cxx ) +namespace { + class DocumentsEnumImpl : public ::cppu::WeakImplHelper< container::XEnumeration > { uno::Reference< uno::XComponentContext > m_xContext; @@ -97,6 +99,8 @@ public: } }; +} + // #FIXME clearly this is also a candidate for some sort of helper base class as // a very similar one is used in vbawindow ( SelectedSheetsEnumAccess ) // Maybe a template base class that does all of the operations on the hashmap @@ -108,6 +112,8 @@ typedef ::cppu::WeakImplHelper< container::XEnumerationAccess , css::container::XNameAccess > DocumentsAccessImpl_BASE; +namespace { + class DocumentsAccessImpl : public DocumentsAccessImpl_BASE { uno::Reference< uno::XComponentContext > m_xContext; @@ -187,6 +193,8 @@ public: }; +} + VbaDocumentsBase::VbaDocumentsBase( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext >& xContext, DOCUMENT_TYPE eDocType ) : VbaDocumentsBase_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new DocumentsAccessImpl( xContext, eDocType ) ) ), meDocType( eDocType ) { } diff --git a/vbahelper/source/vbahelper/vbashaperange.cxx b/vbahelper/source/vbahelper/vbashaperange.cxx index b21c24165cf7..6f353e5e14d1 100644 --- a/vbahelper/source/vbahelper/vbashaperange.cxx +++ b/vbahelper/source/vbahelper/vbashaperange.cxx @@ -29,6 +29,8 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; +namespace { + class VbShapeRangeEnumHelper : public EnumerationHelper_BASE { uno::Reference< XCollection > m_xParent; @@ -50,6 +52,8 @@ public: }; +} + ScVbaShapeRange::ScVbaShapeRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xShapes, const uno::Reference< drawing::XDrawPage >& xDrawPage, const uno::Reference< frame::XModel >& xModel ) : ScVbaShapeRange_BASE( xParent, xContext, xShapes ), m_xDrawPage( xDrawPage ), m_xModel( xModel ) { } diff --git a/vbahelper/source/vbahelper/vbashapes.cxx b/vbahelper/source/vbahelper/vbashapes.cxx index 7c9ca3f22cd9..f9356efedd9d 100644 --- a/vbahelper/source/vbahelper/vbashapes.cxx +++ b/vbahelper/source/vbahelper/vbashapes.cxx @@ -51,6 +51,8 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; +namespace { + class VbShapeEnumHelper : public EnumerationHelper_BASE { uno::Reference<msforms::XShapes > m_xParent; @@ -72,6 +74,8 @@ public: }; +} + void ScVbaShapes::initBaseCollection() { if ( m_xNameAccess.is() ) // already has NameAccess |