summaryrefslogtreecommitdiff
path: root/editeng
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 /editeng
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 'editeng')
-rw-r--r--editeng/source/accessibility/AccessibleEditableTextPara.cxx4
-rw-r--r--editeng/source/accessibility/AccessibleParaManager.cxx12
-rw-r--r--editeng/source/accessibility/AccessibleStaticTextBase.cxx5
-rw-r--r--editeng/source/editeng/impedit3.cxx4
-rw-r--r--editeng/source/items/svxfont.cxx8
-rw-r--r--editeng/source/misc/txtrange.cxx4
-rw-r--r--editeng/source/misc/unolingu.cxx7
-rw-r--r--editeng/source/uno/unoedprx.cxx3
-rw-r--r--editeng/source/uno/unonrule.cxx4
-rw-r--r--editeng/source/xml/xmltxtexp.cxx2
-rw-r--r--editeng/source/xml/xmltxtimp.cxx5
11 files changed, 58 insertions, 0 deletions
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index c68c79ebea8f..62ba3b0f7905 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -837,6 +837,8 @@ namespace accessibility
return aNames;
}
+ namespace {
+
struct IndexCompare
{
const PropertyValue* pValues;
@@ -846,6 +848,8 @@ namespace accessibility
return pValues[a].Name < pValues[b].Name;
}
};
+
+ }
}
namespace
diff --git a/editeng/source/accessibility/AccessibleParaManager.cxx b/editeng/source/accessibility/AccessibleParaManager.cxx
index 8a7ce274e5d0..5d6be4dd60b5 100644
--- a/editeng/source/accessibility/AccessibleParaManager.cxx
+++ b/editeng/source/accessibility/AccessibleParaManager.cxx
@@ -267,6 +267,8 @@ namespace accessibility
nStateId ) );
}
+ namespace {
+
// not generic yet, no arguments...
class AccessibleParaManager_DisposeChildren
{
@@ -278,6 +280,8 @@ namespace accessibility
}
};
+ }
+
void AccessibleParaManager::Dispose()
{
AccessibleParaManager_DisposeChildren aFunctor;
@@ -286,6 +290,8 @@ namespace accessibility
WeakChildAdapter< AccessibleParaManager_DisposeChildren > (aFunctor) );
}
+ namespace {
+
// not generic yet, too many method arguments...
class StateChangeEvent
{
@@ -308,6 +314,8 @@ namespace accessibility
const uno::Any& mrOldValue;
};
+ }
+
void AccessibleParaManager::FireEvent( sal_Int32 nStartPara,
sal_Int32 nEndPara,
const sal_Int16 nEventId,
@@ -337,6 +345,8 @@ namespace accessibility
}
}
+ namespace {
+
class ReleaseChild
{
public:
@@ -349,6 +359,8 @@ namespace accessibility
}
};
+ }
+
void AccessibleParaManager::Release( sal_Int32 nStartPara, sal_Int32 nEndPara )
{
DBG_ASSERT( 0 <= nStartPara && 0 <= nEndPara &&
diff --git a/editeng/source/accessibility/AccessibleStaticTextBase.cxx b/editeng/source/accessibility/AccessibleStaticTextBase.cxx
index c85cc3c9a589..8cef86269d1d 100644
--- a/editeng/source/accessibility/AccessibleStaticTextBase.cxx
+++ b/editeng/source/accessibility/AccessibleStaticTextBase.cxx
@@ -64,6 +64,8 @@ namespace accessibility
{
typedef std::vector< beans::PropertyValue > PropertyValueVector;
+ namespace {
+
class PropertyValueEqualFunctor
{
const beans::PropertyValue& m_rPValue;
@@ -77,6 +79,9 @@ namespace accessibility
return ( m_rPValue.Name == rhs.Name && m_rPValue.Value == rhs.Value );
}
};
+
+ }
+
sal_Unicode const cNewLine(0x0a);
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index ad09f1d543dc..2128434ed05d 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -88,6 +88,8 @@ using namespace ::com::sun::star::linguistic2;
#define WRONG_SHOW_MIN 5
+namespace {
+
struct TabInfo
{
bool bValid;
@@ -106,6 +108,8 @@ struct TabInfo
};
+}
+
Point Rotate( const Point& rPoint, short nOrientation, const Point& rOrigin )
{
double nRealOrientation = nOrientation*F_PI1800;
diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx
index 2f9119a0f143..58cc0ddab5da 100644
--- a/editeng/source/items/svxfont.cxx
+++ b/editeng/source/items/svxfont.cxx
@@ -571,6 +571,8 @@ SvxFont& SvxFont::operator=( const SvxFont& rFont )
return *this;
}
+namespace {
+
class SvxDoGetCapitalSize : public SvxDoCapitals
{
protected:
@@ -592,6 +594,8 @@ public:
const Size &GetSize() const { return aTxtSize; };
};
+}
+
void SvxDoGetCapitalSize::Do( const OUString &_rTxt, const sal_Int32 _nIdx,
const sal_Int32 _nLen, const bool bUpper )
{
@@ -633,6 +637,8 @@ Size SvxFont::GetCapitalSize( const OutputDevice *pOut, const OUString &rTxt,
return aTxtSize;
}
+namespace {
+
class SvxDoDrawCapital : public SvxDoCapitals
{
protected:
@@ -656,6 +662,8 @@ public:
const sal_Int32 nLen, const bool bUpper ) override;
};
+}
+
void SvxDoDrawCapital::DoSpace( const bool bDraw )
{
if ( bDraw || pFont->IsWordLineMode() )
diff --git a/editeng/source/misc/txtrange.cxx b/editeng/source/misc/txtrange.cxx
index 2158e48b0cc6..712eea464024 100644
--- a/editeng/source/misc/txtrange.cxx
+++ b/editeng/source/misc/txtrange.cxx
@@ -88,6 +88,8 @@ void TextRanger::SetVertical( bool bNew )
}
}
+namespace {
+
//! SvxBoundArgs is used to perform temporary calculations on a range array.
//! Temporary instances are created in TextRanger::GetTextRanges()
class SvxBoundArgs
@@ -140,6 +142,8 @@ public:
bool IsConcat() const { return bConcat; }
};
+}
+
SvxBoundArgs::SvxBoundArgs( TextRanger* pRanger, LongDqPtr pLong,
const Range& rRange )
: pLongArr(pLong)
diff --git a/editeng/source/misc/unolingu.cxx b/editeng/source/misc/unolingu.cxx
index 10c184aaa2f7..8aa7a229bc64 100644
--- a/editeng/source/misc/unolingu.cxx
+++ b/editeng/source/misc/unolingu.cxx
@@ -72,6 +72,8 @@ static uno::Reference< XLinguServiceManager2 > GetLngSvcMgr_Impl()
return xRes;
}
+namespace {
+
//! Dummy implementation in order to avoid loading of lingu DLL
//! when only the XSupportedLocales interface is used.
//! The dummy accesses the real implementation (and thus loading the DLL)
@@ -103,6 +105,7 @@ public:
const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override;
};
+}
void ThesDummy_Impl::GetCfgLocales()
{
@@ -186,6 +189,7 @@ uno::Sequence< uno::Reference< linguistic2::XMeaning > > SAL_CALL
return aRes;
}
+namespace {
//! Dummy implementation in order to avoid loading of lingu DLL.
//! The dummy accesses the real implementation (and thus loading the DLL)
@@ -214,6 +218,7 @@ public:
const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override;
};
+}
void SpellDummy_Impl::GetSpell_Impl()
{
@@ -270,6 +275,7 @@ uno::Reference< linguistic2::XSpellAlternatives > SAL_CALL
return xRes;
}
+namespace {
//! Dummy implementation in order to avoid loading of lingu DLL.
//! The dummy accesses the real implementation (and thus loading the DLL)
@@ -311,6 +317,7 @@ public:
const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override;
};
+}
void HyphDummy_Impl::GetHyph_Impl()
{
diff --git a/editeng/source/uno/unoedprx.cxx b/editeng/source/uno/unoedprx.cxx
index 915fe7193eaa..c7ac1bc3786b 100644
--- a/editeng/source/uno/unoedprx.cxx
+++ b/editeng/source/uno/unoedprx.cxx
@@ -45,6 +45,7 @@
using namespace ::com::sun::star;
+namespace {
class SvxAccessibleTextIndex
{
@@ -120,6 +121,8 @@ private:
bool mbInBullet;
};
+}
+
static ESelection MakeEESelection( const SvxAccessibleTextIndex& rStart, const SvxAccessibleTextIndex& rEnd )
{
// deal with field special case: to really get a field contained
diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx
index 3742a02a1db5..dea25ce79a08 100644
--- a/editeng/source/uno/unonrule.cxx
+++ b/editeng/source/uno/unonrule.cxx
@@ -494,12 +494,16 @@ css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule(const SvxN
}
}
+namespace {
+
class SvxUnoNumberingRulesCompare : public ::cppu::WeakAggImplHelper1< XAnyCompare >
{
public:
virtual sal_Int16 SAL_CALL compare( const Any& Any1, const Any& Any2 ) override;
};
+}
+
sal_Int16 SAL_CALL SvxUnoNumberingRulesCompare::compare( const Any& Any1, const Any& Any2 )
{
return SvxUnoNumberingRules::Compare( Any1, Any2 );
diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx
index 646d6819b1d3..89ab645e3283 100644
--- a/editeng/source/xml/xmltxtexp.cxx
+++ b/editeng/source/xml/xmltxtexp.cxx
@@ -248,6 +248,7 @@ void SAL_CALL SvxSimpleUnoModel::removeEventListener( const css::uno::Reference<
{
}
+namespace {
class SvxXMLTextExportComponent : public SvXMLExport
{
@@ -268,6 +269,7 @@ private:
css::uno::Reference< css::text::XText > mxText;
};
+}
SvxXMLTextExportComponent::SvxXMLTextExportComponent(
const css::uno::Reference< css::uno::XComponentContext >& xContext,
diff --git a/editeng/source/xml/xmltxtimp.cxx b/editeng/source/xml/xmltxtimp.cxx
index b3e40380fba0..ac28c0d6b457 100644
--- a/editeng/source/xml/xmltxtimp.cxx
+++ b/editeng/source/xml/xmltxtimp.cxx
@@ -55,6 +55,7 @@ using namespace com::sun::star::text;
using namespace cppu;
using namespace xmloff::token;
+namespace {
class SvxXMLTextImportContext : public SvXMLImportContext
{
@@ -67,6 +68,7 @@ private:
const uno::Reference< XText > mxText;
};
+}
SvxXMLTextImportContext::SvxXMLTextImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const uno::Reference< XText >& xText )
: SvXMLImportContext( rImport, nPrfx, rLName ), mxText( xText )
@@ -97,6 +99,7 @@ SvXMLImportContextRef SvxXMLTextImportContext::CreateChildContext( sal_uInt16 nP
return pContext;
}
+namespace {
class SvxXMLXTextImportComponent : public SvXMLImport
{
@@ -112,6 +115,8 @@ private:
const uno::Reference< XText > mxText;
};
+}
+
SvXMLImportContext *SvxXMLXTextImportComponent::CreateDocumentContext(
sal_uInt16 const nPrefix, const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/)