summaryrefslogtreecommitdiff
path: root/svtools
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 /svtools
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 'svtools')
-rw-r--r--svtools/source/control/ctrltool.cxx6
-rw-r--r--svtools/source/control/tabbar.cxx4
-rw-r--r--svtools/source/dialogs/addresstemplate.cxx9
-rw-r--r--svtools/source/dialogs/insdlg.cxx3
-rw-r--r--svtools/source/misc/acceleratorexecute.cxx3
-rw-r--r--svtools/source/misc/embedhlp.cxx4
-rw-r--r--svtools/source/misc/imagemgr.cxx8
-rw-r--r--svtools/source/misc/imageresourceaccess.cxx4
-rw-r--r--svtools/source/misc/langhelp.cxx4
-rw-r--r--svtools/source/misc/langtab.cxx3
-rw-r--r--svtools/source/misc/templatefoldercache.cxx10
-rw-r--r--svtools/source/svhtml/htmlkywd.cxx5
-rw-r--r--svtools/source/svrtf/rtfkeywd.cxx4
-rw-r--r--svtools/source/table/cellvalueconversion.cxx10
-rw-r--r--svtools/source/table/gridtablerenderer.cxx4
-rw-r--r--svtools/source/table/tablecontrol_impl.cxx4
-rw-r--r--svtools/source/uno/generictoolboxcontroller.cxx4
-rw-r--r--svtools/source/uno/popupmenucontrollerbase.cxx4
-rw-r--r--svtools/source/uno/treecontrolpeer.cxx9
-rw-r--r--svtools/source/uno/unoimap.cxx7
20 files changed, 98 insertions, 11 deletions
diff --git a/svtools/source/control/ctrltool.cxx b/svtools/source/control/ctrltool.cxx
index 957e153e916a..0e8e84174bc4 100644
--- a/svtools/source/control/ctrltool.cxx
+++ b/svtools/source/control/ctrltool.cxx
@@ -70,9 +70,11 @@ const sal_IntPtr FontList::aStdSizeAry[] =
0
};
+namespace {
+
class ImplFontListFontMetric : public FontMetric
{
- friend class FontList;
+ friend FontList;
private:
VclPtr<OutputDevice> mpDevice;
@@ -89,8 +91,6 @@ public:
OutputDevice* GetDevice() const { return mpDevice; }
};
-namespace {
-
enum class FontListFontNameType
{
NONE = 0x00,
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index b469088b3c12..cce013c60993 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -367,6 +367,8 @@ void ImplTabSizer::Paint( vcl::RenderContext& rRenderContext, const tools::Recta
aDecoView.DrawHandle(aOutputRect);
}
+namespace {
+
// Is not named Impl. as it may be both instantiated and derived from
class TabBarEdit : public Edit
{
@@ -389,6 +391,8 @@ public:
virtual void LoseFocus() override;
};
+}
+
TabBarEdit::TabBarEdit( TabBar* pParent, WinBits nWinStyle ) :
Edit( pParent, nWinStyle )
{
diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx
index 2ed288bbac99..d6f84191fa05 100644
--- a/svtools/source/dialogs/addresstemplate.cxx
+++ b/svtools/source/dialogs/addresstemplate.cxx
@@ -83,8 +83,6 @@ namespace svt
}
return selectedDataSource;
}
- }
-
// = IAssigmentData
@@ -111,6 +109,7 @@ namespace svt
virtual void setCommand(const OUString& _rCommand) = 0;
};
+ }
IAssigmentData::~IAssigmentData()
{
@@ -119,6 +118,8 @@ namespace svt
// = AssigmentTransientData
+ namespace {
+
class AssigmentTransientData : public IAssigmentData
{
protected:
@@ -145,6 +146,7 @@ namespace svt
virtual void setCommand(const OUString& _rCommand) override;
};
+ }
AssigmentTransientData::AssigmentTransientData(
const OUString& _rDataSourceName, const OUString& _rTableName,
@@ -232,6 +234,8 @@ namespace svt
// = AssignmentPersistentData
+ namespace {
+
class AssignmentPersistentData
:public ::utl::ConfigItem
,public IAssigmentData
@@ -268,6 +272,7 @@ namespace svt
void clearFieldAssignment(const OUString& _rLogicalName);
};
+ }
void AssignmentPersistentData::Notify( const css::uno::Sequence<OUString>& )
{
diff --git a/svtools/source/dialogs/insdlg.cxx b/svtools/source/dialogs/insdlg.cxx
index 2ae9eb66dc9a..75c5fb6e632a 100644
--- a/svtools/source/dialogs/insdlg.cxx
+++ b/svtools/source/dialogs/insdlg.cxx
@@ -39,6 +39,7 @@ using namespace ::com::sun::star;
// OBJECTDESCRIPTOR -> see oleidl.h
// (MS platform sdk)
+namespace {
struct OleObjectDescriptor
{
@@ -52,6 +53,8 @@ struct OleObjectDescriptor
sal_uInt32 dwSrcOfCopy;
};
+}
+
/********************** SvObjectServerList ********************************
**************************************************************************/
diff --git a/svtools/source/misc/acceleratorexecute.cxx b/svtools/source/misc/acceleratorexecute.cxx
index a9e44ba6a9f8..3648e200e7c2 100644
--- a/svtools/source/misc/acceleratorexecute.cxx
+++ b/svtools/source/misc/acceleratorexecute.cxx
@@ -38,6 +38,8 @@
namespace svt
{
+namespace {
+
class AsyncAccelExec : public cppu::WeakImplHelper<css::lang::XEventListener>
{
private:
@@ -77,6 +79,7 @@ class AsyncAccelExec : public cppu::WeakImplHelper<css::lang::XEventListener>
DECL_LINK(impl_ts_asyncCallback, LinkParamNone*, void);
};
+}
AcceleratorExecute::AcceleratorExecute()
: TMutexInit()
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index 3e270f0e8d60..2319485a65bd 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -58,6 +58,8 @@ using namespace com::sun::star;
namespace svt {
+namespace {
+
class EmbedEventListener_Impl : public ::cppu::WeakImplHelper < embed::XStateChangeListener,
document::XEventListener,
util::XModifyListener,
@@ -83,6 +85,8 @@ public:
virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
};
+}
+
rtl::Reference<EmbedEventListener_Impl> EmbedEventListener_Impl::Create( EmbeddedObjectRef* p )
{
rtl::Reference<EmbedEventListener_Impl> pRet(new EmbedEventListener_Impl( p ));
diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx
index 5fc3456d0bbd..0a36573bb9b5 100644
--- a/svtools/source/misc/imagemgr.cxx
+++ b/svtools/source/misc/imagemgr.cxx
@@ -43,6 +43,8 @@
#define NO_INDEX (-1)
#define CONTENT_HELPER ::utl::UCBContentHelper
+namespace {
+
struct SvtExtensionResIdMapping_Impl
{
const char* _pExt;
@@ -51,6 +53,8 @@ struct SvtExtensionResIdMapping_Impl
SvImageId const _nImgId;
};
+}
+
static SvtExtensionResIdMapping_Impl const ExtensionMap_Impl[] =
{
{ "awk", true, STR_DESCRIPTION_SOURCEFILE, SvImageId::NONE },
@@ -166,12 +170,16 @@ static SvtExtensionResIdMapping_Impl const ExtensionMap_Impl[] =
{ nullptr, false, nullptr, SvImageId::NONE }
};
+namespace {
+
struct SvtFactory2ExtensionMapping_Impl
{
const char* _pFactory;
const char* _pExtension;
};
+}
+
// mapping from "private:factory" url to extension
static SvtFactory2ExtensionMapping_Impl const Fac2ExtMap_Impl[] =
diff --git a/svtools/source/misc/imageresourceaccess.cxx b/svtools/source/misc/imageresourceaccess.cxx
index 829ffdb5feb5..8f07e59b999b 100644
--- a/svtools/source/misc/imageresourceaccess.cxx
+++ b/svtools/source/misc/imageresourceaccess.cxx
@@ -40,6 +40,8 @@ using namespace css;
typedef ::cppu::WeakImplHelper<io::XStream, io::XSeekable> StreamSupplier_Base;
+namespace {
+
class StreamSupplier : public StreamSupplier_Base
{
private:
@@ -61,6 +63,8 @@ protected:
virtual sal_Int64 SAL_CALL getLength() override;
};
+}
+
StreamSupplier::StreamSupplier(uno::Reference<io::XInputStream> const & rxInput, uno::Reference<io::XOutputStream> const & rxOutput)
: m_xInput(rxInput)
, m_xOutput(rxOutput)
diff --git a/svtools/source/misc/langhelp.cxx b/svtools/source/misc/langhelp.cxx
index bedd8d1205c5..b3df64fce1a1 100644
--- a/svtools/source/misc/langhelp.cxx
+++ b/svtools/source/misc/langhelp.cxx
@@ -64,6 +64,8 @@ OUString getInstalledLocaleForLanguage(css::uno::Sequence<OUString> const & inst
static std::unique_ptr<Idle> xLangpackInstaller;
+namespace {
+
class InstallLangpack : public Idle
{
std::vector<OUString> const m_aPackages;
@@ -99,6 +101,8 @@ public:
}
};
+}
+
OUString getInstalledLocaleForSystemUILanguage(const css::uno::Sequence<OUString>& rLocaleElementNames, bool bRequestInstallIfMissing, const OUString& rPreferredLocale)
{
OUString wantedLocale(rPreferredLocale);
diff --git a/svtools/source/misc/langtab.cxx b/svtools/source/misc/langtab.cxx
index 2b4311cde7f6..7c655b1f04f6 100644
--- a/svtools/source/misc/langtab.cxx
+++ b/svtools/source/misc/langtab.cxx
@@ -37,6 +37,8 @@
using namespace ::com::sun::star;
+namespace {
+
class SvtLanguageTableImpl
{
private:
@@ -71,7 +73,6 @@ public:
}
};
-namespace {
struct theLanguageTable : public rtl::Static< SvtLanguageTableImpl, theLanguageTable > {};
}
diff --git a/svtools/source/misc/templatefoldercache.cxx b/svtools/source/misc/templatefoldercache.cxx
index 7048441ecf8a..36761da02577 100644
--- a/svtools/source/misc/templatefoldercache.cxx
+++ b/svtools/source/misc/templatefoldercache.cxx
@@ -93,11 +93,18 @@ namespace svt
//= TemplateContent
+ namespace {
+
struct TemplateContent;
+
+ }
+
typedef ::std::vector< ::rtl::Reference< TemplateContent > > TemplateFolderContent;
typedef TemplateFolderContent::const_iterator ConstFolderIterator;
typedef TemplateFolderContent::iterator FolderIterator;
+ namespace {
+
/** a struct describing one content in one of the template dirs (or at least it's relevant aspects)
*/
struct TemplateContent : public ::salhelper::SimpleReferenceObject
@@ -138,6 +145,7 @@ namespace svt
{ m_aSubContents.push_back( _rxNewElement ); }
};
+ }
TemplateContent::TemplateContent( const INetURLObject& _rURL )
:m_aURL( _rURL )
@@ -154,6 +162,7 @@ namespace svt
//= stl helpers
+ namespace {
/// compares two TemplateContent by URL
struct TemplateContentURLLess
@@ -365,6 +374,7 @@ namespace svt
}
};
+ }
//= TemplateFolderCacheImpl
diff --git a/svtools/source/svhtml/htmlkywd.cxx b/svtools/source/svhtml/htmlkywd.cxx
index b3dddc650dee..70bc2ebe49c7 100644
--- a/svtools/source/svhtml/htmlkywd.cxx
+++ b/svtools/source/svhtml/htmlkywd.cxx
@@ -25,12 +25,17 @@
#include <svtools/htmltokn.h>
#include <svtools/htmlkywd.hxx>
+namespace {
+
template<typename T>
struct TokenEntry
{
OUStringLiteral sToken;
T nToken;
};
+
+}
+
template<typename T>
static bool sortCompare(const TokenEntry<T> & lhs, const TokenEntry<T> & rhs)
{
diff --git a/svtools/source/svrtf/rtfkeywd.cxx b/svtools/source/svrtf/rtfkeywd.cxx
index 5fdfbb26387b..410aa5d3791c 100644
--- a/svtools/source/svrtf/rtfkeywd.cxx
+++ b/svtools/source/svrtf/rtfkeywd.cxx
@@ -24,6 +24,8 @@
#include <algorithm>
#include <string.h>
+namespace {
+
// the table is still to be sorted
struct RTF_TokenEntry
{
@@ -31,6 +33,8 @@ struct RTF_TokenEntry
int nToken;
};
+}
+
// Flag: RTF-token table has been sorted
static bool bSortKeyWords = false;
diff --git a/svtools/source/table/cellvalueconversion.cxx b/svtools/source/table/cellvalueconversion.cxx
index 948dd80580be..6219eee3efc5 100644
--- a/svtools/source/table/cellvalueconversion.cxx
+++ b/svtools/source/table/cellvalueconversion.cxx
@@ -74,11 +74,12 @@ namespace svt
{
return tools::Time( i_hours, i_minutes, i_seconds, i_100thSeconds ).GetTimeInDays();
}
- }
-
//= CellValueConversion_Data
class StandardFormatNormalizer;
+
+ }
+
struct CellValueConversion_Data
{
typedef std::unordered_map< OUString, std::shared_ptr< StandardFormatNormalizer > > NormalizerCache;
@@ -98,6 +99,8 @@ namespace svt
//= StandardFormatNormalizer
+ namespace {
+
class StandardFormatNormalizer
{
public:
@@ -285,9 +288,6 @@ namespace svt
//= operations
- namespace
- {
-
bool lcl_ensureNumberFormatter( CellValueConversion_Data & io_data )
{
if ( io_data.bAttemptedFormatterCreation )
diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx
index d28a8a7f5b49..0f58e4dec291 100644
--- a/svtools/source/table/gridtablerenderer.cxx
+++ b/svtools/source/table/gridtablerenderer.cxx
@@ -51,6 +51,8 @@ namespace svt { namespace table
//= CachedSortIndicator
+ namespace {
+
class CachedSortIndicator
{
public:
@@ -70,6 +72,8 @@ namespace svt { namespace table
BitmapEx m_sortDescending;
};
+ }
+
BitmapEx const & CachedSortIndicator::getBitmapFor(vcl::RenderContext const& i_device, long const i_headerHeight,
StyleSettings const & i_style, bool const i_sortAscending )
{
diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx
index 7153a8fa7838..8dfaf9d7450b 100644
--- a/svtools/source/table/tablecontrol_impl.cxx
+++ b/svtools/source/table/tablecontrol_impl.cxx
@@ -62,6 +62,8 @@ namespace svt { namespace table
//= SuppressCursor
+ namespace {
+
class SuppressCursor
{
private:
@@ -212,6 +214,8 @@ namespace svt { namespace table
}
};
+ }
+
TableControl_Impl::TableControl_Impl( TableControl& _rAntiImpl )
:m_rAntiImpl ( _rAntiImpl )
,m_pModel ( new EmptyTableModel )
diff --git a/svtools/source/uno/generictoolboxcontroller.cxx b/svtools/source/uno/generictoolboxcontroller.cxx
index f5a8d470b7b1..c4e409546018 100644
--- a/svtools/source/uno/generictoolboxcontroller.cxx
+++ b/svtools/source/uno/generictoolboxcontroller.cxx
@@ -38,6 +38,8 @@ using namespace css::util;
namespace svt
{
+namespace {
+
struct ExecuteInfo
{
css::uno::Reference< css::frame::XDispatch > xDispatch;
@@ -45,6 +47,8 @@ struct ExecuteInfo
css::uno::Sequence< css::beans::PropertyValue > aArgs;
};
+}
+
GenericToolboxController::GenericToolboxController( const Reference< XComponentContext >& rxContext,
const Reference< XFrame >& rFrame,
ToolBox* pToolbox,
diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx
index ca2510806d9f..9ce0bda33a63 100644
--- a/svtools/source/uno/popupmenucontrollerbase.cxx
+++ b/svtools/source/uno/popupmenucontrollerbase.cxx
@@ -39,6 +39,8 @@ using namespace css::util;
namespace svt
{
+namespace {
+
struct PopupMenuControllerBaseDispatchInfo
{
Reference< XDispatch > mxDispatch;
@@ -49,6 +51,8 @@ struct PopupMenuControllerBaseDispatchInfo
: mxDispatch( xDispatch ), maURL( rURL ), maArgs( rArgs ) {}
};
+}
+
PopupMenuControllerBase::PopupMenuControllerBase( const Reference< XComponentContext >& xContext ) :
::cppu::BaseMutex(),
PopupMenuControllerBaseType(m_aMutex),
diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx
index 3c5ee8c0364d..da477a40de78 100644
--- a/svtools/source/uno/treecontrolpeer.cxx
+++ b/svtools/source/uno/treecontrolpeer.cxx
@@ -52,6 +52,8 @@ using namespace css::container;
using namespace css::util;
using namespace css::graphic;
+namespace {
+
struct LockGuard
{
public:
@@ -81,6 +83,8 @@ public:
};
+}
+
class UnoTreeListBoxImpl : public SvTreeListBox
{
public:
@@ -104,6 +108,8 @@ private:
};
+namespace {
+
class UnoTreeListItem : public SvLBoxString
{
public:
@@ -122,6 +128,7 @@ private:
Image maImage;
};
+}
class UnoTreeListEntry : public SvTreeListEntry
{
@@ -562,6 +569,7 @@ sal_Int32 SAL_CALL TreeControlPeer::getSelectionCount()
return getTreeListBoxOrThrow().GetSelectionCount();
}
+namespace {
class TreeSelectionEnumeration : public ::cppu::WeakImplHelper< XEnumeration >
{
@@ -574,6 +582,7 @@ public:
std::list< Any >::iterator maIter;
};
+}
TreeSelectionEnumeration::TreeSelectionEnumeration( std::list< Any >& rSelection )
{
diff --git a/svtools/source/uno/unoimap.cxx b/svtools/source/uno/unoimap.cxx
index 265055d96dab..ef14c9487575 100644
--- a/svtools/source/uno/unoimap.cxx
+++ b/svtools/source/uno/unoimap.cxx
@@ -63,6 +63,8 @@ const sal_Int32 HANDLE_RADIUS = 8;
const sal_Int32 HANDLE_BOUNDARY = 9;
const sal_Int32 HANDLE_TITLE = 10;
+namespace {
+
class SvUnoImageMapObject : public OWeakAggObject,
public XEventsSupplier,
public XServiceInfo,
@@ -120,6 +122,8 @@ private:
PointSequence maPolygon;
};
+}
+
UNO3_GETIMPLEMENTATION_IMPL( SvUnoImageMapObject );
rtl::Reference<PropertySetInfo> SvUnoImageMapObject::createPropertySetInfo( sal_uInt16 nType )
@@ -496,6 +500,7 @@ Reference< XNameReplace > SAL_CALL SvUnoImageMapObject::getEvents()
return mxEvents.get();
}
+namespace {
class SvUnoImageMap : public WeakImplHelper< XIndexContainer, XServiceInfo, XUnoTunnel >
{
@@ -535,6 +540,8 @@ private:
std::vector< rtl::Reference<SvUnoImageMapObject> > maObjectList;
};
+}
+
UNO3_GETIMPLEMENTATION_IMPL( SvUnoImageMap );
SvUnoImageMap::SvUnoImageMap()