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 /toolkit | |
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 'toolkit')
-rw-r--r-- | toolkit/source/awt/animatedimagespeer.cxx | 4 | ||||
-rw-r--r-- | toolkit/source/awt/stylesettings.cxx | 3 | ||||
-rw-r--r-- | toolkit/source/controls/controlmodelcontainerbase.cxx | 3 | ||||
-rw-r--r-- | toolkit/source/controls/dialogcontrol.cxx | 4 | ||||
-rw-r--r-- | toolkit/source/controls/geometrycontrolmodel.cxx | 4 | ||||
-rw-r--r-- | toolkit/source/controls/stdtabcontroller.cxx | 4 | ||||
-rw-r--r-- | toolkit/source/controls/unocontrol.cxx | 7 | ||||
-rw-r--r-- | toolkit/source/controls/unocontrolcontainer.cxx | 8 | ||||
-rw-r--r-- | toolkit/source/controls/unocontrols.cxx | 8 | ||||
-rw-r--r-- | toolkit/source/helper/accessibilityclient.cxx | 3 | ||||
-rw-r--r-- | toolkit/source/helper/property.cxx | 7 |
11 files changed, 51 insertions, 4 deletions
diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx index fccfc8b0571f..e056ef04d55c 100644 --- a/toolkit/source/awt/animatedimagespeer.cxx +++ b/toolkit/source/awt/animatedimagespeer.cxx @@ -67,6 +67,8 @@ namespace toolkit //= AnimatedImagesPeer_Data + namespace { + struct CachedImage { OUString sImageURL; @@ -85,6 +87,8 @@ namespace toolkit } }; + } + struct AnimatedImagesPeer_Data { AnimatedImagesPeer& rAntiImpl; diff --git a/toolkit/source/awt/stylesettings.cxx b/toolkit/source/awt/stylesettings.cxx index 55abed46bf87..d2b250894a67 100644 --- a/toolkit/source/awt/stylesettings.cxx +++ b/toolkit/source/awt/stylesettings.cxx @@ -79,6 +79,8 @@ namespace toolkit //= StyleMethodGuard + namespace { + class StyleMethodGuard { public: @@ -92,6 +94,7 @@ namespace toolkit SolarMutexGuard const m_aGuard; }; + } //= WindowStyleSettings diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx index 140d9c103db6..b8328104e518 100644 --- a/toolkit/source/controls/controlmodelcontainerbase.cxx +++ b/toolkit/source/controls/controlmodelcontainerbase.cxx @@ -75,8 +75,6 @@ namespace static Sequence<OUString> s_aLanguageDependentProperties{ "HelpText", "Title" }; return s_aLanguageDependentProperties; } -} - // functor for disposing a control model struct DisposeControlModel @@ -94,6 +92,7 @@ struct DisposeControlModel } }; +} // functor for searching control model by name struct FindControlModel diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx index d260dce6ad7c..b1e944ddf697 100644 --- a/toolkit/source/controls/dialogcontrol.cxx +++ b/toolkit/source/controls/dialogcontrol.cxx @@ -62,6 +62,8 @@ using namespace ::com::sun::star::util; // we probably will need both a hash of control models and hash of controls // => use some template magic +namespace { + template< typename T > class SimpleNamedThingContainer : public ::cppu::WeakImplHelper< container::XNameContainer > { @@ -123,8 +125,6 @@ public: } }; -namespace { - class UnoControlDialogModel : public ControlModelContainerBase { protected: diff --git a/toolkit/source/controls/geometrycontrolmodel.cxx b/toolkit/source/controls/geometrycontrolmodel.cxx index a40856f16179..8bcc53aaccd0 100644 --- a/toolkit/source/controls/geometrycontrolmodel.cxx +++ b/toolkit/source/controls/geometrycontrolmodel.cxx @@ -487,6 +487,7 @@ m_nPropertyMapId = aPropMapIdPos->second; } + namespace { struct PropertyNameLess { @@ -508,6 +509,7 @@ } }; + } ::cppu::IPropertyArrayHelper* OCommonGeometryControlModel::createArrayHelper( sal_Int32 _nId ) const { @@ -569,6 +571,7 @@ return css::uno::Sequence<sal_Int8>(); } + namespace { struct Int32Equal { @@ -581,6 +584,7 @@ } }; + } void SAL_CALL OCommonGeometryControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) { diff --git a/toolkit/source/controls/stdtabcontroller.cxx b/toolkit/source/controls/stdtabcontroller.cxx index b989f3f5a8e5..358eb60a5082 100644 --- a/toolkit/source/controls/stdtabcontroller.cxx +++ b/toolkit/source/controls/stdtabcontroller.cxx @@ -226,12 +226,16 @@ Sequence< Reference< XControl > > StdTabController::getControls( ) return aSeq; } +namespace { + struct ComponentEntry { css::awt::XWindow* pComponent; ::Point aPos; }; +} + void StdTabController::autoTabOrder( ) { ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx index 9aa4a5e22277..c58faaed4b96 100644 --- a/toolkit/source/controls/unocontrol.cxx +++ b/toolkit/source/controls/unocontrol.cxx @@ -53,12 +53,16 @@ using namespace ::com::sun::star::util; using ::com::sun::star::accessibility::XAccessibleContext; using ::com::sun::star::accessibility::XAccessible; +namespace { + struct LanguageDependentProp { const char* pPropName; sal_Int32 const nPropNameLength; }; +} + static const LanguageDependentProp aLanguageDependentProp[] = { { "Text", 4 }, @@ -86,6 +90,7 @@ static Sequence< OUString> lcl_ImplGetPropertyNames( const Reference< XMultiProp return aNames; } +namespace { class VclListenerLock { @@ -108,6 +113,8 @@ public: VclListenerLock& operator=(const VclListenerLock&) = delete; }; +} + typedef ::std::map< OUString, sal_Int32 > MapString2Int; struct UnoControl_Data { diff --git a/toolkit/source/controls/unocontrolcontainer.cxx b/toolkit/source/controls/unocontrolcontainer.cxx index d7f2aefaba85..11d8160dc505 100644 --- a/toolkit/source/controls/unocontrolcontainer.cxx +++ b/toolkit/source/controls/unocontrolcontainer.cxx @@ -40,6 +40,8 @@ using namespace ::com::sun::star; // class UnoControlHolder +namespace { + struct UnoControlHolder { uno::Reference< awt::XControl > mxControl; @@ -56,6 +58,8 @@ public: const uno::Reference< awt::XControl >& getControl() const { return mxControl; } }; +} + class UnoControlHolderList { public: @@ -324,6 +328,8 @@ static void implUpdateVisibility typedef ::cppu::WeakImplHelper< beans::XPropertyChangeListener > PropertyChangeListenerHelper; +namespace { + class DialogStepChangedListener: public PropertyChangeListenerHelper { private: @@ -341,6 +347,8 @@ public: }; +} + void SAL_CALL DialogStepChangedListener::disposing( const lang::EventObject& /*_rSource*/) { mxControlContainer.clear(); diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index cbb04926bd95..d6d4d77f4514 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -1994,6 +1994,8 @@ stardiv_Toolkit_UnoGroupBoxControl_get_implementation( // = UnoControlListBoxModel_Data +namespace { + struct ListItem { OUString ItemText; @@ -2015,8 +2017,12 @@ struct ListItem } }; +} + typedef beans::Pair< OUString, OUString > UnoListItem; +namespace { + struct StripItemData { UnoListItem operator()( const ListItem& i_rItem ) @@ -2025,6 +2031,8 @@ struct StripItemData } }; +} + struct UnoControlListBoxModel_Data { explicit UnoControlListBoxModel_Data( UnoControlListBoxModel& i_rAntiImpl ) diff --git a/toolkit/source/helper/accessibilityclient.cxx b/toolkit/source/helper/accessibilityclient.cxx index abbd9a79066c..682354607111 100644 --- a/toolkit/source/helper/accessibilityclient.cxx +++ b/toolkit/source/helper/accessibilityclient.cxx @@ -49,6 +49,8 @@ namespace toolkit //= AccessibleDummyFactory + namespace { + class AccessibleDummyFactory: public IAccessibleFactory { @@ -129,6 +131,7 @@ namespace toolkit } }; + } AccessibleDummyFactory::AccessibleDummyFactory() { diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index b09b0a7e8fff..c3b67df41ac4 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -45,6 +45,8 @@ using ::com::sun::star::graphic::XGraphic; using namespace com::sun::star; +namespace { + struct ImplPropertyInfo { OUString aName; @@ -65,6 +67,8 @@ struct ImplPropertyInfo }; +} + #define DECL_PROP_1( asciiname, id, type, attrib1 ) \ ImplPropertyInfo( asciiname, BASEPROPERTY_##id, cppu::UnoType<type>::get(), css::beans::PropertyAttribute::attrib1 ) #define DECL_PROP_2( asciiname, id, type, attrib1, attrib2 ) \ @@ -268,6 +272,7 @@ static ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) return aImplPropertyInfos; } +namespace { struct ImplPropertyInfoCompareFunctor { @@ -281,6 +286,8 @@ struct ImplPropertyInfoCompareFunctor } }; +} + static void ImplAssertValidPropertyArray() { static bool bSorted = false; |