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 /dbaccess/source/ui | |
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 'dbaccess/source/ui')
19 files changed, 98 insertions, 1 deletions
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index f79c6d3e030f..df35c9a36111 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -179,6 +179,12 @@ Reference< XInterface > OApplicationController::Create(const Reference<XMultiSer return *(new OApplicationController( comphelper::getComponentContext(_rxFactory))); } +namespace { + +class SelectionGuard; + +} + // OApplicationController class SelectionNotifier { @@ -214,7 +220,7 @@ public: m_aSelectionListeners.disposeAndClear( aEvent ); } - struct SelectionGuardAccess { friend class SelectionGuard; private: SelectionGuardAccess() { } }; + struct SelectionGuardAccess { friend SelectionGuard; private: SelectionGuardAccess() { } }; /** enters a block which modifies the selection of our owner. @@ -243,6 +249,8 @@ public: } }; +namespace { + class SelectionGuard { public: @@ -264,6 +272,8 @@ private: SelectionNotifier& m_rNotifier; }; +} + // OApplicationController OApplicationController::OApplicationController(const Reference< XComponentContext >& _rxORB) :OGenericUnoController( _rxORB ) diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx index 803f00f56e5a..818b423a205b 100644 --- a/dbaccess/source/ui/browser/brwctrlr.cxx +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -133,6 +133,8 @@ using namespace ::svt; namespace dbaui { +namespace { + // OParameterContinuation class OParameterContinuation : public OInteraction< XInteractionSupplyParameters > { @@ -147,6 +149,8 @@ public: virtual void SAL_CALL setParameters( const Sequence< PropertyValue >& _rValues ) override; }; +} + void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyValue >& _rValues ) { m_aValues = _rValues; diff --git a/dbaccess/source/ui/browser/dbloader.cxx b/dbaccess/source/ui/browser/dbloader.cxx index 35df7976f0d6..5a5c46048f0a 100644 --- a/dbaccess/source/ui/browser/dbloader.cxx +++ b/dbaccess/source/ui/browser/dbloader.cxx @@ -62,6 +62,8 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::registry; using namespace dbaui; +namespace { + class DBContentLoader : public ::cppu::WeakImplHelper< XFrameLoader, XServiceInfo> { private: @@ -92,6 +94,7 @@ public: virtual void SAL_CALL cancel() override; }; +} DBContentLoader::DBContentLoader(const Reference< XComponentContext >& _rxContext) :m_xContext(_rxContext) diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index 644c3417065e..a5dc5e061720 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -87,6 +87,8 @@ typedef std::unordered_map< sal_Int16, sal_Int16 > CommandHashMap; namespace dbaui { +namespace { + // UserDefinedFeatures class UserDefinedFeatures { @@ -99,6 +101,8 @@ private: css::uno::WeakReference< XController > m_aController; }; +} + UserDefinedFeatures::UserDefinedFeatures( const Reference< XController >& _rxController ) :m_aController( _rxController ) { diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 42ed0377446c..43655259bc06 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -1188,6 +1188,8 @@ void SbaGridControl::DoFieldDrag(sal_uInt16 nColumnPos, sal_Int16 nRowPos) } + namespace { + /// unary_function Functor object for class ZZ returntype is void struct SbaGridControlPrec { @@ -1204,6 +1206,9 @@ void SbaGridControl::DoFieldDrag(sal_uInt16 nColumnPos, sal_Int16 nRowPos) return false; } }; + + } + sal_Int8 SbaGridControl::AcceptDrop( const BrowserAcceptDropEvent& rEvt ) { sal_Int8 nAction = DND_ACTION_NONE; diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx index c5cb06c6c645..40efd0d7485b 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -543,12 +543,16 @@ OUString ODbDataSourceAdministrationHelper::getConnectionURL() const return sNewUrl; } +namespace { + struct PropertyValueLess { bool operator() (const PropertyValue& x, const PropertyValue& y) const { return x.Name < y.Name; } // construct prevents a MSVC6 warning }; +} + typedef std::set<PropertyValue, PropertyValueLess> PropertyValueSet; void ODbDataSourceAdministrationHelper::translateProperties(const Reference< XPropertySet >& _rxSource, SfxItemSet& _rDest) diff --git a/dbaccess/source/ui/dlg/UserAdmin.cxx b/dbaccess/source/ui/dlg/UserAdmin.cxx index 0310967fa290..3a2804b3ac32 100644 --- a/dbaccess/source/ui/dlg/UserAdmin.cxx +++ b/dbaccess/source/ui/dlg/UserAdmin.cxx @@ -50,6 +50,8 @@ using namespace dbaui; using namespace ucbhelper; using namespace comphelper; +namespace { + class OPasswordDialog : public weld::GenericDialogController { std::unique_ptr<weld::Frame> m_xUser; @@ -68,6 +70,8 @@ public: OUString GetNewPassword() const { return m_xEDPassword->get_text(); } }; +} + OPasswordDialog::OPasswordDialog(weld::Window* _pParent,const OUString& rUserName) : GenericDialogController(_pParent, "dbaccess/ui/password.ui", "PasswordDialog") , m_xUser(m_xBuilder->weld_frame("userframe")) diff --git a/dbaccess/source/ui/dlg/adtabdlg.cxx b/dbaccess/source/ui/dlg/adtabdlg.cxx index e69987042145..04dceaa09259 100644 --- a/dbaccess/source/ui/dlg/adtabdlg.cxx +++ b/dbaccess/source/ui/dlg/adtabdlg.cxx @@ -54,6 +54,8 @@ TableObjectListFacade::~TableObjectListFacade() { } +namespace { + class TableListFacade : public ::cppu::BaseMutex , public TableObjectListFacade , public ::comphelper::OContainerListener @@ -84,6 +86,8 @@ private: virtual void _elementReplaced( const css::container::ContainerEvent& _rEvent ) override; }; +} + TableListFacade::~TableListFacade() { if ( m_pContainerListener.is() ) @@ -233,6 +237,8 @@ bool TableListFacade::isLeafSelected() const return bEntry && !rTableList.iter_has_child(*xEntry); } +namespace { + class QueryListFacade : public ::cppu::BaseMutex , public TableObjectListFacade , public ::comphelper::OContainerListener @@ -261,6 +267,8 @@ private: virtual void _elementReplaced( const css::container::ContainerEvent& _rEvent ) override; }; +} + QueryListFacade::~QueryListFacade() { if ( m_pContainerListener.is() ) diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index c48c4c224c12..047758341b58 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -260,6 +260,8 @@ namespace } } +namespace { + class OExceptionChainDialog : public weld::GenericDialogController { std::unique_ptr<weld::TreeView> m_xExceptionList; @@ -277,6 +279,8 @@ protected: DECL_LINK(OnExceptionSelected, weld::TreeView&, void); }; +} + OExceptionChainDialog::OExceptionChainDialog(weld::Window* pParent, const ExceptionDisplayChain& rExceptions) : GenericDialogController(pParent, "dbaccess/ui/sqlexception.ui", "SQLExceptionDialog") , m_xExceptionList(m_xBuilder->weld_tree_view("list")) diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 98ec40a808b6..6be2d87fa9a9 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -387,6 +387,8 @@ OUString NamedTableCopySource::getSelectStatement() const return const_cast< NamedTableCopySource* >( this )->impl_ensureStatement_throw(); } +namespace { + // DummyCopySource class DummyCopySource : public ICopyTableSourceObject { @@ -410,6 +412,8 @@ public: getPreparedSelectStatement() const override; }; +} + const DummyCopySource& DummyCopySource::Instance() { static DummyCopySource s_aTheInstance; diff --git a/dbaccess/source/ui/misc/asyncmodaldialog.cxx b/dbaccess/source/ui/misc/asyncmodaldialog.cxx index 2f1b3e27b194..3c59a58f8b85 100644 --- a/dbaccess/source/ui/misc/asyncmodaldialog.cxx +++ b/dbaccess/source/ui/misc/asyncmodaldialog.cxx @@ -32,6 +32,8 @@ namespace dbaui using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::uno::Exception; + namespace { + // AsyncDialogExecutor class DialogExecutor_Impl { @@ -57,6 +59,8 @@ namespace dbaui DECL_LINK( onExecute, void*, void ); }; + } + IMPL_LINK_NOARG( DialogExecutor_Impl, onExecute, void*, void ) { try diff --git a/dbaccess/source/ui/misc/controllerframe.cxx b/dbaccess/source/ui/misc/controllerframe.cxx index 4bd0c9e4426d..599398e5d00f 100644 --- a/dbaccess/source/ui/misc/controllerframe.cxx +++ b/dbaccess/source/ui/misc/controllerframe.cxx @@ -64,6 +64,9 @@ namespace dbaui // FrameWindowActivationListener typedef ::cppu::WeakImplHelper< XTopWindowListener > FrameWindowActivationListener_Base; + + namespace { + class FrameWindowActivationListener : public FrameWindowActivationListener_Base { public: @@ -94,6 +97,8 @@ namespace dbaui ControllerFrame_Data* m_pData; }; + } + // ControllerFrame_Data struct ControllerFrame_Data { diff --git a/dbaccess/source/ui/misc/dbaundomanager.cxx b/dbaccess/source/ui/misc/dbaundomanager.cxx index 0ee8e9985590..d8659ce6157d 100644 --- a/dbaccess/source/ui/misc/dbaundomanager.cxx +++ b/dbaccess/source/ui/misc/dbaundomanager.cxx @@ -78,6 +78,8 @@ namespace dbaui return static_cast< XUndoManager* >( &rAntiImpl ); } + namespace { + // OslMutexFacade class OslMutexFacade : public ::framework::IMutex { @@ -96,6 +98,8 @@ namespace dbaui ::osl::Mutex& m_rMutex; }; + } + void OslMutexFacade::acquire() { m_rMutex.acquire(); @@ -106,6 +110,8 @@ namespace dbaui m_rMutex.release(); } + namespace { + // UndoManagerMethodGuard /** guard for public UNO methods of the UndoManager */ @@ -133,6 +139,8 @@ namespace dbaui OslMutexFacade m_aMutexFacade; }; + } + ::framework::IMutex& UndoManagerMethodGuard::getGuardedMutex() { return m_aMutexFacade; diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx index 505391d7cdb8..eb3331d6fe88 100644 --- a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx +++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx @@ -81,6 +81,8 @@ namespace dbaui using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::frame::XUntitledNumbers; + namespace { + class DataSourceHolder { public: @@ -116,6 +118,8 @@ namespace dbaui Reference< XOfficeDatabaseDocument > m_xDocument; }; + } + struct DBSubComponentController_Impl { private: diff --git a/dbaccess/source/ui/misc/dsmeta.cxx b/dbaccess/source/ui/misc/dsmeta.cxx index 82ccab986fd6..045f5b10bcdc 100644 --- a/dbaccess/source/ui/misc/dsmeta.cxx +++ b/dbaccess/source/ui/misc/dsmeta.cxx @@ -31,6 +31,8 @@ namespace dbaui using namespace dbaccess; using namespace ::com::sun::star; + namespace { + struct FeatureSupport { // authentication mode of the data source @@ -54,6 +56,8 @@ namespace dbaui const sal_Char* pAsciiFeatureName; }; + } + // global tables static const FeatureMapping* lcl_getFeatureMappings() { diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 1d6694c5bf99..3937c3d09d0d 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -96,6 +96,8 @@ namespace dbaui using namespace ::com::sun::star::util; using namespace ::com::sun::star::lang; + namespace { + class OViewController : public OQueryController { virtual OUString SAL_CALL getImplementationName() override @@ -127,6 +129,8 @@ namespace dbaui return *(new OViewController(comphelper::getComponentContext(_rM))); } }; + + } } extern "C" void createRegistryInfo_OViewControl() diff --git a/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx index bd8e33d436dc..9a2d0e652176 100644 --- a/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx +++ b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx @@ -35,6 +35,8 @@ namespace dbaui using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; + namespace { + // OAdvancedSettingsDialog class OAdvancedSettingsDialog :public ODatabaseAdministrationDialog @@ -71,6 +73,8 @@ namespace dbaui virtual std::unique_ptr<weld::DialogController> createDialog(const css::uno::Reference<css::awt::XWindow>& rParent) override; }; + } + OAdvancedSettingsDialog::OAdvancedSettingsDialog(const Reference< XComponentContext >& _rxORB) :ODatabaseAdministrationDialog(_rxORB) { diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index edb6805853eb..90fb3cc95b4f 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -142,6 +142,9 @@ namespace dbaui typedef ::cppu::ImplInheritanceHelper< CopyTableWizard_DialogBase , XCopyTableWizard > CopyTableWizard_Base; + + namespace { + class CopyTableWizard :public CopyTableWizard_Base ,public ::comphelper::OPropertyArrayUsageHelper< CopyTableWizard > @@ -372,6 +375,8 @@ private: CopyTableWizard& m_rWizard; }; +} + CopyTableWizard::CopyTableWizard( const Reference< XComponentContext >& _rxORB ) :CopyTableWizard_Base( _rxORB ) ,m_xContext( _rxORB ) diff --git a/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx b/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx index ff9e8a3dee0a..879a633cc00e 100644 --- a/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx +++ b/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx @@ -51,12 +51,19 @@ namespace dbaui // OTextConnectionSettingsDialog + namespace { + class OTextConnectionSettingsDialog; + + } + typedef ::cppu::ImplInheritanceHelper< ODatabaseAdministrationDialog , css::sdb::XTextConnectionSettings > OTextConnectionSettingsDialog_BASE; typedef ::comphelper::OPropertyArrayUsageHelper< OTextConnectionSettingsDialog > OTextConnectionSettingsDialog_PBASE; + namespace { + class OTextConnectionSettingsDialog :public OTextConnectionSettingsDialog_BASE ,public OTextConnectionSettingsDialog_PBASE @@ -108,6 +115,8 @@ namespace dbaui using OTextConnectionSettingsDialog_BASE::getFastPropertyValue; }; + } + // OTextConnectionSettingsDialog OTextConnectionSettingsDialog::OTextConnectionSettingsDialog( const Reference<XComponentContext>& _rContext ) :OTextConnectionSettingsDialog_BASE( _rContext ) |