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 /extensions | |
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 'extensions')
23 files changed, 100 insertions, 10 deletions
diff --git a/extensions/source/bibliography/bibload.cxx b/extensions/source/bibliography/bibload.cxx index dc861bbeb3e3..6edbddd3c744 100644 --- a/extensions/source/bibliography/bibload.cxx +++ b/extensions/source/bibliography/bibload.cxx @@ -75,6 +75,8 @@ using namespace ::com::sun::star::frame; static Reference< XInterface > BibliographyLoader_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ); +namespace { + class BibliographyLoader : public cppu::WeakImplHelper < XServiceInfo, XNameAccess, XPropertySet, XFrameLoader > { @@ -130,7 +132,7 @@ public: static Sequence<OUString> getSupportedServiceNames_Static() throw( ); /// @throws Exception - friend Reference< XInterface > BibliographyLoader_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ); + friend Reference< XInterface > (::BibliographyLoader_CreateInstance)( const Reference< XMultiServiceFactory > & rSMgr ); // XLoader virtual void SAL_CALL load(const Reference< XFrame > & aFrame, const OUString& aURL, @@ -139,6 +141,8 @@ public: virtual void SAL_CALL cancel() override; }; +} + BibliographyLoader::BibliographyLoader() : m_pBibMod(nullptr) { diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx index 8364deb9e657..c9ccfc133919 100644 --- a/extensions/source/bibliography/datman.cxx +++ b/extensions/source/bibliography/datman.cxx @@ -179,6 +179,8 @@ static Reference< XNameAccess > getColumns(const Reference< XForm > & _rxForm) return xReturn; } +namespace { + class MappingDialog_Impl : public weld::GenericDialogController { BibDataManager* pDatMan; @@ -227,6 +229,8 @@ public: MappingDialog_Impl(weld::Window* pParent, BibDataManager* pDatMan); }; +} + static sal_uInt16 lcl_FindLogicalName(BibConfig const * pConfig , const OUString& rLogicalColumnName) { @@ -397,6 +401,8 @@ IMPL_LINK_NOARG(MappingDialog_Impl, OkHdl, weld::Button&, void) m_xDialog->response(bModified ? RET_OK : RET_CANCEL); } +namespace { + class DBChangeDialog_Impl : public weld::GenericDialogController { DBChangeDialogConfig_Impl aConfig; @@ -411,6 +417,8 @@ public: OUString GetCurrentURL()const; }; +} + DBChangeDialog_Impl::DBChangeDialog_Impl(weld::Window* pParent, BibDataManager* pMan ) : GenericDialogController(pParent, "modules/sbibliography/ui/choosedatasourcedialog.ui", "ChooseDataSourceDialog") , pDatMan(pMan) diff --git a/extensions/source/bibliography/formcontrolcontainer.cxx b/extensions/source/bibliography/formcontrolcontainer.cxx index fcb4851d91bc..4a9c23d0c97d 100644 --- a/extensions/source/bibliography/formcontrolcontainer.cxx +++ b/extensions/source/bibliography/formcontrolcontainer.cxx @@ -71,6 +71,8 @@ namespace bib m_xForm = _rxForm; } + namespace { + struct ControlModeSwitch { bool bDesign; @@ -83,6 +85,8 @@ namespace bib } }; + } + void FormControlContainer::implSetDesignMode( bool _bDesign ) { try diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx index a36efe9b550a..80d2ae7b8f52 100644 --- a/extensions/source/bibliography/framectr.cxx +++ b/extensions/source/bibliography/framectr.cxx @@ -60,6 +60,7 @@ using namespace com::sun::star::frame; using namespace com::sun::star::uno; using namespace com::sun::star; +namespace { struct DispatchInfo { @@ -74,6 +75,8 @@ struct CacheDispatchInfo bool bActiveConnection; }; +} + // Attention: commands must be sorted by command groups. Implementation is dependent // on this!! static const DispatchInfo SupportedCommandsArray[] = diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx index 11163a1227be..450bcc9ef882 100644 --- a/extensions/source/bibliography/general.cxx +++ b/extensions/source/bibliography/general.cxx @@ -70,6 +70,8 @@ static OUString lcl_GetColumnName( const Mapping* pMapping, sal_uInt16 nIndexPos return sRet; } +namespace { + class BibPosListener :public cppu::WeakImplHelper <sdbc::XRowSetListener> { VclPtr<BibGeneralPage> pParentPage; @@ -86,6 +88,8 @@ public: }; +} + BibPosListener::BibPosListener(BibGeneralPage* pParent) : pParentPage(pParent) { diff --git a/extensions/source/logging/consolehandler.cxx b/extensions/source/logging/consolehandler.cxx index a241126cc7d6..d1455baa3178 100644 --- a/extensions/source/logging/consolehandler.cxx +++ b/extensions/source/logging/consolehandler.cxx @@ -50,6 +50,9 @@ namespace logging typedef ::cppu::WeakComponentImplHelper < XConsoleHandler , XServiceInfo > ConsoleHandler_Base; + + namespace { + class ConsoleHandler :public ::cppu::BaseMutex ,public ConsoleHandler_Base { @@ -91,6 +94,8 @@ namespace logging void leaveMethod( MethodGuard::Access ); }; + } + ConsoleHandler::ConsoleHandler(const Reference<XComponentContext> &context, const css::uno::Sequence<css::uno::Any> &arguments) :ConsoleHandler_Base( m_aMutex ) diff --git a/extensions/source/logging/csvformatter.cxx b/extensions/source/logging/csvformatter.cxx index bce6922dcb62..42c51a348701 100644 --- a/extensions/source/logging/csvformatter.cxx +++ b/extensions/source/logging/csvformatter.cxx @@ -39,6 +39,8 @@ namespace logging using ::com::sun::star::uno::Sequence; using ::com::sun::star::logging::LogRecord; + namespace { + // formats for csv files as defined by RFC4180 class CsvFormatter : public cppu::WeakImplHelper<css::logging::XCsvLogFormatter, css::lang::XServiceInfo> { @@ -79,6 +81,8 @@ namespace logging bool m_MultiColumn; css::uno::Sequence< OUString > m_Columnnames; }; + + } } // namespace logging // private helpers diff --git a/extensions/source/logging/filehandler.cxx b/extensions/source/logging/filehandler.cxx index bec33521418c..cd62535ad15c 100644 --- a/extensions/source/logging/filehandler.cxx +++ b/extensions/source/logging/filehandler.cxx @@ -60,6 +60,9 @@ namespace logging typedef ::cppu::WeakComponentImplHelper < XLogHandler , XServiceInfo > FileHandler_Base; + + namespace { + class FileHandler :public ::cppu::BaseMutex ,public FileHandler_Base { @@ -122,6 +125,8 @@ namespace logging void impl_doStringsubstitution_nothrow( OUString& _inout_rURL ); }; + } + FileHandler::FileHandler(const css::uno::Reference<XComponentContext> &context, const css::uno::Sequence<css::uno::Any> &arguments) :FileHandler_Base( m_aMutex ) diff --git a/extensions/source/logging/logger.cxx b/extensions/source/logging/logger.cxx index 43dbe1a3a2a2..1770ca377175 100644 --- a/extensions/source/logging/logger.cxx +++ b/extensions/source/logging/logger.cxx @@ -49,6 +49,8 @@ namespace logging using ::com::sun::star::logging::XLogHandler; using ::com::sun::star::logging::LogRecord; + namespace { + class EventLogger : public cppu::BaseMutex, public cppu::WeakImplHelper<css::logging::XLogger> { @@ -110,6 +112,8 @@ namespace logging virtual Reference< XLogger > SAL_CALL getDefaultLogger( ) override; }; + } + EventLogger::EventLogger( const Reference< XComponentContext >& _rxContext, const OUString& _rName ) :m_aHandlers( m_aMutex ) ,m_nEventNumber( 0 ) diff --git a/extensions/source/logging/plaintextformatter.cxx b/extensions/source/logging/plaintextformatter.cxx index 58884a36512c..23392b61c491 100644 --- a/extensions/source/logging/plaintextformatter.cxx +++ b/extensions/source/logging/plaintextformatter.cxx @@ -38,6 +38,8 @@ namespace logging using ::com::sun::star::logging::LogRecord; using ::com::sun::star::uno::XInterface; + namespace { + class PlainTextFormatter : public cppu::WeakImplHelper<css::logging::XLogFormatter, css::lang::XServiceInfo> { public: @@ -55,6 +57,8 @@ namespace logging virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; + } + PlainTextFormatter::PlainTextFormatter() { } diff --git a/extensions/source/logging/simpletextformatter.cxx b/extensions/source/logging/simpletextformatter.cxx index 003c978233b1..542f696e5d34 100644 --- a/extensions/source/logging/simpletextformatter.cxx +++ b/extensions/source/logging/simpletextformatter.cxx @@ -37,6 +37,8 @@ namespace logging using css::logging::LogRecord; using namespace css::uno; +namespace +{ class SimpleTextFormatter : public cppu::WeakImplHelper<css::logging::XLogFormatter, css::lang::XServiceInfo> { @@ -54,6 +56,7 @@ private: virtual sal_Bool SAL_CALL supportsService(const OUString& _rServiceName) override; virtual Sequence<OUString> SAL_CALL getSupportedServiceNames() override; }; +} SimpleTextFormatter::SimpleTextFormatter() {} diff --git a/extensions/source/propctrlr/browserlistbox.cxx b/extensions/source/propctrlr/browserlistbox.cxx index 1e77361f9400..b98f3c1e25c0 100644 --- a/extensions/source/propctrlr/browserlistbox.cxx +++ b/extensions/source/propctrlr/browserlistbox.cxx @@ -68,8 +68,6 @@ namespace pcr ACTIVATE_NEXT }; - } - struct ControlEvent : public ::comphelper::AnyEvent { Reference< XPropertyControl > xControl; @@ -95,6 +93,7 @@ namespace pcr getNotifier(); }; + } ::rtl::Reference< ::comphelper::AsyncEventNotifier > SharedNotifier::s_pNotifier; diff --git a/extensions/source/propctrlr/composeduiupdate.cxx b/extensions/source/propctrlr/composeduiupdate.cxx index 679a894795ee..4d59e51f9544 100644 --- a/extensions/source/propctrlr/composeduiupdate.cxx +++ b/extensions/source/propctrlr/composeduiupdate.cxx @@ -66,6 +66,9 @@ namespace pcr typedef ::cppu::WeakImplHelper < css::inspection::XObjectInspectorUI > CachedInspectorUI_Base; + + namespace { + struct CachedInspectorUI : public CachedInspectorUI_Base { private: @@ -167,6 +170,7 @@ namespace pcr }; }; + } CachedInspectorUI::CachedInspectorUI( ComposedPropertyUIUpdate& _rMaster, FNotifySingleUIChange _pUIChangeNotification ) :m_bDisposed( false ) diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx index e368bdf5f100..646e4feec6f0 100644 --- a/extensions/source/propctrlr/eventhandler.cxx +++ b/extensions/source/propctrlr/eventhandler.cxx @@ -296,6 +296,9 @@ namespace pcr typedef ::cppu::WeakImplHelper < css::container::XNameReplace > EventHolder_Base; + + namespace { + /* A UNO component holding assigned event descriptions, for use with a SvxMacroAssignDlg */ class EventHolder : public EventHolder_Base { @@ -331,6 +334,7 @@ namespace pcr ScriptEventDescriptor const & impl_getDescriptor_throw( const OUString& _rEventName ) const; }; + } EventHolder::EventHolder() { diff --git a/extensions/source/propctrlr/fontdialog.cxx b/extensions/source/propctrlr/fontdialog.cxx index d065e7b63429..43ad19ce294a 100644 --- a/extensions/source/propctrlr/fontdialog.cxx +++ b/extensions/source/propctrlr/fontdialog.cxx @@ -69,6 +69,8 @@ namespace pcr //= OFontPropertyExtractor + namespace { + class OFontPropertyExtractor { protected: @@ -95,6 +97,7 @@ namespace pcr bool _bForceInvalidation = false); }; + } OFontPropertyExtractor::OFontPropertyExtractor(const Reference< XPropertySet >& _rxProps) :m_xPropValueAccess(_rxProps) diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index 7feca01b5a55..833359fdb583 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -173,6 +173,7 @@ namespace pcr return aSupported; } + namespace { // TODO: -> export from toolkit struct LanguageDependentProp @@ -181,6 +182,8 @@ namespace pcr sal_Int32 nPropNameLength; }; + } + static const LanguageDependentProp aLanguageDependentProp[] = { { "Text", 4 }, diff --git a/extensions/source/propctrlr/formgeometryhandler.cxx b/extensions/source/propctrlr/formgeometryhandler.cxx index 8ea36b02a7bb..f6a2d7a15d31 100644 --- a/extensions/source/propctrlr/formgeometryhandler.cxx +++ b/extensions/source/propctrlr/formgeometryhandler.cxx @@ -96,6 +96,8 @@ namespace pcr //= BroadcastHelperBase + namespace { + class BroadcastHelperBase { protected: @@ -111,6 +113,7 @@ namespace pcr ::cppu::OBroadcastHelper maBHelper; }; + } //= ShapeGeometryChangeNotifier - declaration @@ -121,6 +124,8 @@ namespace pcr typedef ::cppu::WeakImplHelper < css::beans::XPropertyChangeListener > ShapeGeometryChangeNotifier_IBase; + namespace { + class ShapeGeometryChangeNotifier :public BroadcastHelperBase ,public ShapeGeometryChangeNotifier_CBase ,public ShapeGeometryChangeNotifier_IBase @@ -195,13 +200,22 @@ namespace pcr Reference< XShape > m_xShape; }; + } //= FormGeometryHandler - declaration + namespace { + class FormGeometryHandler; + + } + typedef HandlerComponentBase< FormGeometryHandler > FormGeometryHandler_Base; /** a property handler for any virtual string properties */ + + namespace { + class FormGeometryHandler : public FormGeometryHandler_Base { public: @@ -247,6 +261,7 @@ namespace pcr ::rtl::Reference< ShapeGeometryChangeNotifier > m_xChangeNotifier; }; + } //= FormGeometryHandler - implementation diff --git a/extensions/source/propctrlr/formmetadata.cxx b/extensions/source/propctrlr/formmetadata.cxx index 2592c47c57eb..f2e3c0328c84 100644 --- a/extensions/source/propctrlr/formmetadata.cxx +++ b/extensions/source/propctrlr/formmetadata.cxx @@ -66,6 +66,7 @@ namespace pcr { } + namespace { // Compare PropertyInfo struct PropertyInfoLessByName @@ -76,6 +77,7 @@ namespace pcr } }; + } //= OPropertyInfoService diff --git a/extensions/source/propctrlr/genericpropertyhandler.cxx b/extensions/source/propctrlr/genericpropertyhandler.cxx index c393e3921137..d30d80918077 100644 --- a/extensions/source/propctrlr/genericpropertyhandler.cxx +++ b/extensions/source/propctrlr/genericpropertyhandler.cxx @@ -63,6 +63,8 @@ namespace pcr using ::com::sun::star::awt::XActionListener; using ::com::sun::star::awt::ActionEvent; + namespace { + class EnumRepresentation : public IPropertyEnumRepresentation { private: @@ -84,6 +86,8 @@ namespace pcr void impl_getValues( Sequence< sal_Int32 >& _out_rValues ) const; }; + } + EnumRepresentation::EnumRepresentation( const Reference< XComponentContext >& _rxContext, const Type& _rEnumType ) :m_aEnumType( _rEnumType ) { @@ -177,6 +181,9 @@ namespace pcr typedef ::cppu::WeakImplHelper < XActionListener > UrlClickHandler_Base; + + namespace { + class UrlClickHandler : public UrlClickHandler_Base { Reference<XComponentContext> m_xContext; @@ -196,6 +203,7 @@ namespace pcr void impl_dispatch_throw( const OUString& _rURL ); }; + } UrlClickHandler::UrlClickHandler( const Reference<XComponentContext>& _rContext, const Reference< XHyperlinkControl >& _rxControl ) :m_xContext( _rContext ) diff --git a/extensions/source/propctrlr/objectinspectormodel.cxx b/extensions/source/propctrlr/objectinspectormodel.cxx index aa0628555e59..00520029b490 100644 --- a/extensions/source/propctrlr/objectinspectormodel.cxx +++ b/extensions/source/propctrlr/objectinspectormodel.cxx @@ -42,6 +42,8 @@ namespace pcr //= ObjectInspectorModel + namespace { + class ObjectInspectorModel : public ImplInspectorModel { private: @@ -81,6 +83,7 @@ namespace pcr void impl_verifyArgument_throw( bool _bCondition, sal_Int16 _nArgumentPosition ); }; + } //= ObjectInspectorModel diff --git a/extensions/source/propctrlr/stringrepresentation.cxx b/extensions/source/propctrlr/stringrepresentation.cxx index 42d638c2f9e5..c16565028355 100644 --- a/extensions/source/propctrlr/stringrepresentation.cxx +++ b/extensions/source/propctrlr/stringrepresentation.cxx @@ -66,6 +66,8 @@ namespace pcr{ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +namespace { + class StringRepresentation: public ::cppu::WeakImplHelper< lang::XServiceInfo, @@ -141,6 +143,8 @@ private: }; +} + StringRepresentation::StringRepresentation(uno::Reference< uno::XComponentContext > const & context) : m_xContext(context) {} diff --git a/extensions/source/propctrlr/taborder.cxx b/extensions/source/propctrlr/taborder.cxx index 3fc08b9599a5..90d28f8794bc 100644 --- a/extensions/source/propctrlr/taborder.cxx +++ b/extensions/source/propctrlr/taborder.cxx @@ -79,8 +79,6 @@ namespace pcr return sImageId; } - } - //= OSimpleTabModel class OSimpleTabModel : public ::cppu::WeakImplHelper< XTabControllerModel> @@ -104,6 +102,8 @@ namespace pcr virtual void SAL_CALL setGroupControl(sal_Bool /*GroupControl*/) override {}; }; + } + //= TabOrderDialog TabOrderDialog::TabOrderDialog(weld::Window* _pParent, const Reference< XTabControllerModel >& _rxTabModel, const Reference< XControlContainer >& _rxControlCont, const Reference< XComponentContext >& _rxORB) diff --git a/extensions/source/scanner/scanunx.cxx b/extensions/source/scanner/scanunx.cxx index a9ee05e5164e..83df6c32d5d2 100644 --- a/extensions/source/scanner/scanunx.cxx +++ b/extensions/source/scanner/scanunx.cxx @@ -76,6 +76,7 @@ Sequence< sal_Int8 > BitmapTransporter::getDIB() return aValue; } +namespace { struct SaneHolder { @@ -88,9 +89,6 @@ struct SaneHolder SaneHolder() : m_nError(ScanError_ScanErrorNone), m_bBusy(false) {} }; - -namespace -{ typedef std::vector< std::shared_ptr<SaneHolder> > sanevec; class allSanes { @@ -119,8 +117,6 @@ namespace struct theSaneProtector : public rtl::Static<osl::Mutex, theSaneProtector> {}; struct theSanes : public rtl::Static<allSanes, theSanes> {}; -} - class ScannerThread : public osl::Thread { @@ -138,6 +134,7 @@ public: virtual ~ScannerThread() override; }; +} ScannerThread::ScannerThread(const std::shared_ptr<SaneHolder>& pHolder, const Reference< css::lang::XEventListener >& listener, |