summaryrefslogtreecommitdiff
path: root/xmloff/source/transform
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 /xmloff/source/transform
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 'xmloff/source/transform')
-rw-r--r--xmloff/source/transform/ChartPlotAreaOASISTContext.cxx4
-rw-r--r--xmloff/source/transform/MergeElemTContext.cxx8
-rw-r--r--xmloff/source/transform/OOo2Oasis.cxx20
-rw-r--r--xmloff/source/transform/Oasis2OOo.cxx20
-rw-r--r--xmloff/source/transform/PersMixedContentTContext.cxx4
-rw-r--r--xmloff/source/transform/StyleOOoTContext.cxx8
6 files changed, 64 insertions, 0 deletions
diff --git a/xmloff/source/transform/ChartPlotAreaOASISTContext.cxx b/xmloff/source/transform/ChartPlotAreaOASISTContext.cxx
index 187333016852..a4fcb6129eba 100644
--- a/xmloff/source/transform/ChartPlotAreaOASISTContext.cxx
+++ b/xmloff/source/transform/ChartPlotAreaOASISTContext.cxx
@@ -32,6 +32,8 @@ using namespace ::xmloff::token;
using ::com::sun::star::uno::Reference;
+namespace {
+
class XMLAxisOASISContext : public XMLPersElemContentTContext
{
public:
@@ -53,6 +55,8 @@ private:
bool m_bHasCategories;
};
+}
+
XMLAxisOASISContext::XMLAxisOASISContext(
XMLTransformerBase& rTransformer,
const OUString& rQName,
diff --git a/xmloff/source/transform/MergeElemTContext.cxx b/xmloff/source/transform/MergeElemTContext.cxx
index ac10b3044282..3d0a7543a6a4 100644
--- a/xmloff/source/transform/MergeElemTContext.cxx
+++ b/xmloff/source/transform/MergeElemTContext.cxx
@@ -30,6 +30,8 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::xml::sax;
using namespace ::xmloff::token;
+namespace {
+
class XMLParagraphTransformerContext : public XMLTransformerContext
{
public:
@@ -44,6 +46,8 @@ public:
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
};
+}
+
XMLParagraphTransformerContext::XMLParagraphTransformerContext(
XMLTransformerBase& rImp,
const OUString& rQName ) :
@@ -61,6 +65,8 @@ rtl::Reference<XMLTransformerContext> XMLParagraphTransformerContext::CreateChil
rQName, true );
}
+namespace {
+
class XMLPersTextContentRNGTransformTContext : public XMLPersTextContentTContext
{
public:
@@ -73,6 +79,8 @@ public:
virtual void Characters( const OUString& rChars ) override;
};
+}
+
XMLPersTextContentRNGTransformTContext::XMLPersTextContentRNGTransformTContext(
XMLTransformerBase& rTransformer,
const OUString& rQName,
diff --git a/xmloff/source/transform/OOo2Oasis.cxx b/xmloff/source/transform/OOo2Oasis.cxx
index 1e6055ebec14..2badb088e673 100644
--- a/xmloff/source/transform/OOo2Oasis.cxx
+++ b/xmloff/source/transform/OOo2Oasis.cxx
@@ -1090,6 +1090,8 @@ static XMLTokenEnum const aTokenMap[] =
XML_TOKEN_END
};
+namespace {
+
class XMLDocumentTransformerContext_Impl : public XMLTransformerContext
{
OUString const m_aElemQName;
@@ -1107,6 +1109,8 @@ public:
virtual void EndElement() override;
};
+}
+
XMLDocumentTransformerContext_Impl::XMLDocumentTransformerContext_Impl(
XMLTransformerBase& rImp,
const OUString& rQName ) :
@@ -1229,6 +1233,8 @@ void XMLDocumentTransformerContext_Impl::EndElement()
GetTransformer().SetClass( m_aOldClass );
}
+namespace {
+
class XMLBodyTransformerContext_Impl : public XMLTransformerContext
{
OUString m_aClassQName;
@@ -1241,6 +1247,8 @@ public:
virtual void EndElement() override;
};
+}
+
XMLBodyTransformerContext_Impl::XMLBodyTransformerContext_Impl(
XMLTransformerBase& rImp,
const OUString& rQName ) :
@@ -1283,6 +1291,8 @@ void XMLBodyTransformerContext_Impl::EndElement()
XMLTransformerContext::EndElement();
}
+namespace {
+
class XMLTabStopOOoTContext_Impl : public XMLPersElemContentTContext
{
public:
@@ -1292,6 +1302,8 @@ public:
virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
};
+}
+
XMLTabStopOOoTContext_Impl::XMLTabStopOOoTContext_Impl(
XMLTransformerBase& rImp,
const OUString& rQName ) :
@@ -1370,6 +1382,8 @@ void XMLTabStopOOoTContext_Impl::StartElement(
XMLPersElemContentTContext::StartElement( xAttrList );
}
+namespace {
+
class XMLTrackedChangesOOoTContext_Impl : public XMLTransformerContext
{
sal_uInt16 const m_nPrefix;
@@ -1384,6 +1398,8 @@ public:
virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
};
+}
+
XMLTrackedChangesOOoTContext_Impl::XMLTrackedChangesOOoTContext_Impl(
XMLTransformerBase& rImp,
const OUString& rQName,
@@ -1435,6 +1451,8 @@ void XMLTrackedChangesOOoTContext_Impl::StartElement(
XMLTransformerContext::StartElement( rAttrList );
}
+namespace {
+
class XMLTableOOoTransformerContext_Impl : public XMLTransformerContext
{
OUString const m_aElemQName;
@@ -1447,6 +1465,8 @@ public:
virtual void EndElement() override;
};
+}
+
XMLTableOOoTransformerContext_Impl::XMLTableOOoTransformerContext_Impl(
XMLTransformerBase& rImp,
const OUString& rQName ) :
diff --git a/xmloff/source/transform/Oasis2OOo.cxx b/xmloff/source/transform/Oasis2OOo.cxx
index 0f55019aa7b9..896b424f87e0 100644
--- a/xmloff/source/transform/Oasis2OOo.cxx
+++ b/xmloff/source/transform/Oasis2OOo.cxx
@@ -1148,6 +1148,8 @@ static XMLTokenEnum const aTokenMap[] =
XML_DOT_DOT_DASH, XML_WAVE, XML_SMALL_WAVE, XML_TOKEN_END
};
+namespace {
+
class XMLTableTransformerContext_Impl : public XMLTransformerContext
{
OUString m_aElemQName;
@@ -1160,6 +1162,8 @@ public:
virtual void EndElement() override;
};
+}
+
XMLTableTransformerContext_Impl::XMLTableTransformerContext_Impl(
XMLTransformerBase& rImp,
const OUString& rQName ) :
@@ -1240,6 +1244,8 @@ void XMLTableTransformerContext_Impl::EndElement()
GetTransformer().GetDocHandler()->endElement( m_aElemQName );
}
+namespace {
+
class XMLBodyOASISTransformerContext_Impl : public XMLTransformerContext
{
bool m_bFirstChild;
@@ -1257,6 +1263,8 @@ public:
virtual void EndElement() override;
};
+}
+
XMLBodyOASISTransformerContext_Impl::XMLBodyOASISTransformerContext_Impl(
XMLTransformerBase& rImp,
const OUString& rQName ) :
@@ -1292,6 +1300,8 @@ void XMLBodyOASISTransformerContext_Impl::EndElement()
XMLTransformerContext::EndElement();
}
+namespace {
+
class XMLTabStopOASISTContext_Impl : public XMLPersElemContentTContext
{
public:
@@ -1301,6 +1311,8 @@ public:
virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
};
+}
+
XMLTabStopOASISTContext_Impl::XMLTabStopOASISTContext_Impl(
XMLTransformerBase& rImp,
const OUString& rQName ) :
@@ -1411,6 +1423,8 @@ void XMLTabStopOASISTContext_Impl::StartElement(
XMLPersElemContentTContext::StartElement( xAttrList );
}
+namespace {
+
class XMLConfigItemTContext_Impl : public XMLTransformerContext
{
OUString m_aContent;
@@ -1428,6 +1442,8 @@ public:
virtual void Characters( const OUString& rChars ) override;
};
+}
+
XMLConfigItemTContext_Impl::XMLConfigItemTContext_Impl(
XMLTransformerBase& rImp,
const OUString& rQName ) :
@@ -1512,6 +1528,8 @@ void XMLConfigItemTContext_Impl::EndElement()
XMLTransformerContext::EndElement();
}
+namespace {
+
class XMLTrackedChangesOASISTContext_Impl : public XMLTransformerContext
{
OUString const m_aAttrQName;
@@ -1526,6 +1544,8 @@ public:
virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
};
+}
+
XMLTrackedChangesOASISTContext_Impl::XMLTrackedChangesOASISTContext_Impl(
XMLTransformerBase& rImp,
const OUString& rQName,
diff --git a/xmloff/source/transform/PersMixedContentTContext.cxx b/xmloff/source/transform/PersMixedContentTContext.cxx
index 6d5342a09df3..f892530ac111 100644
--- a/xmloff/source/transform/PersMixedContentTContext.cxx
+++ b/xmloff/source/transform/PersMixedContentTContext.cxx
@@ -25,6 +25,8 @@
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::xml::sax;
+namespace {
+
class XMLPersTextTContext_Impl : public XMLTransformerContext
{
OUString m_aCharacters;
@@ -45,6 +47,8 @@ public:
virtual void Export() override;
};
+}
+
XMLPersTextTContext_Impl::XMLPersTextTContext_Impl(
XMLTransformerBase& rImp,
const OUString& rChars ) :
diff --git a/xmloff/source/transform/StyleOOoTContext.cxx b/xmloff/source/transform/StyleOOoTContext.cxx
index 00f429ee721b..584ae5985790 100644
--- a/xmloff/source/transform/StyleOOoTContext.cxx
+++ b/xmloff/source/transform/StyleOOoTContext.cxx
@@ -140,6 +140,8 @@ static const sal_uInt16 aElemActionMaps[XML_PROP_TYPE_END] =
PROP_OOO_CHART_ELEM_ACTIONS
};
+namespace {
+
class XMLTypedPropertiesOOoTContext_Impl : public XMLPersElemContentTContext
{
css::uno::Reference< css::xml::sax::XAttributeList > m_xAttrList;
@@ -159,6 +161,8 @@ public:
virtual void Export() override;
};
+}
+
XMLTypedPropertiesOOoTContext_Impl::XMLTypedPropertiesOOoTContext_Impl(
XMLTransformerBase& rImp,
const OUString& rQName ) :
@@ -202,6 +206,8 @@ void XMLTypedPropertiesOOoTContext_Impl::Export()
}
}
+namespace {
+
class XMLPropertiesOOoTContext_Impl : public XMLTransformerContext
{
::rtl::Reference < XMLTypedPropertiesOOoTContext_Impl >
@@ -244,6 +250,8 @@ public:
virtual bool IsPersistent() const override;
};
+}
+
XMLTypedPropertiesOOoTContext_Impl
*XMLPropertiesOOoTContext_Impl::GetPropContext(
XMLPropType eType )