summaryrefslogtreecommitdiffstats
path: root/io
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-11-19 16:32:49 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-11-22 12:57:32 +0100
commitf853ec317f6af1b8c65cc5bd758371689c75118d (patch)
treeb86d729bf9a9465ee619ead3b5635efa62a1804e /io
parenttdf#124513 let wizard reappear on tabbing back to document (diff)
downloadcore-f853ec317f6af1b8c65cc5bd758371689c75118d.tar.gz
core-f853ec317f6af1b8c65cc5bd758371689c75118d.zip
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 'io')
-rw-r--r--io/source/TextInputStream/TextInputStream.cxx4
-rw-r--r--io/source/TextOutputStream/TextOutputStream.cxx4
-rw-r--r--io/source/acceptor/acc_pipe.cxx2
-rw-r--r--io/source/acceptor/acc_socket.cxx7
-rw-r--r--io/source/acceptor/acceptor.cxx7
-rw-r--r--io/source/connector/connector.cxx4
-rw-r--r--io/source/connector/ctr_socket.cxx4
-rw-r--r--io/source/stm/odata.cxx18
-rw-r--r--io/source/stm/omark.cxx7
-rw-r--r--io/source/stm/opipe.cxx3
-rw-r--r--io/source/stm/opump.cxx4
11 files changed, 64 insertions, 0 deletions
diff --git a/io/source/TextInputStream/TextInputStream.cxx b/io/source/TextInputStream/TextInputStream.cxx
index d90f30976ec8..fc860b1063b1 100644
--- a/io/source/TextInputStream/TextInputStream.cxx
+++ b/io/source/TextInputStream/TextInputStream.cxx
@@ -55,6 +55,8 @@ namespace io_TextInputStream
#define INITIAL_UNICODE_BUFFER_CAPACITY 0x100
#define READ_BYTE_COUNT 0x100
+namespace {
+
class OTextInputStream : public WeakImplHelper< XTextInputStream2, XServiceInfo >
{
Reference< XInputStream > mxStream;
@@ -105,6 +107,8 @@ public:
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
};
+}
+
OTextInputStream::OTextInputStream()
: mbEncodingInitialized(false)
, mConvText2Unicode(nullptr)
diff --git a/io/source/TextOutputStream/TextOutputStream.cxx b/io/source/TextOutputStream/TextOutputStream.cxx
index 22fab1f01bd0..5f39c8afbb5e 100644
--- a/io/source/TextOutputStream/TextOutputStream.cxx
+++ b/io/source/TextOutputStream/TextOutputStream.cxx
@@ -47,6 +47,8 @@ namespace io_TextOutputStream
// Implementation XTextOutputStream
+namespace {
+
class OTextOutputStream : public WeakImplHelper< XTextOutputStream2, XServiceInfo >
{
Reference< XOutputStream > mxStream;
@@ -83,6 +85,8 @@ public:
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
};
+}
+
OTextOutputStream::OTextOutputStream()
: mbEncodingInitialized(false)
, mConvUnicode2Text(nullptr)
diff --git a/io/source/acceptor/acc_pipe.cxx b/io/source/acceptor/acc_pipe.cxx
index ad9ce09a20cb..b06b0aa678bc 100644
--- a/io/source/acceptor/acc_pipe.cxx
+++ b/io/source/acceptor/acc_pipe.cxx
@@ -37,6 +37,7 @@ using namespace ::com::sun::star::io;
namespace io_acceptor
{
+ namespace {
class PipeConnection :
public WeakImplHelper< XConnection >
@@ -55,6 +56,7 @@ namespace io_acceptor
OUString m_sDescription;
};
+ }
PipeConnection::PipeConnection( const OUString &sConnectionDescription) :
m_nStatus( 0 ),
diff --git a/io/source/acceptor/acc_socket.cxx b/io/source/acceptor/acc_socket.cxx
index a72179ecb356..9700cd566bb8 100644
--- a/io/source/acceptor/acc_socket.cxx
+++ b/io/source/acceptor/acc_socket.cxx
@@ -41,6 +41,7 @@ namespace io_acceptor {
typedef std::unordered_set< css::uno::Reference< css::io::XStreamListener> >
XStreamListener_hash_set;
+ namespace {
class SocketConnection : public ::cppu::WeakImplHelper<
css::connection::XConnection,
@@ -75,6 +76,8 @@ namespace io_acceptor {
XStreamListener_hash_set _listeners;
};
+ }
+
template<class T>
static void notifyListeners(SocketConnection * pCon, bool * notified, T t)
{
@@ -98,6 +101,8 @@ namespace io_acceptor {
xStreamListener->started();
}
+ namespace {
+
struct callError {
const Any & any;
@@ -106,6 +111,8 @@ namespace io_acceptor {
void operator () (const Reference<XStreamListener>& xStreamListener);
};
+ }
+
callError::callError(const Any & aAny)
: any(aAny)
{
diff --git a/io/source/acceptor/acceptor.cxx b/io/source/acceptor/acceptor.cxx
index 217c23b9a845..d1f2bb54bf40 100644
--- a/io/source/acceptor/acceptor.cxx
+++ b/io/source/acceptor/acceptor.cxx
@@ -46,6 +46,8 @@ using namespace ::com::sun::star::connection;
namespace io_acceptor
{
+ namespace {
+
class OAcceptor : public WeakImplHelper< XAcceptor, XServiceInfo >
{
public:
@@ -73,6 +75,7 @@ namespace io_acceptor
Reference<XAcceptor> _xAcceptor;
};
+ }
OAcceptor::OAcceptor( const Reference< XComponentContext > & xCtx )
: m_bInAccept( false )
@@ -85,6 +88,8 @@ namespace io_acceptor
m_pPipe.reset();
}
+ namespace {
+
struct BeingInAccept
{
/// @throws AlreadyAcceptingException
@@ -102,6 +107,8 @@ namespace io_acceptor
bool *m_pFlag;
};
+ }
+
Reference< XConnection > OAcceptor::accept( const OUString &sConnectionDescription )
{
// if there is a thread already accepting in this object, throw an exception.
diff --git a/io/source/connector/connector.cxx b/io/source/connector/connector.cxx
index c21a34d17eac..0f4792f3aa8e 100644
--- a/io/source/connector/connector.cxx
+++ b/io/source/connector/connector.cxx
@@ -45,6 +45,8 @@ using namespace ::com::sun::star::connection;
namespace stoc_connector
{
+ namespace {
+
class OConnector : public WeakImplHelper< XConnector, XServiceInfo >
{
Reference< XMultiComponentFactory > _xSMgr;
@@ -62,6 +64,8 @@ namespace stoc_connector
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
};
+ }
+
OConnector::OConnector(const Reference< XComponentContext > &xCtx)
: _xSMgr( xCtx->getServiceManager() )
, _xCtx( xCtx )
diff --git a/io/source/connector/ctr_socket.cxx b/io/source/connector/ctr_socket.cxx
index ada34a6e2016..164cd4f6f31c 100644
--- a/io/source/connector/ctr_socket.cxx
+++ b/io/source/connector/ctr_socket.cxx
@@ -53,6 +53,8 @@ namespace stoc_connector {
xStreamListener->started();
}
+ namespace {
+
struct callError {
const Any & any;
@@ -61,6 +63,8 @@ namespace stoc_connector {
void operator () (const Reference<XStreamListener>& xStreamListener);
};
+ }
+
callError::callError(const Any & aAny)
: any(aAny)
{
diff --git a/io/source/stm/odata.cxx b/io/source/stm/odata.cxx
index 0c1dd29f9bb1..6ffd12c89387 100644
--- a/io/source/stm/odata.cxx
+++ b/io/source/stm/odata.cxx
@@ -49,6 +49,8 @@ using namespace ::com::sun::star::lang;
namespace io_stm {
+namespace {
+
class ODataInputStream :
public WeakImplHelper <
XDataInputStream,
@@ -106,6 +108,8 @@ protected:
bool m_bValidStream;
};
+}
+
// XInputStream
sal_Int32 ODataInputStream::readBytes(Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead)
{
@@ -428,6 +432,7 @@ Sequence<OUString> ODataInputStream_getSupportedServiceNames()
return aRet;
}
+namespace {
class ODataOutputStream :
public WeakImplHelper <
@@ -480,6 +485,8 @@ protected:
bool m_bValidStream;
};
+}
+
// XOutputStream
void ODataOutputStream::writeBytes(const Sequence< sal_Int8 >& aData)
{
@@ -732,6 +739,7 @@ Sequence<OUString> ODataOutputStream_getSupportedServiceNames()
return aRet;
}
+namespace {
struct equalObjectContainer_Impl
{
@@ -751,6 +759,8 @@ struct hashObjectContainer_Impl
}
};
+}
+
typedef std::unordered_map
<
Reference< XInterface >,
@@ -759,6 +769,8 @@ typedef std::unordered_map
equalObjectContainer_Impl
> ObjectContainer_Impl;
+namespace {
+
class OObjectOutputStream:
public ImplInheritanceHelper<
ODataOutputStream, /* parent */
@@ -827,6 +839,8 @@ private:
bool m_bValidMarkable;
};
+}
+
void OObjectOutputStream::writeObject( const Reference< XPersistObject > & xPObj )
{
@@ -998,6 +1012,8 @@ Sequence< OUString > OObjectOutputStream::getSupportedServiceNames()
return OObjectOutputStream_getSupportedServiceNames();
}
+namespace {
+
class OObjectInputStream:
public ImplInheritanceHelper<
ODataInputStream, /* parent */
@@ -1073,6 +1089,8 @@ private:
};
+}
+
Reference< XPersistObject > OObjectInputStream::readObject()
{
// check if chain contains a XMarkableStream
diff --git a/io/source/stm/omark.cxx b/io/source/stm/omark.cxx
index 19191e4a957b..7623392b4277 100644
--- a/io/source/stm/omark.cxx
+++ b/io/source/stm/omark.cxx
@@ -52,6 +52,8 @@ using namespace ::com::sun::star::lang;
namespace io_stm {
+namespace {
+
/***********************
*
* OMarkableOutputStream.
@@ -122,6 +124,8 @@ private:
Mutex m_mutex;
};
+}
+
OMarkableOutputStream::OMarkableOutputStream( )
: m_bValidStream(false)
, m_pBuffer( new MemRingBuffer )
@@ -386,6 +390,7 @@ Sequence<OUString> OMarkableOutputStream_getSupportedServiceNames()
// XMarkableInputStream
+namespace {
class OMarkableInputStream :
public WeakImplHelper
@@ -448,6 +453,8 @@ private:
Mutex m_mutex;
};
+}
+
OMarkableInputStream::OMarkableInputStream()
: m_bValidStream(false)
, m_nCurrentPos(0)
diff --git a/io/source/stm/opipe.cxx b/io/source/stm/opipe.cxx
index 4815a69bc862..07331472d5e5 100644
--- a/io/source/stm/opipe.cxx
+++ b/io/source/stm/opipe.cxx
@@ -52,6 +52,8 @@ namespace com::sun::star::uno { class XComponentContext; }
namespace io_stm{
+namespace {
+
class OPipeImpl :
public WeakImplHelper< XPipe , XConnectable , XServiceInfo >
{
@@ -98,6 +100,7 @@ private:
std::unique_ptr<MemFIFO> m_pFIFO;
};
+}
OPipeImpl::OPipeImpl()
: m_nBytesToSkip(0 )
diff --git a/io/source/stm/opump.cxx b/io/source/stm/opump.cxx
index fc6ba14c8488..29f09bdd3e81 100644
--- a/io/source/stm/opump.cxx
+++ b/io/source/stm/opump.cxx
@@ -46,6 +46,8 @@ using namespace com::sun::star::io;
namespace io_stm {
+ namespace {
+
class Pump : public WeakImplHelper<
XActiveDataSource, XActiveDataSink, XActiveDataControl, XConnectable, XServiceInfo >
{
@@ -98,6 +100,8 @@ namespace io_stm {
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
};
+ }
+
Pump::Pump() : m_aThread( nullptr ),
m_cnt( m_aMutex ),
m_closeFired( false )