summaryrefslogtreecommitdiff
path: root/framework
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 /framework
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 'framework')
-rw-r--r--framework/source/fwe/dispatch/interaction.cxx8
-rw-r--r--framework/source/fwe/helper/documentundoguard.cxx5
-rw-r--r--framework/source/fwe/helper/undomanagerhelper.cxx8
-rw-r--r--framework/source/fwe/xml/menudocumenthandler.cxx4
-rw-r--r--framework/source/fwe/xml/statusbardocumenthandler.cxx4
-rw-r--r--framework/source/fwe/xml/toolboxdocumenthandler.cxx8
-rw-r--r--framework/source/helper/statusindicatorfactory.cxx5
-rw-r--r--framework/source/loadenv/loadenv.cxx4
-rw-r--r--framework/source/uiconfiguration/globalsettings.cxx9
-rw-r--r--framework/source/uielement/subtoolbarcontroller.cxx4
-rw-r--r--framework/source/uielement/thesaurusmenucontroller.cxx4
-rw-r--r--framework/source/uielement/toolbarsmenucontroller.cxx8
-rw-r--r--framework/source/uielement/uicommanddescription.cxx5
-rw-r--r--framework/source/xml/imagesdocumenthandler.cxx4
14 files changed, 80 insertions, 0 deletions
diff --git a/framework/source/fwe/dispatch/interaction.cxx b/framework/source/fwe/dispatch/interaction.cxx
index 2f17a19eaa86..ef851093e70e 100644
--- a/framework/source/fwe/dispatch/interaction.cxx
+++ b/framework/source/fwe/dispatch/interaction.cxx
@@ -26,6 +26,8 @@ using namespace ::com::sun::star;
namespace framework{
+namespace {
+
/*-************************************************************************************************************
@short declaration of special continuation for filter selection
@descr Sometimes filter detection during loading document failed. Then we need a possibility
@@ -63,6 +65,8 @@ class ContinuationFilterSelect : public comphelper::OInteraction< css::document:
}; // class ContinuationFilterSelect
+}
+
// initialize continuation with right start values
ContinuationFilterSelect::ContinuationFilterSelect()
@@ -180,6 +184,8 @@ uno::Reference < task::XInteractionRequest > RequestFilterSelect::GetRequest()
return mxImpl.get();
}
+namespace {
+
class InteractionRequest_Impl : public ::cppu::WeakImplHelper< css::task::XInteractionRequest >
{
uno::Any m_aRequest;
@@ -197,6 +203,8 @@ public:
virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations() override;
};
+}
+
uno::Any SAL_CALL InteractionRequest_Impl::getRequest()
{
return m_aRequest;
diff --git a/framework/source/fwe/helper/documentundoguard.cxx b/framework/source/fwe/helper/documentundoguard.cxx
index c4aac1619b1e..5f7d16041caa 100644
--- a/framework/source/fwe/helper/documentundoguard.cxx
+++ b/framework/source/fwe/helper/documentundoguard.cxx
@@ -43,6 +43,9 @@ namespace framework
typedef ::cppu::WeakImplHelper < XUndoManagerListener
> UndoManagerContextListener_Base;
+
+ namespace {
+
class UndoManagerContextListener : public UndoManagerContextListener_Base
{
public:
@@ -97,6 +100,8 @@ namespace framework
bool m_documentDisposed;
};
+ }
+
void SAL_CALL UndoManagerContextListener::undoActionAdded( const UndoManagerEvent& )
{
// not interested in
diff --git a/framework/source/fwe/helper/undomanagerhelper.cxx b/framework/source/fwe/helper/undomanagerhelper.cxx
index 080b70eef4c6..a621a39ae320 100644
--- a/framework/source/fwe/helper/undomanagerhelper.cxx
+++ b/framework/source/fwe/helper/undomanagerhelper.cxx
@@ -67,6 +67,8 @@ namespace framework
//= UndoActionWrapper
+ namespace {
+
class UndoActionWrapper : public SfxUndoAction
{
public:
@@ -84,6 +86,8 @@ namespace framework
const Reference< XUndoAction > m_xUndoAction;
};
+ }
+
UndoActionWrapper::UndoActionWrapper( Reference< XUndoAction > const& i_undoAction )
:SfxUndoAction()
,m_xUndoAction( i_undoAction )
@@ -136,6 +140,8 @@ namespace framework
//= UndoManagerRequest
+ namespace {
+
class UndoManagerRequest : public ::comphelper::AnyEvent
{
public:
@@ -187,6 +193,8 @@ namespace framework
::osl::Condition m_finishCondition;
};
+ }
+
//= UndoManagerHelper_Impl
class UndoManagerHelper_Impl : public SfxUndoListener
diff --git a/framework/source/fwe/xml/menudocumenthandler.cxx b/framework/source/fwe/xml/menudocumenthandler.cxx
index 1e69c23e5b2d..144c6c600d22 100644
--- a/framework/source/fwe/xml/menudocumenthandler.cxx
+++ b/framework/source/fwe/xml/menudocumenthandler.cxx
@@ -92,12 +92,16 @@ using namespace ::com::sun::star::ui;
namespace framework
{
+namespace {
+
struct MenuStyleItem
{
sal_Int16 nBit;
const char* attrName;
};
+}
+
const MenuStyleItem MenuItemStyles[ ] = {
{ css::ui::ItemStyle::ICON, ATTRIBUTE_ITEMSTYLE_IMAGE },
{ css::ui::ItemStyle::TEXT, ATTRIBUTE_ITEMSTYLE_TEXT },
diff --git a/framework/source/fwe/xml/statusbardocumenthandler.cxx b/framework/source/fwe/xml/statusbardocumenthandler.cxx
index 18b6388d41d3..43d6cc12e811 100644
--- a/framework/source/fwe/xml/statusbardocumenthandler.cxx
+++ b/framework/source/fwe/xml/statusbardocumenthandler.cxx
@@ -126,12 +126,16 @@ static void ExtractStatusbarItemParameters(
}
}
+namespace {
+
struct StatusBarEntryProperty
{
OReadStatusBarDocumentHandler::StatusBar_XML_Namespace nNamespace;
char aEntryName[20];
};
+}
+
StatusBarEntryProperty const StatusBarEntries[OReadStatusBarDocumentHandler::SB_XML_ENTRY_COUNT] =
{
{ OReadStatusBarDocumentHandler::SB_NS_STATUSBAR, ELEMENT_STATUSBAR },
diff --git a/framework/source/fwe/xml/toolboxdocumenthandler.cxx b/framework/source/fwe/xml/toolboxdocumenthandler.cxx
index 7089623094b7..1ded389cdcce 100644
--- a/framework/source/fwe/xml/toolboxdocumenthandler.cxx
+++ b/framework/source/fwe/xml/toolboxdocumenthandler.cxx
@@ -81,12 +81,16 @@ static void ExtractToolbarParameters( const Sequence< PropertyValue >& rProp,
}
}
+namespace {
+
struct ToolboxStyleItem
{
sal_Int16 nBit;
const char* attrName;
};
+}
+
const ToolboxStyleItem Styles[ ] = {
{ css::ui::ItemStyle::RADIO_CHECK, ATTRIBUTE_ITEMSTYLE_RADIO },
{ css::ui::ItemStyle::ALIGN_LEFT, ATTRIBUTE_ITEMSTYLE_LEFT },
@@ -100,12 +104,16 @@ const ToolboxStyleItem Styles[ ] = {
sal_Int32 const nStyleItemEntries = SAL_N_ELEMENTS(Styles);
+namespace {
+
struct ToolBarEntryProperty
{
OReadToolBoxDocumentHandler::ToolBox_XML_Namespace nNamespace;
char aEntryName[20];
};
+}
+
ToolBarEntryProperty const ToolBoxEntries[OReadToolBoxDocumentHandler::TB_XML_ENTRY_COUNT] =
{
{ OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ELEMENT_TOOLBAR },
diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx
index 8bab8ca452c0..f00ce08eb043 100644
--- a/framework/source/helper/statusindicatorfactory.cxx
+++ b/framework/source/helper/statusindicatorfactory.cxx
@@ -41,8 +41,13 @@
namespace framework{
sal_Int32 StatusIndicatorFactory::m_nInReschedule = 0; ///< static counter for rescheduling
+
+namespace {
+
struct RescheduleLock: public rtl::Static<osl::Mutex, RescheduleLock> {}; ///< mutex to guard the m_nInReschedule
+}
+
const char PROGRESS_RESOURCE[] = "private:resource/progressbar/progressbar";
StatusIndicatorFactory::StatusIndicatorFactory(const css::uno::Reference< css::uno::XComponentContext >& xContext)
diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx
index a4ed4a3ef23b..96e9b6f2a970 100644
--- a/framework/source/loadenv/loadenv.cxx
+++ b/framework/source/loadenv/loadenv.cxx
@@ -96,6 +96,8 @@ namespace framework {
using namespace com::sun::star;
+namespace {
+
class LoadEnvListener : public ::cppu::WeakImplHelper< css::frame::XLoadEventListener ,
css::frame::XDispatchResultListener >
{
@@ -124,6 +126,8 @@ class LoadEnvListener : public ::cppu::WeakImplHelper< css::frame::XLoadEventLis
virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
};
+}
+
LoadEnv::LoadEnv(const css::uno::Reference< css::uno::XComponentContext >& xContext)
: m_xContext(xContext)
, m_nSearchFlags(0)
diff --git a/framework/source/uiconfiguration/globalsettings.cxx b/framework/source/uiconfiguration/globalsettings.cxx
index 288e81a676c0..f8a492299b95 100644
--- a/framework/source/uiconfiguration/globalsettings.cxx
+++ b/framework/source/uiconfiguration/globalsettings.cxx
@@ -40,6 +40,8 @@ namespace framework
// Configuration access class for WindowState supplier implementation
+namespace {
+
class GlobalSettings_Access : public ::cppu::WeakImplHelper<
css::lang::XComponent,
css::lang::XEventListener>
@@ -73,6 +75,8 @@ class GlobalSettings_Access : public ::cppu::WeakImplHelper<
css::uno::Reference< css::uno::XComponentContext> m_xContext;
};
+}
+
GlobalSettings_Access::GlobalSettings_Access( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) :
m_bDisposed( false ),
m_bConfigRead( false ),
@@ -217,7 +221,12 @@ void GlobalSettings_Access::impl_initConfigAccess()
// global class
+namespace {
+
struct mutexGlobalSettings : public rtl::Static< osl::Mutex, mutexGlobalSettings > {};
+
+}
+
static GlobalSettings_Access* pStaticSettings = nullptr;
static GlobalSettings_Access* GetGlobalSettings( const css::uno::Reference< css::uno::XComponentContext >& rxContext )
diff --git a/framework/source/uielement/subtoolbarcontroller.cxx b/framework/source/uielement/subtoolbarcontroller.cxx
index 058cbeee3a3c..e36ec92ea4aa 100644
--- a/framework/source/uielement/subtoolbarcontroller.cxx
+++ b/framework/source/uielement/subtoolbarcontroller.cxx
@@ -41,6 +41,8 @@ typedef cppu::ImplInheritanceHelper< svt::ToolboxController,
css::awt::XDockableWindowListener,
css::lang::XServiceInfo > ToolBarBase;
+namespace {
+
class SubToolBarController : public ToolBarBase
{
OUString m_aSubTbName;
@@ -88,6 +90,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
};
+}
+
SubToolBarController::SubToolBarController( const css::uno::Sequence< css::uno::Any >& rxArgs )
{
css::beans::PropertyValue aPropValue;
diff --git a/framework/source/uielement/thesaurusmenucontroller.cxx b/framework/source/uielement/thesaurusmenucontroller.cxx
index bfff4cb778a0..6cae0457f61d 100644
--- a/framework/source/uielement/thesaurusmenucontroller.cxx
+++ b/framework/source/uielement/thesaurusmenucontroller.cxx
@@ -29,6 +29,8 @@
#include <com/sun/star/linguistic2/LinguServiceManager.hpp>
+namespace {
+
class ThesaurusMenuController : public svt::PopupMenuControllerBase
{
public:
@@ -50,6 +52,8 @@ private:
OUString m_aLastWord;
};
+}
+
ThesaurusMenuController::ThesaurusMenuController( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) :
svt::PopupMenuControllerBase( rxContext ),
m_xLinguServiceManager( css::linguistic2::LinguServiceManager::create( rxContext ) ),
diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx
index f9f79ee19f76..3caf634f32c4 100644
--- a/framework/source/uielement/toolbarsmenucontroller.cxx
+++ b/framework/source/uielement/toolbarsmenucontroller.cxx
@@ -77,6 +77,8 @@ namespace framework
typedef std::unordered_map< OUString, OUString > ToolbarHashMap;
+namespace {
+
struct ToolBarEntry
{
OUString aUIName;
@@ -86,6 +88,8 @@ struct ToolBarEntry
const CollatorWrapper* pCollatorWrapper;
};
+}
+
static bool CompareToolBarEntry( const ToolBarEntry& aOne, const ToolBarEntry& aTwo )
{
sal_Int32 nComp = aOne.pCollatorWrapper->compareString( aOne.aUIName, aTwo.aUIName );
@@ -109,12 +113,16 @@ static Reference< XLayoutManager > getLayoutManagerFromFrame( const Reference< X
return xLayoutManager;
}
+namespace {
+
struct ToolBarInfo
{
OUString aToolBarResName;
OUString aToolBarUIName;
};
+}
+
DEFINE_XSERVICEINFO_MULTISERVICE_2 ( ToolbarsMenuController ,
OWeakObject ,
SERVICENAME_POPUPMENUCONTROLLER ,
diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx
index afbaba2f08cf..85c97cee559d 100644
--- a/framework/source/uielement/uicommanddescription.cxx
+++ b/framework/source/uielement/uicommanddescription.cxx
@@ -60,6 +60,8 @@ namespace framework
// Configuration access class for PopupMenuControllerFactory implementation
+namespace {
+
class ConfigurationAccess_UICommand : // Order is necessary for right initialization!
public ::cppu::WeakImplHelper<XNameAccess,XContainerListener>
{
@@ -145,6 +147,9 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa
bool m_bGenericDataRetrieved;
};
+}
+
+
// XInterface, XTypeProvider
ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const OUString& aModuleName, const Reference< XNameAccess >& rGenericUICommands, const Reference< XComponentContext>& rxContext ) :
diff --git a/framework/source/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx
index 90c717afad8b..45a5387186b9 100644
--- a/framework/source/xml/imagesdocumenthandler.cxx
+++ b/framework/source/xml/imagesdocumenthandler.cxx
@@ -67,12 +67,16 @@ using namespace ::com::sun::star::xml::sax;
namespace framework
{
+namespace {
+
struct ImageXMLEntryProperty
{
OReadImagesDocumentHandler::Image_XML_Namespace nNamespace;
char aEntryName[20];
};
+}
+
ImageXMLEntryProperty const ImagesEntries[OReadImagesDocumentHandler::IMG_XML_ENTRY_COUNT] =
{
{ OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_IMAGECONTAINER },