summaryrefslogtreecommitdiff
path: root/desktop
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 /desktop
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 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx4
-rw-r--r--desktop/source/app/app.cxx7
-rw-r--r--desktop/source/app/appinit.cxx4
-rw-r--r--desktop/source/app/dispatchwatcher.cxx5
-rw-r--r--desktop/source/app/officeipcthread.cxx8
-rw-r--r--desktop/source/deployment/dp_log.cxx2
-rw-r--r--desktop/source/deployment/gui/dp_gui_dialog2.cxx3
-rw-r--r--desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx3
-rw-r--r--desktop/source/deployment/gui/dp_gui_service.cxx5
-rw-r--r--desktop/source/deployment/gui/license_dialog.cxx4
-rw-r--r--desktop/source/deployment/manager/dp_informationprovider.cxx3
-rw-r--r--desktop/source/deployment/manager/dp_manager.cxx4
-rw-r--r--desktop/source/deployment/manager/dp_managerfac.cxx2
-rw-r--r--desktop/source/deployment/registry/sfwk/dp_sfwk.cxx3
-rw-r--r--desktop/source/lib/init.cxx12
-rw-r--r--desktop/source/migration/services/jvmfwk.cxx4
16 files changed, 68 insertions, 5 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 2c2d03b967ea..242a539cf08e 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1794,6 +1794,8 @@ void DesktopLOKTest::testRedlineCalc()
CPPUNIT_ASSERT_EQUAL(std::string("Cell B4 changed from '5' to 't'"), rRedline.second.get<std::string>("description"));
}
+namespace {
+
class ViewCallback
{
LibLODocument_Impl* mpDocument;
@@ -1864,6 +1866,8 @@ public:
}
};
+}
+
void DesktopLOKTest::testPaintPartTile()
{
// Load an impress doc of 2 slides.
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 82422c835210..f448d6e7e507 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -1207,6 +1207,8 @@ void Desktop::AppEvent( const ApplicationEvent& rAppEvent )
HandleAppEvent( rAppEvent );
}
+namespace {
+
struct ExecuteGlobals
{
Reference < css::document::XDocumentEventListener > xGlobalBroadcaster;
@@ -1221,6 +1223,8 @@ struct ExecuteGlobals
{}
};
+}
+
static ExecuteGlobals* pExecGlobals = nullptr;
int Desktop::Main()
@@ -1888,6 +1892,7 @@ void Desktop::OverrideSystemSettings( AllSettings& rSettings )
rSettings.SetStyleSettings ( hStyleSettings );
}
+namespace {
class ExitTimer : public Timer
{
@@ -1903,6 +1908,8 @@ class ExitTimer : public Timer
}
};
+}
+
IMPL_LINK_NOARG(Desktop, OpenClients_Impl, void*, void)
{
try {
diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx
index 642733efceb2..dc2095a14af5 100644
--- a/desktop/source/app/appinit.cxx
+++ b/desktop/source/app/appinit.cxx
@@ -175,6 +175,8 @@ void Desktop::createAcceptor(const OUString& aAcceptString)
}
}
+namespace {
+
class enable
{
private:
@@ -190,6 +192,8 @@ class enable
}
};
+}
+
// enable acceptors
IMPL_STATIC_LINK_NOARG(Desktop, EnableAcceptors_Impl, void*, void)
{
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index f3857d8cff57..ade5ad25acc8 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -83,6 +83,8 @@ namespace document = ::com::sun::star::document;
namespace desktop
{
+namespace {
+
struct DispatchHolder
{
DispatchHolder( const URL& rURL, Reference< XDispatch > const & rDispatch ) :
@@ -92,9 +94,6 @@ struct DispatchHolder
Reference< XDispatch > xDispatch;
};
-namespace
-{
-
std::shared_ptr<const SfxFilter> impl_lookupExportFilterForUrl( const OUString& rUrl, const OUString& rFactory )
{
// create the list of filters
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index e375c17f683c..5a79206c96ee 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -266,6 +266,8 @@ static OUString CreateMD5FromString( const OUString& aMsg )
return OUString();
}
+namespace {
+
class ProcessEventsClass_Impl
{
public:
@@ -273,6 +275,8 @@ public:
DECL_STATIC_LINK( ProcessEventsClass_Impl, ProcessDocumentsEvent, void*, void );
};
+}
+
IMPL_STATIC_LINK( ProcessEventsClass_Impl, CallEvent, void*, pEvent, void )
{
// Application events are processed by the Desktop::HandleAppEvent implementation.
@@ -1300,6 +1304,8 @@ static void AddConversionsToDispatchList(
}
}
+namespace {
+
struct ConditionSetGuard
{
osl::Condition* m_pCondition;
@@ -1307,6 +1313,8 @@ struct ConditionSetGuard
~ConditionSetGuard() { if (m_pCondition) m_pCondition->set(); }
};
+}
+
bool RequestHandler::ExecuteCmdLineRequests(
ProcessDocumentsRequest& aRequest, bool noTerminate)
{
diff --git a/desktop/source/deployment/dp_log.cxx b/desktop/source/deployment/dp_log.cxx
index 3cfdb338d9b7..000dc46b347c 100644
--- a/desktop/source/deployment/dp_log.cxx
+++ b/desktop/source/deployment/dp_log.cxx
@@ -46,6 +46,7 @@ namespace dp_log {
typedef ::cppu::WeakComponentImplHelper<ucb::XProgressHandler> t_log_helper;
+namespace {
class ProgressLogImpl : public ::dp_misc::MutexHolder, public t_log_helper
{
@@ -65,6 +66,7 @@ public:
virtual void SAL_CALL pop() override;
};
+}
ProgressLogImpl::~ProgressLogImpl()
{
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index e48bb2d0912d..5fb33529c395 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -87,6 +87,7 @@ namespace dp_gui {
#define SHARED_PACKAGE_MANAGER "shared"
#define BUNDLED_PACKAGE_MANAGER "bundled"
+namespace {
struct StrAllFiles : public rtl::StaticWithInit< OUString, StrAllFiles >
{
@@ -97,6 +98,8 @@ struct StrAllFiles : public rtl::StaticWithInit< OUString, StrAllFiles >
}
};
+}
+
// ExtBoxWithBtns_Impl
class ExtBoxWithBtns_Impl : public ExtensionBox_Impl
{
diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
index 31f29368708e..179304795611 100644
--- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
@@ -109,6 +109,7 @@ OUString getVersion( const uno::Reference< deployment::XPackage > &rPackage )
namespace dp_gui {
+namespace {
class ProgressCmdEnv
: public ::cppu::WeakImplHelper< ucb::XCommandEnvironment,
@@ -199,6 +200,8 @@ struct ExtensionCmd
m_vExtensionList( vExtensionList ) {};
};
+}
+
typedef std::shared_ptr< ExtensionCmd > TExtensionCmd;
diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx b/desktop/source/deployment/gui/dp_gui_service.cxx
index 10325631d6a2..fbcb4ed13232 100644
--- a/desktop/source/deployment/gui/dp_gui_service.cxx
+++ b/desktop/source/deployment/gui/dp_gui_service.cxx
@@ -49,6 +49,7 @@ namespace sdecl = comphelper::service_decl;
namespace dp_gui {
+namespace {
class MyApp : public Application
{
@@ -63,6 +64,8 @@ public:
virtual void DeInit() override;
};
+}
+
MyApp::MyApp()
{
}
@@ -133,6 +136,7 @@ static OUString ReplaceProductNameHookProc( const OUString& rStr )
return sRet;
}
+namespace {
class ServiceImpl
: public ::cppu::WeakImplHelper<ui::dialogs::XAsynchronousExecutableDialog,
@@ -157,6 +161,7 @@ public:
virtual void SAL_CALL trigger( OUString const & event ) override;
};
+}
ServiceImpl::ServiceImpl( Sequence<Any> const& args,
Reference<XComponentContext> const& xComponentContext)
diff --git a/desktop/source/deployment/gui/license_dialog.cxx b/desktop/source/deployment/gui/license_dialog.cxx
index 9ab343730d89..7f7f14402278 100644
--- a/desktop/source/deployment/gui/license_dialog.cxx
+++ b/desktop/source/deployment/gui/license_dialog.cxx
@@ -41,6 +41,8 @@ using namespace ::com::sun::star::uno;
namespace dp_gui {
+namespace {
+
struct LicenseDialogImpl : public weld::GenericDialogController
{
bool m_bLicenseRead;
@@ -74,6 +76,8 @@ struct LicenseDialogImpl : public weld::GenericDialogController
bool IsEndReached() const;
};
+}
+
LicenseDialogImpl::LicenseDialogImpl(
weld::Window * pParent,
const OUString & sExtensionName,
diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx
index 5eafb605c91a..2866d0dccac3 100644
--- a/desktop/source/deployment/manager/dp_informationprovider.cxx
+++ b/desktop/source/deployment/manager/dp_informationprovider.cxx
@@ -61,6 +61,8 @@ namespace xml = com::sun::star::xml ;
namespace dp_info {
+namespace {
+
class PackageInformationProvider :
public ::cppu::WeakImplHelper< deployment::XPackageInformationProvider >
@@ -83,6 +85,7 @@ private:
uno::Reference< deployment::XUpdateInformationProvider > mxUpdateInformation;
};
+}
PackageInformationProvider::PackageInformationProvider( uno::Reference< uno::XComponentContext > const& xContext) :
mxContext( xContext ),
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index ac814592daf8..7c79ab43405e 100644
--- a/desktop/source/deployment/manager/dp_manager.cxx
+++ b/desktop/source/deployment/manager/dp_manager.cxx
@@ -90,6 +90,8 @@ extern comphelper::service_decl::ServiceDecl const serviceDecl;
namespace dp_manager {
+namespace {
+
struct MatchTempDir
{
OUString m_str;
@@ -99,8 +101,6 @@ struct MatchTempDir
}
};
-
-namespace {
OUString getExtensionFolder(OUString const & parentFolder,
Reference<ucb::XCommandEnvironment> const & xCmdEnv,
Reference<uno::XComponentContext> const & xContext)
diff --git a/desktop/source/deployment/manager/dp_managerfac.cxx b/desktop/source/deployment/manager/dp_managerfac.cxx
index 5b7c7e11a3f0..f284c7e3cceb 100644
--- a/desktop/source/deployment/manager/dp_managerfac.cxx
+++ b/desktop/source/deployment/manager/dp_managerfac.cxx
@@ -36,6 +36,7 @@ namespace factory {
typedef ::cppu::WeakComponentImplHelper<
deployment::XPackageManagerFactory > t_pmfac_helper;
+namespace {
class PackageManagerFactoryImpl : private MutexHolder, public t_pmfac_helper
{
@@ -63,6 +64,7 @@ public:
OUString const & context ) override;
};
+}
namespace sdecl = comphelper::service_decl;
sdecl::class_<PackageManagerFactoryImpl> const servicePMFI;
diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx
index 0701a3492e86..4b66e51ede80 100644
--- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx
+++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx
@@ -48,6 +48,7 @@ namespace backend
namespace sfwk
{
+namespace {
class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
{
@@ -103,6 +104,8 @@ public:
virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) override;
};
+}
+
BackendImpl * BackendImpl::PackageImpl::getMyBackend() const
{
BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get());
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 1e97c1aecc4b..9298be14c0dc 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -177,12 +177,16 @@ static void SetLastExceptionMsg(const OUString& s = OUString())
gImpl->maLastExceptionMsg = s;
}
+namespace {
+
struct ExtensionMap
{
const char *extn;
const char *filterName;
};
+}
+
static const ExtensionMap aWriterExtensionMap[] =
{
{ "doc", "MS Word 97" },
@@ -3237,6 +3241,8 @@ static size_t doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOu
return 0;
}
+namespace {
+
/** Class to react on finishing of a dispatched command.
This will call a LOK_COMMAND_FINISHED callback when postUnoCommand was
@@ -3279,6 +3285,8 @@ public:
virtual void SAL_CALL disposing(const css::lang::EventObject&) override {}
};
+}
+
static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWindowId, const char* pArguments)
{
SolarMutexGuard aGuard;
@@ -5410,6 +5418,8 @@ static void preloadData()
rtl::Bootstrap::set("UserInstallation", sUserPath);
}
+namespace {
+
class ProfileZoneDumper : public AutoTimer
{
static const int dumpTimeoutMS = 5000;
@@ -5435,6 +5445,8 @@ public:
}
};
+}
+
static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char* pUserProfileUrl)
{
enum {
diff --git a/desktop/source/migration/services/jvmfwk.cxx b/desktop/source/migration/services/jvmfwk.cxx
index 034a526a810f..e0c13c7767ee 100644
--- a/desktop/source/migration/services/jvmfwk.cxx
+++ b/desktop/source/migration/services/jvmfwk.cxx
@@ -58,6 +58,8 @@ using namespace com::sun::star::configuration::backend;
namespace migration
{
+namespace {
+
class JavaMigration : public ::cppu::WeakImplHelper<
css::lang::XServiceInfo,
css::lang::XInitialization,
@@ -140,6 +142,8 @@ private:
};
+}
+
JavaMigration::~JavaMigration()
{
OSL_ASSERT(m_aStack.empty());