From 206b5b2661be37efdff3c6aedb6f248c4636be79 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sat, 15 Sep 2018 19:13:19 +0200 Subject: New loplugin:external ...warning about (for now only) functions and variables with external linkage that likely don't need it. The problems with moving entities into unnamed namespacs and breaking ADL (as alluded to in comments in compilerplugins/clang/external.cxx) are illustrated by the fact that while struct S1 { int f() { return 0; } }; int f(S1 s) { return s.f(); } namespace N { struct S2: S1 { int f() { return 1; } }; int f(S2 s) { return s.f(); } } int main() { return f(N::S2()); } returns 1, both moving just the struct S2 into an nunnamed namespace, struct S1 { int f() { return 0; } }; int f(S1 s) { return s.f(); } namespace N { namespace { struct S2: S1 { int f() { return 1; } }; } int f(S2 s) { return s.f(); } } int main() { return f(N::S2()); } as well as moving just the function f overload into an unnamed namespace, struct S1 { int f() { return 0; } }; int f(S1 s) { return s.f(); } namespace N { struct S2: S1 { int f() { return 1; } }; namespace { int f(S2 s) { return s.f(); } } } int main() { return f(N::S2()); } would each change the program to return 0 instead. Change-Id: I4d09f7ac5e8f9bcd6e6bde4712608444b642265c Reviewed-on: https://gerrit.libreoffice.org/60539 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- connectivity/source/commontools/CommonTools.cxx | 4 ++-- connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx | 2 +- connectivity/source/commontools/TKeys.cxx | 2 +- connectivity/source/commontools/TTableHelper.cxx | 2 +- connectivity/source/commontools/dbtools.cxx | 10 +++++----- connectivity/source/commontools/dbtools2.cxx | 6 +++--- connectivity/source/drivers/evoab2/NResultSet.cxx | 7 +++++-- connectivity/source/drivers/firebird/Util.cxx | 4 ++-- connectivity/source/drivers/hsqldb/HStorageMap.cxx | 4 ++-- connectivity/source/drivers/jdbc/Object.cxx | 4 ++-- connectivity/source/drivers/mork/MQueryHelper.cxx | 2 +- connectivity/source/drivers/mork/mork_helper.cxx | 2 +- connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx | 4 ++-- connectivity/source/drivers/odbc/OFunctions.cxx | 2 +- connectivity/source/drivers/postgresql/pq_connection.cxx | 6 +++--- connectivity/source/drivers/postgresql/pq_driver.cxx | 6 +++--- connectivity/source/manager/mdrivermanager.cxx | 2 +- connectivity/source/parse/sqlnode.cxx | 4 ++-- 18 files changed, 38 insertions(+), 35 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/commontools/CommonTools.cxx b/connectivity/source/commontools/CommonTools.cxx index 51d449ad1bb0..61e14b44aee3 100644 --- a/connectivity/source/commontools/CommonTools.cxx +++ b/connectivity/source/commontools/CommonTools.cxx @@ -36,7 +36,7 @@ #include using namespace ::comphelper; -inline sal_Unicode rtl_ascii_toUpperCase( sal_Unicode ch ) +static inline sal_Unicode rtl_ascii_toUpperCase( sal_Unicode ch ) { return ch >= 0x0061 && ch <= 0x007a ? ch + 0x20 : ch; } @@ -168,7 +168,7 @@ namespace connectivity namespace dbtools { -bool isCharOk(sal_Unicode c,const OUString& _rSpecials) +static bool isCharOk(sal_Unicode c,const OUString& _rSpecials) { return ( ((c >= 97) && (c <= 122)) || ((c >= 65) && (c <= 90)) || ((c >= 48) && (c <= 57)) || diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx index bef6e6c5584f..95bae62bed1e 100644 --- a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx +++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx @@ -871,7 +871,7 @@ void SAL_CALL ODatabaseMetaDataResultSet::initialize( const Sequence< Any >& _aA namespace connectivity { /// @throws Exception - Reference< XInterface > ODatabaseMetaDataResultSet_CreateInstance(const Reference< XComponentContext >& ) + static Reference< XInterface > ODatabaseMetaDataResultSet_CreateInstance(const Reference< XComponentContext >& ) { return *(new ODatabaseMetaDataResultSet()); } diff --git a/connectivity/source/commontools/TKeys.cxx b/connectivity/source/commontools/TKeys.cxx index 81479b491d92..293a0dab4ccf 100644 --- a/connectivity/source/commontools/TKeys.cxx +++ b/connectivity/source/commontools/TKeys.cxx @@ -79,7 +79,7 @@ Reference< XPropertySet > OKeysHelper::createDescriptor() /** returns the keyrule string for the primary key */ -OUString getKeyRuleString(bool _bUpdate,sal_Int32 _nKeyRule) +static OUString getKeyRuleString(bool _bUpdate,sal_Int32 _nKeyRule) { const char* pKeyRule = nullptr; switch ( _nKeyRule ) diff --git a/connectivity/source/commontools/TTableHelper.cxx b/connectivity/source/commontools/TTableHelper.cxx index 92447c8e94db..7b9bb2e52984 100644 --- a/connectivity/source/commontools/TTableHelper.cxx +++ b/connectivity/source/commontools/TTableHelper.cxx @@ -94,7 +94,7 @@ public: } namespace connectivity { - OUString lcl_getServiceNameForSetting(const Reference< css::sdbc::XConnection >& _xConnection,const OUString& i_sSetting) + static OUString lcl_getServiceNameForSetting(const Reference< css::sdbc::XConnection >& _xConnection,const OUString& i_sSetting) { OUString sSupportService; Any aValue; diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 2476315bc46c..b8b8a4cdd29b 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -220,7 +220,7 @@ sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType, return nFormat; } -Reference< XConnection> findConnection(const Reference< XInterface >& xParent) +static Reference< XConnection> findConnection(const Reference< XInterface >& xParent) { Reference< XConnection> xConnection(xParent, UNO_QUERY); if (!xConnection.is()) @@ -232,7 +232,7 @@ Reference< XConnection> findConnection(const Reference< XInterface >& xParent) return xConnection; } -Reference< XDataSource> getDataSource_allowException( +static Reference< XDataSource> getDataSource_allowException( const OUString& _rsTitleOrPath, const Reference< XComponentContext >& _rxContext ) { @@ -260,7 +260,7 @@ Reference< XDataSource > getDataSource( return xDS; } -Reference< XConnection > getConnection_allowException( +static Reference< XConnection > getConnection_allowException( const OUString& _rsTitleOrPath, const OUString& _rsUser, const OUString& _rsPwd, @@ -337,7 +337,7 @@ Reference< XConnection> getConnection(const Reference< XRowSet>& _rxRowSet) // helper function which allows to implement both the connectRowset and the ensureRowSetConnection semantics // if connectRowset (which is deprecated) is removed, this function and one of its parameters are // not needed anymore, the whole implementation can be moved into ensureRowSetConnection then) -SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext, +static SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext, bool _bAttachAutoDisposer ) { SharedConnection xConnection; @@ -1197,7 +1197,7 @@ Reference< XDataSource> findDataSource(const Reference< XInterface >& _xParent) return xDataSource; } -Reference< XSingleSelectQueryComposer > getComposedRowSetStatement( const Reference< XPropertySet >& _rxRowSet, const Reference< XComponentContext >& _rxContext ) +static Reference< XSingleSelectQueryComposer > getComposedRowSetStatement( const Reference< XPropertySet >& _rxRowSet, const Reference< XComponentContext >& _rxContext ) { Reference< XSingleSelectQueryComposer > xComposer; try diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index d17c96d400ee..b8643e642efd 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -940,17 +940,17 @@ sal_Int32 DBTypeConversion::convertUnicodeStringToLength( const OUString& _rSour return nLen; } -OUString lcl_getReportEngines() +static OUString lcl_getReportEngines() { return OUString("org.openoffice.Office.DataAccess/ReportEngines"); } -OUString lcl_getDefaultReportEngine() +static OUString lcl_getDefaultReportEngine() { return OUString("DefaultReportEngine"); } -OUString lcl_getReportEngineNames() +static OUString lcl_getReportEngineNames() { return OUString("ReportEngineNames"); } diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx b/connectivity/source/drivers/evoab2/NResultSet.cxx index e852309963ae..79557fd69789 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.cxx +++ b/connectivity/source/drivers/evoab2/NResultSet.cxx @@ -297,8 +297,9 @@ getValue( EContact* pContact, sal_Int32 nColumnNum, GType nType, GValue* pStackV return true; } -extern "C" -int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _userData ) +extern "C" { + +static int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _userData ) { EContact* lhs = const_cast< gpointer >( _lhs ); EContact* rhs = const_cast< gpointer >( _rhs ); @@ -355,6 +356,8 @@ int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _userData return 0; } +} + OString OEvoabVersionHelper::getUserName( EBook *pBook ) { OString aName; diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx index 14844cfaaddb..6cc5d16484f9 100644 --- a/connectivity/source/drivers/firebird/Util.cxx +++ b/connectivity/source/drivers/firebird/Util.cxx @@ -67,7 +67,7 @@ void firebird::evaluateStatusVector(const ISC_STATUS_ARRAY& rStatusVector, } } -sal_Int32 lcl_getNumberType( short aType, NumberSubType aSubType ) +static sal_Int32 lcl_getNumberType( short aType, NumberSubType aSubType ) { switch(aSubType) { @@ -92,7 +92,7 @@ sal_Int32 lcl_getNumberType( short aType, NumberSubType aSubType ) } } } -sal_Int32 lcl_getCharColumnType( short aType, const OUString& sCharset ) +static sal_Int32 lcl_getCharColumnType( short aType, const OUString& sCharset ) { switch(aType) { diff --git a/connectivity/source/drivers/hsqldb/HStorageMap.cxx b/connectivity/source/drivers/hsqldb/HStorageMap.cxx index f3214e94359c..04116d02f036 100644 --- a/connectivity/source/drivers/hsqldb/HStorageMap.cxx +++ b/connectivity/source/drivers/hsqldb/HStorageMap.cxx @@ -123,13 +123,13 @@ namespace connectivity } } - TStorages& lcl_getStorageMap() + static TStorages& lcl_getStorageMap() { static TStorages s_aMap; return s_aMap; } - OUString lcl_getNextCount() + static OUString lcl_getNextCount() { static sal_Int32 s_nCount = 0; return OUString::number(s_nCount++); diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx index 4a9a854d48f7..8fac24980fb7 100644 --- a/connectivity/source/drivers/jdbc/Object.cxx +++ b/connectivity/source/drivers/jdbc/Object.cxx @@ -40,7 +40,7 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; -::rtl::Reference< jvmaccess::VirtualMachine > const & getJavaVM2(const ::rtl::Reference< jvmaccess::VirtualMachine >& _rVM = ::rtl::Reference< jvmaccess::VirtualMachine >(), +static ::rtl::Reference< jvmaccess::VirtualMachine > const & getJavaVM2(const ::rtl::Reference< jvmaccess::VirtualMachine >& _rVM = ::rtl::Reference< jvmaccess::VirtualMachine >(), bool _bSet = false) { static ::rtl::Reference< jvmaccess::VirtualMachine > s_VM; @@ -70,7 +70,7 @@ SDBThreadAttach::~SDBThreadAttach() { } -oslInterlockedCount& getJavaVMRefCount() +static oslInterlockedCount& getJavaVMRefCount() { static oslInterlockedCount s_nRefCount = 0; return s_nRefCount; diff --git a/connectivity/source/drivers/mork/MQueryHelper.cxx b/connectivity/source/drivers/mork/MQueryHelper.cxx index 00cdf3df93c0..c2b3ccf5713b 100644 --- a/connectivity/source/drivers/mork/MQueryHelper.cxx +++ b/connectivity/source/drivers/mork/MQueryHelper.cxx @@ -41,7 +41,7 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; -extern +static std::vector entryMatchedByExpression(MQueryHelper* _aQuery, MQueryExpression const * _aExpr, MQueryHelperResultEntry* entry); MQueryHelperResultEntry::MQueryHelperResultEntry() diff --git a/connectivity/source/drivers/mork/mork_helper.cxx b/connectivity/source/drivers/mork/mork_helper.cxx index 07c70a1aa2d6..4cb11864fee5 100644 --- a/connectivity/source/drivers/mork/mork_helper.cxx +++ b/connectivity/source/drivers/mork/mork_helper.cxx @@ -4,7 +4,7 @@ #include #include -bool openAddressBook(const std::string& path) +static bool openAddressBook(const std::string& path) { MorkParser mork; // Open and parse mork file diff --git a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx index 903481e27fe0..5fb717fe3741 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx @@ -47,8 +47,8 @@ using namespace com::sun::star::sdbc; static std::string wild("%"); -void lcl_setRows_throw(const Reference& _xResultSet, sal_Int32 _nType, - const std::vector>& _rRows) +static void lcl_setRows_throw(const Reference& _xResultSet, sal_Int32 _nType, + const std::vector>& _rRows) { Reference xIni(_xResultSet, UNO_QUERY); Sequence aArgs(2); diff --git a/connectivity/source/drivers/odbc/OFunctions.cxx b/connectivity/source/drivers/odbc/OFunctions.cxx index 9e546e389208..f740052325c3 100644 --- a/connectivity/source/drivers/odbc/OFunctions.cxx +++ b/connectivity/source/drivers/odbc/OFunctions.cxx @@ -79,7 +79,7 @@ T3SQLFreeHandle pODBC3SQLFreeHandle; T3SQLGetCursorName pODBC3SQLGetCursorName; T3SQLNativeSql pODBC3SQLNativeSql; -bool LoadFunctions(oslModule pODBCso); +static bool LoadFunctions(oslModule pODBCso); // Take care of Dynamically loading of the DLL/shared lib and Addresses: // Returns sal_True at success diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx index fe113e0c0585..172c6fc5f130 100644 --- a/connectivity/source/drivers/postgresql/pq_connection.cxx +++ b/connectivity/source/drivers/postgresql/pq_connection.cxx @@ -117,11 +117,11 @@ public: } }; -OUString ConnectionGetImplementationName() +static OUString ConnectionGetImplementationName() { return OUString( "org.openoffice.comp.connectivity.pq.Connection.noext" ); } -css::uno::Sequence ConnectionGetSupportedServiceNames() +static css::uno::Sequence ConnectionGetSupportedServiceNames() { return Sequence< OUString > { "com.sun.star.sdbc.Connection" }; } @@ -640,7 +640,7 @@ Reference< XNameAccess > Connection::getUsers() } /// @throws Exception -Reference< XInterface > ConnectionCreateInstance( +static Reference< XInterface > ConnectionCreateInstance( const Reference< XComponentContext > & ctx ) { ::rtl::Reference< comphelper::RefCountedMutex > ref = new comphelper::RefCountedMutex; diff --git a/connectivity/source/drivers/postgresql/pq_driver.cxx b/connectivity/source/drivers/postgresql/pq_driver.cxx index a51f69c848e9..a27bd95175d5 100644 --- a/connectivity/source/drivers/postgresql/pq_driver.cxx +++ b/connectivity/source/drivers/postgresql/pq_driver.cxx @@ -70,12 +70,12 @@ using com::sun::star::sdbcx::XTablesSupplier; namespace pq_sdbc_driver { -OUString DriverGetImplementationName() +static OUString DriverGetImplementationName() { return OUString( "org.openoffice.comp.connectivity.pq.Driver.noext" ); } -Sequence< OUString > DriverGetSupportedServiceNames() +static Sequence< OUString > DriverGetSupportedServiceNames() { return Sequence< OUString > { "com.sun.star.sdbc.Driver" }; } @@ -154,7 +154,7 @@ Reference< XTablesSupplier > Driver::getDataDefinitionByURL( } -Reference< XInterface > DriverCreateInstance( const Reference < XComponentContext > & ctx ) +static Reference< XInterface > DriverCreateInstance( const Reference < XComponentContext > & ctx ) { Reference< XInterface > ret = * new Driver( ctx ); return ret; diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx index e9fdf9f8ad09..cac14c1d673f 100644 --- a/connectivity/source/manager/mdrivermanager.cxx +++ b/connectivity/source/manager/mdrivermanager.cxx @@ -50,7 +50,7 @@ using namespace ::osl; #define SERVICE_SDBC_DRIVER "com.sun.star.sdbc.Driver" /// @throws NoSuchElementException -void throwNoSuchElementException() +static void throwNoSuchElementException() { throw NoSuchElementException(); } diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 2b2a687f6e47..683ac9e3b3c2 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1786,7 +1786,7 @@ OSQLParseNode* OSQLParseNode::getByRule(OSQLParseNode::Rule eRule) const return pRetNode; } -OSQLParseNode* MakeANDNode(OSQLParseNode *pLeftLeaf,OSQLParseNode *pRightLeaf) +static OSQLParseNode* MakeANDNode(OSQLParseNode *pLeftLeaf,OSQLParseNode *pRightLeaf) { OSQLParseNode* pNewNode = new OSQLParseNode(OUString(),SQLNodeType::Rule,OSQLParser::RuleID(OSQLParseNode::boolean_term)); pNewNode->append(pLeftLeaf); @@ -1795,7 +1795,7 @@ OSQLParseNode* MakeANDNode(OSQLParseNode *pLeftLeaf,OSQLParseNode *pRightLeaf) return pNewNode; } -OSQLParseNode* MakeORNode(OSQLParseNode *pLeftLeaf,OSQLParseNode *pRightLeaf) +static OSQLParseNode* MakeORNode(OSQLParseNode *pLeftLeaf,OSQLParseNode *pRightLeaf) { OSQLParseNode* pNewNode = new OSQLParseNode(OUString(),SQLNodeType::Rule,OSQLParser::RuleID(OSQLParseNode::search_condition)); pNewNode->append(pLeftLeaf); -- cgit