summaryrefslogtreecommitdiff
path: root/unotools
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 /unotools
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 'unotools')
-rw-r--r--unotools/source/config/cmdoptions.cxx4
-rw-r--r--unotools/source/config/configitem.cxx4
-rw-r--r--unotools/source/config/configvaluecontainer.cxx4
-rw-r--r--unotools/source/config/defaultoptions.cxx4
-rw-r--r--unotools/source/config/dynamicmenuoptions.cxx8
-rw-r--r--unotools/source/config/fltrcfg.cxx12
-rw-r--r--unotools/source/config/fontcfg.cxx20
-rw-r--r--unotools/source/config/lingucfg.cxx10
-rw-r--r--unotools/source/config/moduleoptions.cxx4
-rw-r--r--unotools/source/config/pathoptions.cxx4
-rw-r--r--unotools/source/config/saveopt.cxx12
-rw-r--r--unotools/source/misc/closeveto.cxx5
-rw-r--r--unotools/source/misc/fontcvt.cxx8
-rw-r--r--unotools/source/misc/fontdefs.cxx4
-rw-r--r--unotools/source/ucbhelper/tempfile.cxx4
-rw-r--r--unotools/source/ucbhelper/ucblockbytes.cxx12
16 files changed, 117 insertions, 2 deletions
diff --git a/unotools/source/config/cmdoptions.cxx b/unotools/source/config/cmdoptions.cxx
index 56b61ad2704a..5826eb0ac082 100644
--- a/unotools/source/config/cmdoptions.cxx
+++ b/unotools/source/config/cmdoptions.cxx
@@ -47,6 +47,8 @@ using namespace ::com::sun::star::beans;
#define PROPERTYNAME_CMD "Command"
+namespace {
+
/*-****************************************************************************************************************
@descr support simple command option structures and operations on it
****************************************************************************************************************-*/
@@ -83,6 +85,8 @@ class SvtCmdOptions
CommandHashMap m_aCommandHashMap;
};
+}
+
typedef ::std::vector< css::uno::WeakReference< css::frame::XFrame > > SvtFrameVector;
class SvtCommandOptions_Impl : public ConfigItem
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx
index 8ed1d317a09c..5de369999fc3 100644
--- a/unotools/source/config/configitem.cxx
+++ b/unotools/source/config/configitem.cxx
@@ -76,6 +76,8 @@ namespace utl{
};
}
+namespace {
+
class ValueCounter_Impl
{
sal_Int16& rCnt;
@@ -92,6 +94,8 @@ public:
}
};
+}
+
ConfigChangeListener_Impl::ConfigChangeListener_Impl(
ConfigItem& rItem, const Sequence< OUString >& rNames) :
pParent(&rItem),
diff --git a/unotools/source/config/configvaluecontainer.cxx b/unotools/source/config/configvaluecontainer.cxx
index 780a59d99926..01a974bcecf2 100644
--- a/unotools/source/config/configvaluecontainer.cxx
+++ b/unotools/source/config/configvaluecontainer.cxx
@@ -140,6 +140,8 @@ namespace utl
//= functors on NodeValueAccessor instances
+ namespace {
+
/// base class for functors synchronizing between exchange locations and config sub nodes
struct SubNodeAccess
{
@@ -179,6 +181,8 @@ namespace utl
}
};
+ }
+
//= OConfigurationValueContainerImpl
struct OConfigurationValueContainerImpl
diff --git a/unotools/source/config/defaultoptions.cxx b/unotools/source/config/defaultoptions.cxx
index dddbd22d3b13..b3c9dca8e38b 100644
--- a/unotools/source/config/defaultoptions.cxx
+++ b/unotools/source/config/defaultoptions.cxx
@@ -110,12 +110,16 @@ std::weak_ptr<SvtDefaultOptions_Impl> g_pOptions;
typedef OUString SvtDefaultOptions_Impl:: *PathStrPtr;
+namespace {
+
struct PathToDefaultMapping_Impl
{
SvtPathOptions::Paths const _ePath;
PathStrPtr const _pDefaultPath;
};
+}
+
static PathToDefaultMapping_Impl const PathMap_Impl[] =
{
{ SvtPathOptions::PATH_ADDIN, &SvtDefaultOptions_Impl::m_aAddinPath },
diff --git a/unotools/source/config/dynamicmenuoptions.cxx b/unotools/source/config/dynamicmenuoptions.cxx
index fe7f31d6b96a..019ca1b86407 100644
--- a/unotools/source/config/dynamicmenuoptions.cxx
+++ b/unotools/source/config/dynamicmenuoptions.cxx
@@ -59,6 +59,8 @@ using namespace ::com::sun::star::beans;
#define PATHPREFIX_SETUP "m"
+namespace {
+
/*-****************************************************************************************************************
@descr struct to hold information about one menu entry.
****************************************************************************************************************-*/
@@ -139,6 +141,8 @@ class SvtDynMenu
vector< SvtDynMenuEntry > lUserEntries;
};
+}
+
class SvtDynamicMenuOptions_Impl : public ConfigItem
{
public:
@@ -440,6 +444,8 @@ Sequence< OUString > SvtDynamicMenuOptions_Impl::impl_GetPropertyNames( sal_uInt
// private helper
+namespace {
+
class CountWithPrefixSort
{
public:
@@ -467,6 +473,8 @@ class SelectByPrefix
}
};
+}
+
// private method
void SvtDynamicMenuOptions_Impl::impl_SortAndExpandPropertyNames( const Sequence< OUString >& lSource ,
diff --git a/unotools/source/config/fltrcfg.cxx b/unotools/source/config/fltrcfg.cxx
index 92ec14e0dd14..c68ac827ee79 100644
--- a/unotools/source/config/fltrcfg.cxx
+++ b/unotools/source/config/fltrcfg.cxx
@@ -64,6 +64,8 @@ namespace o3tl {
template<> struct typed_flags<ConfigFlags> : is_typed_flags<ConfigFlags, 0xe7fff3f> {};
}
+namespace {
+
class SvtAppFilterOptions_Impl : public utl::ConfigItem
{
private:
@@ -98,6 +100,8 @@ public:
}
};
+}
+
SvtAppFilterOptions_Impl::~SvtAppFilterOptions_Impl()
{
assert(!IsModified()); // should have been committed
@@ -130,6 +134,8 @@ void SvtAppFilterOptions_Impl::Load()
bSaveVBA = *o3tl::doAccess<bool>(pValues[1]);
}
+namespace {
+
class SvtWriterFilterOptions_Impl : public SvtAppFilterOptions_Impl
{
private:
@@ -153,6 +159,8 @@ public:
}
};
+}
+
void SvtWriterFilterOptions_Impl::ImplCommit()
{
SvtAppFilterOptions_Impl::ImplCommit();
@@ -176,6 +184,8 @@ void SvtWriterFilterOptions_Impl::Load()
bLoadExecutable = *o3tl::doAccess<bool>(pValues[0]);
}
+namespace {
+
class SvtCalcFilterOptions_Impl : public SvtAppFilterOptions_Impl
{
private:
@@ -199,6 +209,8 @@ public:
}
};
+}
+
void SvtCalcFilterOptions_Impl::ImplCommit()
{
SvtAppFilterOptions_Impl::ImplCommit();
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index bd7f7e21330b..1da36a7e978c 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -448,12 +448,16 @@ static const char* const aImplKillTrailingWithExceptionsList[] =
nullptr
};
+namespace {
+
struct ImplFontAttrWeightSearchData
{
const char* mpStr;
FontWeight const meWeight;
};
+}
+
static ImplFontAttrWeightSearchData const aImplWeightAttrSearchList[] =
{
// the attribute names are ordered by "first match wins"
@@ -474,12 +478,16 @@ static ImplFontAttrWeightSearchData const aImplWeightAttrSearchList[] =
{ nullptr, WEIGHT_DONTKNOW },
};
+namespace {
+
struct ImplFontAttrWidthSearchData
{
const char* mpStr;
FontWidth const meWidth;
};
+}
+
static ImplFontAttrWidthSearchData const aImplWidthAttrSearchList[] =
{
{ "narrow", WIDTH_CONDENSED },
@@ -495,12 +503,16 @@ static ImplFontAttrWidthSearchData const aImplWidthAttrSearchList[] =
{ nullptr, WIDTH_DONTKNOW },
};
+namespace {
+
struct ImplFontAttrTypeSearchData
{
const char* mpStr;
ImplFontAttrs const mnType;
};
+}
+
static ImplFontAttrTypeSearchData const aImplTypeAttrSearchList[] =
{
{ "monotype", ImplFontAttrs::None },
@@ -734,12 +746,16 @@ void FontSubstConfiguration::getMapName( const OUString& rOrgName, OUString& rSh
}
}
+namespace {
+
struct StrictStringSort
{
bool operator()( const FontNameAttr& rLeft, const FontNameAttr& rRight )
{ return rLeft.Name.compareTo( rRight.Name ) < 0; }
};
+}
+
// The entries in this table must match the bits in the ImplFontAttrs enum.
static const char* const pAttribNames[] =
@@ -778,12 +794,16 @@ static const char* const pAttribNames[] =
"other"
};
+namespace {
+
struct enum_convert
{
const char* pName;
int const nEnum;
};
+}
+
static const enum_convert pWeightNames[] =
{
{ "normal", WEIGHT_NORMAL },
diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx
index 7c7a6b700cc8..0bbd036b6255 100644
--- a/unotools/source/config/lingucfg.cxx
+++ b/unotools/source/config/lingucfg.cxx
@@ -208,12 +208,18 @@ void SvtLinguConfigItem::ImplCommit()
SaveOptions( GetPropertyNames() );
}
-static struct NamesToHdl
+namespace {
+
+struct NamesToHdl
{
const char *pFullPropName; // full qualified name as used in configuration
const char *pPropName; // property name only (atom) of above
sal_Int32 const nHdl; // numeric handle representing the property
-} const aNamesToHdl[] =
+};
+
+}
+
+static NamesToHdl const aNamesToHdl[] =
{
{/* 0 */ "General/DefaultLocale", UPN_DEFAULT_LOCALE, UPH_DEFAULT_LOCALE},
{/* 1 */ "General/DictionaryList/ActiveDictionaries", UPN_ACTIVE_DICTIONARIES, UPH_ACTIVE_DICTIONARIES},
diff --git a/unotools/source/config/moduleoptions.cxx b/unotools/source/config/moduleoptions.cxx
index c6442a16ab9e..be70d4d7e0c1 100644
--- a/unotools/source/config/moduleoptions.cxx
+++ b/unotools/source/config/moduleoptions.cxx
@@ -82,6 +82,8 @@
#define FACTORYCOUNT 11
+namespace {
+
/*-************************************************************************************************************
@descr This struct hold information about one factory. We declare a complete array which can hold infos
for all well known factories. Values of enum "EFactory" (see header!) are directly used as index!
@@ -224,6 +226,8 @@ struct FactoryInfo
css::uno::Reference< css::util::XStringSubstitution > xSubstVars;
};
+}
+
class SvtModuleOptions_Impl : public ::utl::ConfigItem
{
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index b6e5006ce39c..f54b388d50a3 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -151,6 +151,8 @@ class SvtPathOptions_Impl
static std::weak_ptr<SvtPathOptions_Impl> g_pOptions;
+namespace {
+
// functions -------------------------------------------------------------
struct PropertyStruct
{
@@ -163,6 +165,8 @@ struct VarNameAttribute
const char* pVarName; // The name of the path variable
};
+}
+
static const PropertyStruct aPropNames[] =
{
{ "Addin", SvtPathOptions::PATH_ADDIN },
diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx
index 6c8922edf706..82f63887932d 100644
--- a/unotools/source/config/saveopt.cxx
+++ b/unotools/source/config/saveopt.cxx
@@ -35,9 +35,13 @@
using namespace utl;
using namespace com::sun::star::uno;
+namespace {
+
class SvtSaveOptions_Impl;
class SvtLoadOptions_Impl;
+}
+
#define CFG_READONLY_DEFAULT false
struct SvtLoadSaveOptions_Impl
@@ -49,6 +53,8 @@ struct SvtLoadSaveOptions_Impl
static std::unique_ptr<SvtLoadSaveOptions_Impl> pOptions;
static sal_Int32 nRefCount = 0;
+namespace {
+
class SvtSaveOptions_Impl : public utl::ConfigItem
{
sal_Int32 nAutoSaveTime;
@@ -128,6 +134,8 @@ public:
bool IsReadOnly( SvtSaveOptions::EOption eOption ) const;
};
+}
+
void SvtSaveOptions_Impl::SetAutoSaveTime( sal_Int32 n )
{
if (!bROAutoSaveTime && nAutoSaveTime!=n)
@@ -686,6 +694,8 @@ void SvtSaveOptions_Impl::Notify( const Sequence<OUString>& )
{
}
+namespace {
+
class SvtLoadOptions_Impl : public utl::ConfigItem
{
private:
@@ -702,6 +712,8 @@ public:
bool IsLoadUserSettings() const {return bLoadUserDefinedSettings;}
};
+}
+
const sal_Char cUserDefinedSettings[] = "UserDefinedSettings";
SvtLoadOptions_Impl::SvtLoadOptions_Impl()
diff --git a/unotools/source/misc/closeveto.cxx b/unotools/source/misc/closeveto.cxx
index d47ecb500f86..92ef895bf931 100644
--- a/unotools/source/misc/closeveto.cxx
+++ b/unotools/source/misc/closeveto.cxx
@@ -43,6 +43,9 @@ namespace utl
typedef ::cppu::WeakImplHelper < XCloseListener
> CloseListener_Base;
+
+ namespace {
+
class CloseListener_Impl : public CloseListener_Base
{
public:
@@ -69,6 +72,8 @@ namespace utl
bool m_bHasOwnership;
};
+ }
+
void SAL_CALL CloseListener_Impl::queryClosing( const EventObject&, sal_Bool i_deliverOwnership )
{
if ( !m_bHasOwnership )
diff --git a/unotools/source/misc/fontcvt.cxx b/unotools/source/misc/fontcvt.cxx
index d9d80ce2e2de..6a04e7d612a9 100644
--- a/unotools/source/misc/fontcvt.cxx
+++ b/unotools/source/misc/fontcvt.cxx
@@ -1027,6 +1027,8 @@ const char * const aSymbolNames[] =
"Wingdings 3", "MT Extra", "Times New Roman"
};
+namespace {
+
struct SymbolEntry
{
sal_uInt8 cIndex;
@@ -1044,6 +1046,8 @@ public:
struct ExtraTable { sal_Unicode cStar; sal_uInt8 cMS;};
+}
+
ExtraTable const aWingDingsExtraTab[] =
{
{0x25cf, 0x6C}, {0x2714, 0xFC}, {0x2717, 0xFB}, {0x2794, 0xE8},
@@ -1304,8 +1308,12 @@ void ConvertChar::RecodeString( OUString& rStr, sal_Int32 nIndex, sal_Int32 nLen
rStr = aTmpStr.makeStringAndClear();
}
+namespace {
+
struct RecodeTable { const char* pOrgName; ConvertChar aCvt;};
+}
+
static const RecodeTable aStarSymbolRecodeTable[] =
{
// the first two entries must be StarMath and StarBats; do not reorder!
diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx
index c8c05c94fe59..3e0b78a37f39 100644
--- a/unotools/source/misc/fontdefs.cxx
+++ b/unotools/source/misc/fontdefs.cxx
@@ -22,12 +22,16 @@
#include <rtl/ustrbuf.hxx>
#include <unordered_map>
+namespace {
+
struct ImplLocalizedFontName
{
const char* mpEnglishName;
const sal_Unicode* mpLocalizedNames;
};
+}
+
// TODO: where did the 0,0 delimiters come from? A single 0 should suffice...
static sal_Unicode const aBatang[] = { 0xBC14, 0xD0D5, 0, 0 };
static sal_Unicode const aBatangChe[] = { 0xBC14, 0xD0D5, 0xCCB4, 0, 0 };
diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx
index bce71120f4f9..b168957055ce 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -163,6 +163,8 @@ static OUString ConstructTempDir_Impl( const OUString* pParent )
return aName;
}
+namespace {
+
class Tokens {
public:
virtual bool next(OUString *) = 0;
@@ -226,6 +228,8 @@ private:
sal_uInt32 m_count;
};
+}
+
sal_uInt32 UniqueTokens::globalValue = SAL_MAX_UINT32;
namespace
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx
index 0aa836bfd7fb..b410352bfe93 100644
--- a/unotools/source/ucbhelper/ucblockbytes.cxx
+++ b/unotools/source/ucbhelper/ucblockbytes.cxx
@@ -68,6 +68,8 @@ using namespace ::com::sun::star::beans;
namespace utl
{
+namespace {
+
/**
Helper class for getting a XInputStream when opening a content
*/
@@ -159,6 +161,8 @@ public:
virtual void SAL_CALL propertiesChange ( const Sequence<PropertyChangeEvent> &rEvent) override;
};
+}
+
void SAL_CALL UcbPropertiesChangeListener_Impl::propertiesChange ( const Sequence<PropertyChangeEvent> &rEvent)
{
for (const auto& rPropChangeEvent : rEvent)
@@ -170,6 +174,8 @@ void SAL_CALL UcbPropertiesChangeListener_Impl::propertiesChange ( const Sequenc
}
}
+namespace {
+
class Moderator
: public osl::Thread
{
@@ -337,6 +343,8 @@ private:
Reference<XInputStream> m_xStream;
};
+}
+
ModeratorsActiveDataSink::ModeratorsActiveDataSink(Moderator &theModerator)
: m_aModerator(theModerator)
{
@@ -371,6 +379,8 @@ ModeratorsActiveDataStreamer::setStream (
m_xStream = rxStream;
}
+namespace {
+
class ModeratorsInteractionHandler
: public ::cppu::WeakImplHelper<XInteractionHandler>
{
@@ -386,6 +396,8 @@ private:
Moderator& m_aModerator;
};
+}
+
ModeratorsInteractionHandler::ModeratorsInteractionHandler(
Moderator &aModerator)
: m_aModerator(aModerator)