summaryrefslogtreecommitdiff
path: root/ucb/source
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 /ucb/source
parentf31d36966bceb90e261cbecd42634bde4448d527 (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 'ucb/source')
-rw-r--r--ucb/source/core/ucbstore.cxx3
-rw-r--r--ucb/source/ucp/ext/ucpext_datasupplier.cxx4
-rw-r--r--ucb/source/ucp/file/prov.cxx3
-rw-r--r--ucb/source/ucp/ftp/ftpcontent.cxx2
-rw-r--r--ucb/source/ucp/ftp/ftpresultsetbase.cxx2
-rw-r--r--ucb/source/ucp/gio/gio_content.cxx4
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydatasource.cxx3
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx2
-rw-r--r--ucb/source/ucp/package/pkgdatasupplier.cxx3
-rw-r--r--ucb/source/ucp/package/pkgprovider.cxx4
-rw-r--r--ucb/source/ucp/tdoc/tdoc_datasupplier.cxx2
-rw-r--r--ucb/source/ucp/tdoc/tdoc_passwordrequest.cxx4
-rw-r--r--ucb/source/ucp/webdav-neon/LinkSequence.cxx3
-rw-r--r--ucb/source/ucp/webdav-neon/LockEntrySequence.cxx3
-rw-r--r--ucb/source/ucp/webdav-neon/LockSequence.cxx4
-rw-r--r--ucb/source/ucp/webdav-neon/NeonSession.cxx8
-rw-r--r--ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx3
-rw-r--r--ucb/source/ucp/webdav-neon/webdavdatasupplier.cxx2
18 files changed, 58 insertions, 1 deletions
diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index ea5e23d38f9b..b36fc0e8ca78 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -110,6 +110,8 @@ static OUString makeHierarchalNameSegment( const OUString & rIn )
// PropertySetMap_Impl.
typedef std::unordered_map< OUString, PersistentPropertySet*> PropertySetMap_Impl;
+namespace {
+
// class PropertySetInfo_Impl
class PropertySetInfo_Impl : public cppu::WeakImplHelper < XPropertySetInfo >
{
@@ -129,6 +131,7 @@ public:
void reset() { m_pProps.reset(); }
};
+}
// UcbStore_Impl.
diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.cxx b/ucb/source/ucp/ext/ucpext_datasupplier.cxx
index 4fdfef7bbc49..acb415f3d903 100644
--- a/ucb/source/ucp/ext/ucpext_datasupplier.cxx
+++ b/ucb/source/ucp/ext/ucpext_datasupplier.cxx
@@ -59,6 +59,8 @@ namespace ucb { namespace ucp { namespace ext
//= ResultListEntry
+ namespace {
+
struct ResultListEntry
{
OUString sId;
@@ -67,6 +69,8 @@ namespace ucb { namespace ucp { namespace ext
Reference< XRow > xRow;
};
+ }
+
typedef ::std::vector< ResultListEntry > ResultList;
diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx
index 937487e749cc..0cdbacaba61e 100644
--- a/ucb/source/ucp/file/prov.cxx
+++ b/ucb/source/ucp/file/prov.cxx
@@ -245,6 +245,8 @@ FileProvider::createContentIdentifier(
//XPropertySetInfoImpl
+namespace {
+
class XPropertySetInfoImpl2
: public cppu::OWeakObject,
public XPropertySetInfo
@@ -279,6 +281,7 @@ private:
Sequence< Property > m_seq;
};
+}
XPropertySetInfoImpl2::XPropertySetInfoImpl2()
: m_seq( 3 )
diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx
index eede2a33b6bd..e655c6cbe162 100644
--- a/ucb/source/ucp/ftp/ftpcontent.cxx
+++ b/ucb/source/ucp/ftp/ftpcontent.cxx
@@ -626,6 +626,7 @@ OUString FTPContent::getParentURL()
return m_aFTPURL.parent();
}
+namespace {
class InsertData
: public CurlInput {
@@ -644,6 +645,7 @@ private:
Reference<XInputStream> m_xInputStream;
};
+}
sal_Int32 InsertData::read(sal_Int8 *dest,sal_Int32 nBytesRequested)
{
diff --git a/ucb/source/ucp/ftp/ftpresultsetbase.cxx b/ucb/source/ucp/ftp/ftpresultsetbase.cxx
index f777dad67a5b..cb3d017af7d3 100644
--- a/ucb/source/ucp/ftp/ftpresultsetbase.cxx
+++ b/ucb/source/ucp/ftp/ftpresultsetbase.cxx
@@ -333,6 +333,7 @@ ResultSetBase::queryContent()
return uno::Reference< ucb::XContent >();
}
+namespace {
class XPropertySetInfoImpl
: public cppu::OWeakObject,
@@ -391,6 +392,7 @@ private:
uno::Sequence< beans::Property > m_aSeq;
};
+}
// XPropertySet
uno::Reference< beans::XPropertySetInfo > SAL_CALL
diff --git a/ucb/source/ucp/gio/gio_content.cxx b/ucb/source/ucp/gio/gio_content.cxx
index 05c26c42760f..77a5c0127ae7 100644
--- a/ucb/source/ucp/gio/gio_content.cxx
+++ b/ucb/source/ucp/gio/gio_content.cxx
@@ -304,6 +304,8 @@ css::uno::Any Content::getBadArgExcept()
static_cast< cppu::OWeakObject * >( this ), -1) );
}
+namespace {
+
class MountOperation
{
ucb::ucp::gio::glib::MainContextRef mContext;
@@ -317,6 +319,8 @@ public:
GError *Mount(GFile *pFile);
};
+}
+
MountOperation::MountOperation(const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv) : mpError(nullptr)
{
ucb::ucp::gio::glib::MainContextRef oldContext(g_main_context_ref_thread_default());
diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
index 004c27a5f2c1..d9571c758e86 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
@@ -61,6 +61,7 @@ namespace hcp_impl
// HierarchyDataReadAccess Implementation.
+namespace {
class HierarchyDataAccess : public cppu::OWeakObject,
public lang::XServiceInfo,
@@ -171,6 +172,8 @@ private:
css::uno::Reference<T> ensureOrigInterface(css::uno::Reference<T>& x);
};
+}
+
} // namespace hcp_impl
using namespace hcp_impl;
diff --git a/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx b/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx
index c31eb075227c..fc1a0f0d9b64 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx
@@ -42,6 +42,7 @@ namespace hierarchy_ucp
// struct ResultListEntry.
+namespace {
struct ResultListEntry
{
@@ -54,6 +55,7 @@ struct ResultListEntry
explicit ResultListEntry( const HierarchyEntryData& rEntry ) : aData( rEntry ) {}
};
+}
// ResultList.
diff --git a/ucb/source/ucp/package/pkgdatasupplier.cxx b/ucb/source/ucp/package/pkgdatasupplier.cxx
index 71d58c777bb4..596282b6a1f6 100644
--- a/ucb/source/ucp/package/pkgdatasupplier.cxx
+++ b/ucb/source/ucp/package/pkgdatasupplier.cxx
@@ -47,6 +47,7 @@ namespace package_ucp
// struct ResultListEntry.
+namespace {
struct ResultListEntry
{
@@ -58,6 +59,8 @@ struct ResultListEntry
explicit ResultListEntry( const OUString& rURL ) : aURL( rURL ) {}
};
+}
+
// struct DataSupplier_Impl.
diff --git a/ucb/source/ucp/package/pkgprovider.cxx b/ucb/source/ucp/package/pkgprovider.cxx
index ea4549a32268..609ce5b40671 100644
--- a/ucb/source/ucp/package/pkgprovider.cxx
+++ b/ucb/source/ucp/package/pkgprovider.cxx
@@ -47,11 +47,12 @@ namespace package_ucp
// class Package.
+namespace {
class Package : public cppu::OWeakObject,
public container::XHierarchicalNameAccess
{
- friend class ContentProvider;
+ friend ContentProvider;
OUString const m_aName;
uno::Reference< container::XHierarchicalNameAccess > m_xNA;
@@ -84,6 +85,7 @@ public:
{ return m_xNA->hasByHierarchicalName( aName ); }
};
+}
class Packages : public std::unordered_map<OUString, Package*> {};
diff --git a/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx b/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx
index 6f4c65582ec1..218fc117e44e 100644
--- a/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx
@@ -43,6 +43,7 @@ namespace tdoc_ucp
// struct ResultListEntry.
+namespace {
struct ResultListEntry
{
@@ -54,6 +55,7 @@ struct ResultListEntry
explicit ResultListEntry( const OUString& rURL ) : aURL( rURL ) {}
};
+}
// struct DataSupplier_Impl.
diff --git a/ucb/source/ucp/tdoc/tdoc_passwordrequest.cxx b/ucb/source/ucp/tdoc/tdoc_passwordrequest.cxx
index 0312840c3f36..cac1eaaf61e3 100644
--- a/ucb/source/ucp/tdoc/tdoc_passwordrequest.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_passwordrequest.cxx
@@ -35,6 +35,8 @@ using namespace tdoc_ucp;
namespace tdoc_ucp
{
+ namespace {
+
class InteractionSupplyPassword :
public ucbhelper::InteractionContinuation,
public lang::XTypeProvider,
@@ -66,6 +68,8 @@ namespace tdoc_ucp
osl::Mutex m_aMutex;
OUString m_aPassword;
};
+
+ }
} // namespace tdoc_ucp
diff --git a/ucb/source/ucp/webdav-neon/LinkSequence.cxx b/ucb/source/ucp/webdav-neon/LinkSequence.cxx
index 361e1a27fbd7..ea49352d93ba 100644
--- a/ucb/source/ucp/webdav-neon/LinkSequence.cxx
+++ b/ucb/source/ucp/webdav-neon/LinkSequence.cxx
@@ -36,6 +36,7 @@
using namespace webdav_ucp;
using namespace com::sun::star;
+namespace {
struct LinkSequenceParseContext
{
@@ -47,6 +48,8 @@ struct LinkSequenceParseContext
: hasSource( false ), hasDestination( false ) {}
};
+}
+
#define STATE_TOP (1)
#define STATE_LINK (STATE_TOP)
diff --git a/ucb/source/ucp/webdav-neon/LockEntrySequence.cxx b/ucb/source/ucp/webdav-neon/LockEntrySequence.cxx
index 0023769bcc9a..61be4420c7b9 100644
--- a/ucb/source/ucp/webdav-neon/LockEntrySequence.cxx
+++ b/ucb/source/ucp/webdav-neon/LockEntrySequence.cxx
@@ -35,6 +35,7 @@
using namespace webdav_ucp;
using namespace com::sun::star;
+namespace {
struct LockEntrySequenceParseContext
{
@@ -46,6 +47,8 @@ struct LockEntrySequenceParseContext
: hasScope( false ), hasType( false ) {}
};
+}
+
#define STATE_TOP (1)
#define STATE_LOCKENTRY (STATE_TOP)
diff --git a/ucb/source/ucp/webdav-neon/LockSequence.cxx b/ucb/source/ucp/webdav-neon/LockSequence.cxx
index 917945824d11..b9399c60d64e 100644
--- a/ucb/source/ucp/webdav-neon/LockSequence.cxx
+++ b/ucb/source/ucp/webdav-neon/LockSequence.cxx
@@ -36,6 +36,8 @@
using namespace webdav_ucp;
using namespace com::sun::star;
+namespace {
+
struct LockSequenceParseContext
{
std::unique_ptr<ucb::Lock> pLock;
@@ -50,6 +52,8 @@ struct LockSequenceParseContext
hasDepth( false ), hasHREF( false ), hasTimeout( false ) {}
};
+}
+
#define STATE_TOP (1)
#define STATE_ACTIVELOCK (STATE_TOP)
diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx
index cdd703615b4c..56f813a8c1fb 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx
@@ -79,6 +79,8 @@ using namespace webdav_ucp;
# define EOL "\r\n"
#endif
+namespace {
+
struct RequestData
{
// POST
@@ -107,6 +109,8 @@ struct hashPtr
}
};
+}
+
typedef std::unordered_map
<
ne_request*,
@@ -149,6 +153,8 @@ static bool noKeepAlive( const uno::Sequence< beans::NamedValue >& rFlags )
return pValue != rFlags.end() && !pValue->Value.get<bool>();
}
+namespace {
+
struct NeonRequestContext
{
uno::Reference< io::XOutputStream > xOutputStream;
@@ -193,6 +199,8 @@ struct NeonRequestContext
};
+}
+
// A simple Neon response_block_reader for use with an XInputStream
extern "C" {
diff --git a/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx b/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx
index 659bf5d49cc1..6a06f0dcb9ba 100644
--- a/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx
+++ b/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx
@@ -37,6 +37,7 @@
using namespace webdav_ucp;
using namespace com::sun::star;
+namespace {
struct UCBDeadPropertyValueParseContext
{
@@ -46,6 +47,8 @@ struct UCBDeadPropertyValueParseContext
UCBDeadPropertyValueParseContext() {}
};
+}
+
static const char aTypeString[] = "string";
static const char aTypeLong[] = "long";
static const char aTypeShort[] = "short";
diff --git a/ucb/source/ucp/webdav-neon/webdavdatasupplier.cxx b/ucb/source/ucp/webdav-neon/webdavdatasupplier.cxx
index 00085956aa3c..062cf2d5683f 100644
--- a/ucb/source/ucp/webdav-neon/webdavdatasupplier.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavdatasupplier.cxx
@@ -55,6 +55,7 @@ namespace webdav_ucp
// struct ResultListEntry.
+namespace {
struct ResultListEntry
{
@@ -69,6 +70,7 @@ struct ResultListEntry
{}
};
+}
// ResultList.