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 --- linguistic/source/convdic.cxx | 2 +- linguistic/source/convdiclist.cxx | 4 ++-- linguistic/source/dlistimp.cxx | 2 +- linguistic/source/gciterator.cxx | 6 +++++- linguistic/source/hhconvdic.cxx | 4 ++-- linguistic/source/lngopt.cxx | 2 +- linguistic/source/lngsvcmgr.cxx | 2 +- linguistic/source/misc.cxx | 2 +- linguistic/source/spelldsp.cxx | 2 +- linguistic/source/spelldta.cxx | 2 +- 10 files changed, 16 insertions(+), 12 deletions(-) (limited to 'linguistic') diff --git a/linguistic/source/convdic.cxx b/linguistic/source/convdic.cxx index c29afc0e25b1..6a08b11498d8 100644 --- a/linguistic/source/convdic.cxx +++ b/linguistic/source/convdic.cxx @@ -67,7 +67,7 @@ using namespace linguistic; #define SN_CONV_DICTIONARY "com.sun.star.linguistic2.ConversionDictionary" -void ReadThroughDic( const OUString &rMainURL, ConvDicXMLImport &rImport ) +static void ReadThroughDic( const OUString &rMainURL, ConvDicXMLImport &rImport ) { if (rMainURL.isEmpty()) return; diff --git a/linguistic/source/convdiclist.cxx b/linguistic/source/convdiclist.cxx index 58b7b8bc4a02..589a38aa42fd 100644 --- a/linguistic/source/convdiclist.cxx +++ b/linguistic/source/convdiclist.cxx @@ -62,7 +62,7 @@ using namespace linguistic; #define SN_CONV_DICTIONARY_LIST "com.sun.star.linguistic2.ConversionDictionaryList" -OUString GetConvDicMainURL( const OUString &rDicName, const OUString &rDirectoryURL ) +static OUString GetConvDicMainURL( const OUString &rDicName, const OUString &rDirectoryURL ) { // build URL to use for new (persistent) dictionaries @@ -561,7 +561,7 @@ uno::Sequence< OUString > ConvDicList::getSupportedServiceNames_Static() } /// @throws css::uno::Exception -uno::Reference< uno::XInterface > ConvDicList_CreateInstance( +static uno::Reference< uno::XInterface > ConvDicList_CreateInstance( const uno::Reference< XMultiServiceFactory > & /*rSMgr*/ ) { return StaticConvDicList::get(); diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx index 651cb6ed2731..7f875fc3cc05 100644 --- a/linguistic/source/dlistimp.cxx +++ b/linguistic/source/dlistimp.cxx @@ -364,7 +364,7 @@ sal_Int32 DicList::GetDicPos(const uno::Reference< XDictionary > &xDic) } /// @throws Exception -uno::Reference< XInterface > +static uno::Reference< XInterface > DicList_CreateInstance( const uno::Reference< XMultiServiceFactory > & /*rSMgr*/ ) { uno::Reference< XInterface > xService = static_cast(new DicList); diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index c104ee9a4f95..685947c4cdf8 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -219,13 +219,17 @@ static sal_Int32 lcl_BacktraceWhiteSpaces( const OUString &rText, sal_Int32 nSta } -extern "C" void lcl_workerfunc (void * gci) +extern "C" { + +static void lcl_workerfunc (void * gci) { osl_setThreadName("GrammarCheckingIterator"); static_cast(gci)->DequeueAndCheck(); } +} + static lang::Locale lcl_GetPrimaryLanguageOfSentence( const uno::Reference< text::XFlatParagraph >& xFlatPara, sal_Int32 nStartIndex ) diff --git a/linguistic/source/hhconvdic.cxx b/linguistic/source/hhconvdic.cxx index 2e8969b0dff6..801af0800947 100644 --- a/linguistic/source/hhconvdic.cxx +++ b/linguistic/source/hhconvdic.cxx @@ -56,7 +56,7 @@ using namespace i18n; // from i18npool/source/textconversion/textconversion_ko.cxx /// @throws RuntimeException -sal_Int16 checkScriptType(sal_Unicode c) +static sal_Int16 checkScriptType(sal_Unicode c) { UErrorCode status = U_ZERO_ERROR; @@ -69,7 +69,7 @@ sal_Int16 checkScriptType(sal_Unicode c) } -bool TextIsAllScriptType( const OUString &rTxt, sal_Int16 nScriptType ) +static bool TextIsAllScriptType( const OUString &rTxt, sal_Int16 nScriptType ) { bool bIsAll = true; for (sal_Int32 i = 0; i < rTxt.getLength() && bIsAll; ++i) diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx index ec7816cf445c..cf89b437f98c 100644 --- a/linguistic/source/lngopt.cxx +++ b/linguistic/source/lngopt.cxx @@ -210,7 +210,7 @@ void LinguProps::launchEvent( const PropertyChangeEvent &rEvt ) const } /// @throws Exception -Reference< XInterface > LinguProps_CreateInstance( +static Reference< XInterface > LinguProps_CreateInstance( const Reference< XMultiServiceFactory > & /*rSMgr*/ ) { Reference< XInterface > xService = static_cast(new LinguProps); diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx index b06ac83dfdf5..d62510c0645f 100644 --- a/linguistic/source/lngsvcmgr.cxx +++ b/linguistic/source/lngsvcmgr.cxx @@ -1941,7 +1941,7 @@ uno::Sequence< OUString > LngSvcMgr::getSupportedServiceNames_Static() } /// @throws uno::Exception -uno::Reference< uno::XInterface > LngSvcMgr_CreateInstance( +static uno::Reference< uno::XInterface > LngSvcMgr_CreateInstance( const uno::Reference< lang::XMultiServiceFactory > & /*rSMgr*/ ) { uno::Reference< uno::XInterface > xService = static_cast(new LngSvcMgr); diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx index 1bf297d4589e..b49e4f555418 100644 --- a/linguistic/source/misc.cxx +++ b/linguistic/source/misc.cxx @@ -590,7 +590,7 @@ static CharClass & lcl_GetCharClass() return aCC; } -osl::Mutex & lcl_GetCharClassMutex() +static osl::Mutex & lcl_GetCharClassMutex() { static osl::Mutex aMutex; return aMutex; diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx index 104dce04bff6..0251635c3d9f 100644 --- a/linguistic/source/spelldsp.cxx +++ b/linguistic/source/spelldsp.cxx @@ -154,7 +154,7 @@ std::vector< OUString > ProposalList::GetVector() const return aRes; } -bool SvcListHasLanguage( +static bool SvcListHasLanguage( const LangSvcEntries_Spell &rEntry, LanguageType nLanguage ) { diff --git a/linguistic/source/spelldta.cxx b/linguistic/source/spelldta.cxx index ded6f83bf846..7a0bc0f5d183 100644 --- a/linguistic/source/spelldta.cxx +++ b/linguistic/source/spelldta.cxx @@ -43,7 +43,7 @@ namespace linguistic #define MAX_PROPOSALS 40 -bool SeqHasEntry( +static bool SeqHasEntry( const std::vector< OUString > &rSeq, const OUString &rTxt) { -- cgit