diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-09-15 19:13:19 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-09-17 09:05:38 +0200 |
commit | 206b5b2661be37efdff3c6aedb6f248c4636be79 (patch) | |
tree | af385e5b4725dcfea23988d9113cced8e9ccaf3c /comphelper | |
parent | a85d3ba1c0de313b60324b9ecfa488bb99d69d06 (diff) |
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 <sbergman@redhat.com>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/base64.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/misc/mimeconfighelper.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/misc/syntaxhighlight.cxx | 5 | ||||
-rw-r--r-- | comphelper/source/processfactory/processfactory.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/streaming/seekableinput.cxx | 2 |
5 files changed, 8 insertions, 5 deletions
diff --git a/comphelper/source/misc/base64.cxx b/comphelper/source/misc/base64.cxx index 4e3a6bc6ef00..8fd02f120f8f 100644 --- a/comphelper/source/misc/base64.cxx +++ b/comphelper/source/misc/base64.cxx @@ -60,7 +60,7 @@ const // p q r s t u v w x y z -void ThreeByteToFourByte(const sal_Int8* pBuffer, const sal_Int32 nStart, const sal_Int32 nFullLen, sal_Char* aCharBuffer) +static void ThreeByteToFourByte(const sal_Int8* pBuffer, const sal_Int32 nStart, const sal_Int32 nFullLen, sal_Char* aCharBuffer) { sal_Int32 nLen(nFullLen - nStart); if (nLen > 3) diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx index c027bc1ff00f..8a4b002f7d77 100644 --- a/comphelper/source/misc/mimeconfighelper.cxx +++ b/comphelper/source/misc/mimeconfighelper.cxx @@ -66,7 +66,7 @@ OUString MimeConfigurationHelper::GetStringClassIDRepresentation( const uno::Seq } -sal_uInt8 GetDigit_Impl( sal_Char aChar ) +static sal_uInt8 GetDigit_Impl( sal_Char aChar ) { if ( aChar >= '0' && aChar <= '9' ) return aChar - '0'; diff --git a/comphelper/source/misc/syntaxhighlight.cxx b/comphelper/source/misc/syntaxhighlight.cxx index 76c8dfa862d3..3fb5bc057094 100644 --- a/comphelper/source/misc/syntaxhighlight.cxx +++ b/comphelper/source/misc/syntaxhighlight.cxx @@ -246,11 +246,14 @@ static const char* strListSqlKeyWords[] = { }; -extern "C" int compare_strings( const void *arg1, const void *arg2 ) +extern "C" { + +static int compare_strings( const void *arg1, const void *arg2 ) { return strcmp( static_cast<char const *>(arg1), *static_cast<char * const *>(arg2) ); } +} namespace { diff --git a/comphelper/source/processfactory/processfactory.cxx b/comphelper/source/processfactory/processfactory.cxx index 211067a5e75f..f3654a243ca9 100644 --- a/comphelper/source/processfactory/processfactory.cxx +++ b/comphelper/source/processfactory/processfactory.cxx @@ -36,7 +36,7 @@ namespace comphelper This function preserves only that the xProcessFactory variable will not be create when the library is loaded. */ -Reference< XMultiServiceFactory > localProcessFactory( const Reference< XMultiServiceFactory >& xSMgr, bool bSet ) +static Reference< XMultiServiceFactory > localProcessFactory( const Reference< XMultiServiceFactory >& xSMgr, bool bSet ) { Guard< Mutex > aGuard( Mutex::getGlobalMutex() ); diff --git a/comphelper/source/streaming/seekableinput.cxx b/comphelper/source/streaming/seekableinput.cxx index d7f107eae72d..89d887ea3548 100644 --- a/comphelper/source/streaming/seekableinput.cxx +++ b/comphelper/source/streaming/seekableinput.cxx @@ -35,7 +35,7 @@ namespace comphelper const sal_Int32 nConstBufferSize = 32000; -void copyInputToOutput_Impl( const uno::Reference< io::XInputStream >& xIn, +static void copyInputToOutput_Impl( const uno::Reference< io::XInputStream >& xIn, const uno::Reference< io::XOutputStream >& xOut ) { sal_Int32 nRead; |