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 /connectivity/source | |
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 'connectivity/source')
25 files changed, 85 insertions, 7 deletions
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index bf79ffd5ac7b..69f0933ef7cb 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -2131,6 +2131,8 @@ namespace detail virtual ~IValueSource() { } }; + namespace { + class RowValue : public IValueSource { public: @@ -2192,6 +2194,8 @@ namespace detail private: const Reference< XColumn > m_xColumn; }; + + } } diff --git a/connectivity/source/commontools/TSortIndex.cxx b/connectivity/source/commontools/TSortIndex.cxx index 0658c517a07d..76bbafaeb13a 100644 --- a/connectivity/source/commontools/TSortIndex.cxx +++ b/connectivity/source/commontools/TSortIndex.cxx @@ -24,6 +24,8 @@ using namespace connectivity; +namespace { + /// Functor object for class OSortIndex::TIntValuePairVector::value_type returntype is bool struct TKeyValueFunc { @@ -76,6 +78,7 @@ struct TKeyValueFunc } }; +} ::rtl::Reference<OKeySet> OSortIndex::CreateKeySet() { diff --git a/connectivity/source/cpool/ZConnectionPool.cxx b/connectivity/source/cpool/ZConnectionPool.cxx index 7ac1845911a1..c347e5ad84c9 100644 --- a/connectivity/source/cpool/ZConnectionPool.cxx +++ b/connectivity/source/cpool/ZConnectionPool.cxx @@ -75,6 +75,8 @@ OConnectionPool::~OConnectionPool() clear(false); } +namespace { + struct TRemoveEventListenerFunctor { OConnectionPool* m_pConnectionPool; @@ -125,6 +127,8 @@ struct TConnectionPoolFunctor } }; +} + void OConnectionPool::clear(bool _bDispose) { MutexGuard aGuard(m_aMutex); diff --git a/connectivity/source/drivers/calc/Cservices.cxx b/connectivity/source/drivers/calc/Cservices.cxx index 343c9fcb6305..91f58219cac3 100644 --- a/connectivity/source/drivers/calc/Cservices.cxx +++ b/connectivity/source/drivers/calc/Cservices.cxx @@ -36,6 +36,7 @@ typedef Reference< XSingleServiceFactory > (*createFactoryFunc) rtl_ModuleCount* ); +namespace { struct ProviderRequest { @@ -75,6 +76,7 @@ struct ProviderRequest void* getProvider() const { return xRet.get(); } }; +} extern "C" SAL_DLLPUBLIC_EXPORT void* connectivity_calc_component_getFactory( const sal_Char* pImplementationName, diff --git a/connectivity/source/drivers/dbase/Dservices.cxx b/connectivity/source/drivers/dbase/Dservices.cxx index c269ddf997f0..9e24128912b2 100644 --- a/connectivity/source/drivers/dbase/Dservices.cxx +++ b/connectivity/source/drivers/dbase/Dservices.cxx @@ -36,6 +36,7 @@ typedef Reference< XSingleServiceFactory > (*createFactoryFunc) rtl_ModuleCount* ); +namespace { struct ProviderRequest { @@ -75,6 +76,7 @@ struct ProviderRequest void* getProvider() const { return xRet.get(); } }; +} extern "C" SAL_DLLPUBLIC_EXPORT void* dbase_component_getFactory( const sal_Char* pImplementationName, diff --git a/connectivity/source/drivers/evoab2/EApi.cxx b/connectivity/source/drivers/evoab2/EApi.cxx index c802778cff2e..12096bdade87 100644 --- a/connectivity/source/drivers/evoab2/EApi.cxx +++ b/connectivity/source/drivers/evoab2/EApi.cxx @@ -38,12 +38,17 @@ static const char *eBookLibNames[] = { typedef void (*SymbolFunc) (); #define SYM_MAP(a) { #a, reinterpret_cast<SymbolFunc *>(&a) } + +namespace { + struct ApiMap { const char *sym_name; SymbolFunc *ref_value; }; +} + static const ApiMap aCommonApiMap[] = { SYM_MAP( eds_check_version ), diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx b/connectivity/source/drivers/evoab2/NResultSet.cxx index d6d55c272bfa..1341e5a33c68 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.cxx +++ b/connectivity/source/drivers/evoab2/NResultSet.cxx @@ -375,8 +375,6 @@ bool isBookBackend( EBookClient *pBook, const char *backendname) return isSourceBackend(pSource, backendname); } -} - class OEvoabVersion36Helper : public OEvoabVersionHelper { private: @@ -490,8 +488,6 @@ protected: } }; -namespace { - ESource * findSource( const char *id ) { ESourceList *pSourceList = nullptr; @@ -519,8 +515,6 @@ bool isAuthRequired( EBook *pBook ) "auth" ) != nullptr; } -} - class OEvoabVersion35Helper : public OEvoabVersionHelper { private: @@ -610,6 +604,8 @@ public: } }; +} + OEvoabResultSet::OEvoabResultSet( OCommonStatement* pStmt, OEvoabConnection *pConnection ) :OResultSet_BASE(m_aMutex) ,::comphelper::OPropertyContainer( OResultSet_BASE::rBHelper ) diff --git a/connectivity/source/drivers/evoab2/NServices.cxx b/connectivity/source/drivers/evoab2/NServices.cxx index 94b6f7867438..afc6291307cb 100644 --- a/connectivity/source/drivers/evoab2/NServices.cxx +++ b/connectivity/source/drivers/evoab2/NServices.cxx @@ -37,6 +37,7 @@ typedef Reference< XSingleServiceFactory > (*createFactoryFunc) rtl_ModuleCount* ); +namespace { struct ProviderRequest { @@ -77,6 +78,7 @@ struct ProviderRequest void* getProvider() const { return xRet.get(); } }; +} extern "C" SAL_DLLPUBLIC_EXPORT void* evoab2_component_getFactory( const sal_Char* pImplementationName, diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index dd4917634dab..b3b5ac9ee1da 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -109,6 +109,8 @@ Connection::~Connection() close(); } +namespace { + struct ConnectionGuard { oslInterlockedCount& m_refCount; @@ -123,6 +125,8 @@ struct ConnectionGuard } }; +} + void Connection::construct(const OUString& url, const Sequence< PropertyValue >& info) { ConnectionGuard aGuard(m_refCount); diff --git a/connectivity/source/drivers/firebird/Services.cxx b/connectivity/source/drivers/firebird/Services.cxx index 69b05e471263..f85d5dbb48d5 100644 --- a/connectivity/source/drivers/firebird/Services.cxx +++ b/connectivity/source/drivers/firebird/Services.cxx @@ -38,6 +38,8 @@ typedef Reference< XSingleServiceFactory > (*createFactoryFunc) rtl_ModuleCount* _pTemp ); +namespace { + struct ProviderRequest { Reference< XSingleServiceFactory > xRet; @@ -76,6 +78,7 @@ struct ProviderRequest void* getProvider() const { return xRet.get(); } }; +} extern "C" SAL_DLLPUBLIC_EXPORT void* firebird_sdbc_component_getFactory( const sal_Char* pImplementationName, diff --git a/connectivity/source/drivers/flat/Eservices.cxx b/connectivity/source/drivers/flat/Eservices.cxx index 62884acef137..4b8b6c4b2879 100644 --- a/connectivity/source/drivers/flat/Eservices.cxx +++ b/connectivity/source/drivers/flat/Eservices.cxx @@ -36,6 +36,7 @@ typedef Reference< XSingleServiceFactory > (*createFactoryFunc) rtl_ModuleCount* ); +namespace { struct ProviderRequest { @@ -75,6 +76,7 @@ struct ProviderRequest void* getProvider() const { return xRet.get(); } }; +} extern "C" SAL_DLLPUBLIC_EXPORT void* flat_component_getFactory( const sal_Char* pImplementationName, diff --git a/connectivity/source/drivers/hsqldb/Hservices.cxx b/connectivity/source/drivers/hsqldb/Hservices.cxx index a7ce2346374a..b41389a6d118 100644 --- a/connectivity/source/drivers/hsqldb/Hservices.cxx +++ b/connectivity/source/drivers/hsqldb/Hservices.cxx @@ -37,6 +37,7 @@ typedef Reference< XSingleServiceFactory > (*createFactoryFunc) rtl_ModuleCount* ); +namespace { struct ProviderRequest { @@ -76,6 +77,7 @@ struct ProviderRequest void* getProvider() const { return xRet.get(); } }; +} extern "C" SAL_DLLPUBLIC_EXPORT void* hsqldb_component_getFactory( const sal_Char* pImplementationName, diff --git a/connectivity/source/drivers/jdbc/jservices.cxx b/connectivity/source/drivers/jdbc/jservices.cxx index 281d8936d488..3044724735db 100644 --- a/connectivity/source/drivers/jdbc/jservices.cxx +++ b/connectivity/source/drivers/jdbc/jservices.cxx @@ -36,6 +36,7 @@ typedef Reference< XSingleServiceFactory > (*createFactoryFunc) rtl_ModuleCount* ); +namespace { struct ProviderRequest { @@ -75,6 +76,8 @@ struct ProviderRequest void* getProvider() const { return xRet.get(); } }; +} + extern "C" SAL_DLLPUBLIC_EXPORT void* jdbc_component_getFactory( const sal_Char* pImplementationName, void* pServiceManager, diff --git a/connectivity/source/drivers/mysql_jdbc/YTable.cxx b/connectivity/source/drivers/mysql_jdbc/YTable.cxx index 6eeaf3a23897..0db740478993 100644 --- a/connectivity/source/drivers/mysql_jdbc/YTable.cxx +++ b/connectivity/source/drivers/mysql_jdbc/YTable.cxx @@ -55,6 +55,8 @@ namespace connectivity { namespace mysql { +namespace +{ class OMySQLKeysHelper : public OKeysHelper { protected: @@ -69,6 +71,7 @@ public: }; } } +} OMySQLTable::OMySQLTable(sdbcx::OCollection* _pTables, const Reference<XConnection>& _xConnection) : OTableHelper(_pTables, _xConnection, true) diff --git a/connectivity/source/drivers/mysqlc/mysqlc_services.cxx b/connectivity/source/drivers/mysqlc/mysqlc_services.cxx index d23cf66aba06..56a2242e5e50 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_services.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_services.cxx @@ -35,6 +35,8 @@ typedef Reference<XSingleServiceFactory> (*createFactoryFunc)( ::cppu::ComponentInstantiation pCreateFunction, const Sequence<OUString>& rServiceNames, rtl_ModuleCount*); +namespace +{ struct ProviderRequest { Reference<XSingleServiceFactory> xRet; @@ -65,6 +67,7 @@ struct ProviderRequest void* getProvider() const { return xRet.get(); } }; +} extern "C" SAL_DLLPUBLIC_EXPORT void* component_getFactory(const sal_Char* pImplementationName, void* pServiceManager, diff --git a/connectivity/source/drivers/odbc/ORealDriver.cxx b/connectivity/source/drivers/odbc/ORealDriver.cxx index 8b76f4cf1cc6..1c7bc80ae203 100644 --- a/connectivity/source/drivers/odbc/ORealDriver.cxx +++ b/connectivity/source/drivers/odbc/ORealDriver.cxx @@ -26,6 +26,8 @@ namespace connectivity { namespace odbc { + namespace { + class ORealObdcDriver : public ODBCDriver { protected: @@ -35,6 +37,7 @@ namespace connectivity explicit ORealObdcDriver(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory) : ODBCDriver(_rxFactory) {} }; + } oslGenericFunction ORealObdcDriver::getOdbcFunction(ODBC3SQLFunctionId _nIndex) const { diff --git a/connectivity/source/drivers/odbc/oservices.cxx b/connectivity/source/drivers/odbc/oservices.cxx index 71fd857ec19e..9c4994172422 100644 --- a/connectivity/source/drivers/odbc/oservices.cxx +++ b/connectivity/source/drivers/odbc/oservices.cxx @@ -37,6 +37,7 @@ typedef Reference< XSingleServiceFactory > (*createFactoryFunc) rtl_ModuleCount* ); +namespace { struct ProviderRequest { @@ -76,6 +77,7 @@ struct ProviderRequest void* getProvider() const { return xRet.get(); } }; +} extern "C" SAL_DLLPUBLIC_EXPORT void* odbc_component_getFactory( const sal_Char* pImplementationName, diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx index 56670cef1aa5..868a011584c5 100644 --- a/connectivity/source/drivers/postgresql/pq_connection.cxx +++ b/connectivity/source/drivers/postgresql/pq_connection.cxx @@ -94,6 +94,7 @@ using com::sun::star::sdbc::XDatabaseMetaData; namespace pq_sdbc_driver { +namespace { // Helper class for statement lifetime management class ClosableReference : public cppu::WeakImplHelper< css::uno::XReference > @@ -116,6 +117,8 @@ public: } }; +} + static OUString ConnectionGetImplementationName() { return "org.openoffice.comp.connectivity.pq.Connection.noext"; @@ -393,6 +396,8 @@ void Connection::clearWarnings() { } +namespace { + class cstr_vector { std::vector<char*> values; @@ -426,6 +431,8 @@ public: char const** c_array() const { return const_cast <const char**>(values.data()); } }; +} + static void properties2arrays( const Sequence< PropertyValue > & args, const Reference< XTypeConverter> &tc, rtl_TextEncoding enc, diff --git a/connectivity/source/drivers/postgresql/pq_driver.cxx b/connectivity/source/drivers/postgresql/pq_driver.cxx index b11dc491d016..a8e915a5cc67 100644 --- a/connectivity/source/drivers/postgresql/pq_driver.cxx +++ b/connectivity/source/drivers/postgresql/pq_driver.cxx @@ -158,6 +158,7 @@ static Reference< XInterface > DriverCreateInstance( const Reference < XComponen return ret; } +namespace { class OOneInstanceComponentFactory : public MutexHolder, @@ -212,6 +213,8 @@ private: Reference< XComponentContext > m_defaultContext; }; +} + Reference< XInterface > OOneInstanceComponentFactory::createInstanceWithArgumentsAndContext( Sequence< Any > const &, const Reference< XComponentContext > & ctx ) { diff --git a/connectivity/source/drivers/postgresql/pq_statics.cxx b/connectivity/source/drivers/postgresql/pq_statics.cxx index 564ab7910567..1b8c1cc116e3 100644 --- a/connectivity/source/drivers/postgresql/pq_statics.cxx +++ b/connectivity/source/drivers/postgresql/pq_statics.cxx @@ -51,6 +51,8 @@ using com::sun::star::beans::Property; namespace pq_sdbc_driver { +namespace { + struct DefColumnMetaData { const sal_Char * columnName; @@ -83,6 +85,8 @@ struct PropertyDefEx : public PropertyDef sal_Int32 attribute; }; +} + static cppu::IPropertyArrayHelper * createPropertyArrayHelper( PropertyDef const *props, int count , sal_Int16 attr ) { diff --git a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx index 2082816813fd..147f5c17a465 100644 --- a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx +++ b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx @@ -66,6 +66,8 @@ using com::sun::star::lang::XEventListener; namespace pq_sdbc_driver { +namespace { + class ReplacedBroadcaster : public EventBroadcastHelper { ContainerEvent m_event; @@ -131,6 +133,8 @@ public: } }; +} + Container::Container( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex, const css::uno::Reference< css::sdbc::XConnection > & origin, @@ -201,6 +205,7 @@ sal_Int32 Container::getCount() return m_values.size(); } +namespace { class ContainerEnumeration : public ::cppu::WeakImplHelper< XEnumeration > { @@ -219,6 +224,8 @@ public: }; +} + sal_Bool ContainerEnumeration::hasMoreElements() { return static_cast<int>(m_vec.size()) > m_index +1; diff --git a/connectivity/source/drivers/writer/Wservices.cxx b/connectivity/source/drivers/writer/Wservices.cxx index 10e0e3ef32e7..69f88016231d 100644 --- a/connectivity/source/drivers/writer/Wservices.cxx +++ b/connectivity/source/drivers/writer/Wservices.cxx @@ -28,6 +28,8 @@ using createFactoryFunc = uno::Reference<lang::XSingleServiceFactory> (*)( const OUString& rComponentName, ::cppu::ComponentInstantiation pCreateFunction, const uno::Sequence<OUString>& rServiceNames, rtl_ModuleCount*); +namespace +{ struct ProviderRequest { private: @@ -60,6 +62,7 @@ public: uno::XInterface* getProvider() const { return xRet.get(); } }; +} extern "C" SAL_DLLPUBLIC_EXPORT void* connectivity_writer_component_getFactory(const sal_Char* pImplementationName, void* pServiceManager, diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx index c88e117414fa..b3291cf89f5f 100644 --- a/connectivity/source/manager/mdrivermanager.cxx +++ b/connectivity/source/manager/mdrivermanager.cxx @@ -102,6 +102,7 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) return makeAny( *m_aPos++ ); } + namespace { /// an STL functor which ensures that a SdbcDriver described by a DriverAccess is loaded struct EnsureDriver @@ -173,6 +174,8 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) } }; + } + static sal_Int32 lcl_getDriverPrecedence( const Reference<XComponentContext>& _rContext, Sequence< OUString >& _rPrecedence ) { _rPrecedence.realloc( 0 ); @@ -208,6 +211,8 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) return _rPrecedence.getLength(); } + namespace { + /// an STL argorithm compatible predicate comparing two DriverAccess instances by their implementation names struct CompareDriverAccessByName { @@ -230,6 +235,7 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) } }; + } OSDBCDriverManager::OSDBCDriverManager( const Reference< XComponentContext >& _rxContext ) :m_xContext( _rxContext ) diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 4cb00394faa3..2c928216707c 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -109,6 +109,7 @@ namespace connectivity } }; + namespace { /** helper class for temporarily adding a query name to a list of forbidden query names */ @@ -132,6 +133,8 @@ namespace connectivity m_rpAllForbiddenNames->erase( m_sForbiddenQueryName ); } }; + + } } OSQLParseTreeIterator::OSQLParseTreeIterator(const Reference< XConnection >& _rxConnection, diff --git a/connectivity/source/resource/sharedresources.cxx b/connectivity/source/resource/sharedresources.cxx index 87185d66b83a..bab95793452d 100644 --- a/connectivity/source/resource/sharedresources.cxx +++ b/connectivity/source/resource/sharedresources.cxx @@ -29,7 +29,7 @@ namespace connectivity { - + namespace { class SharedResources_Impl { @@ -59,6 +59,8 @@ namespace connectivity } }; + } + SharedResources_Impl* SharedResources_Impl::s_pInstance( nullptr ); oslInterlockedCount SharedResources_Impl::s_nClients( 0 ); |