summaryrefslogtreecommitdiff
path: root/basic
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 /basic
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 'basic')
-rw-r--r--basic/source/basmgr/basicmanagerrepository.cxx10
-rw-r--r--basic/source/basmgr/basmgr.cxx6
-rw-r--r--basic/source/classes/sb.cxx4
-rw-r--r--basic/source/classes/sbunoobj.cxx21
-rw-r--r--basic/source/classes/sbxmod.cxx8
-rw-r--r--basic/source/comp/codegen.cxx8
-rw-r--r--basic/source/comp/exprgen.cxx4
-rw-r--r--basic/source/comp/parser.cxx4
-rw-r--r--basic/source/comp/token.cxx8
-rw-r--r--basic/source/runtime/inputbox.cxx4
-rw-r--r--basic/source/runtime/iosys.cxx9
-rw-r--r--basic/source/runtime/methods1.cxx4
-rw-r--r--basic/source/runtime/runtime.cxx7
-rw-r--r--basic/source/runtime/stdobj.cxx4
14 files changed, 98 insertions, 3 deletions
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx
index edc73fed8c4a..296e59327d8f 100644
--- a/basic/source/basmgr/basicmanagerrepository.cxx
+++ b/basic/source/basmgr/basicmanagerrepository.cxx
@@ -64,10 +64,16 @@ namespace basic
typedef std::vector< BasicManagerCreationListener* > CreationListeners;
+ namespace {
+
+ struct CreateImplRepository;
+
+ }
+
class ImplRepository : public ::utl::OEventListenerAdapter, public SfxListener
{
private:
- friend struct CreateImplRepository;
+ friend CreateImplRepository;
ImplRepository();
private:
@@ -192,6 +198,7 @@ namespace basic
StarBASIC* impl_getDefaultAppBasicLibrary();
};
+ namespace {
struct CreateImplRepository
{
@@ -202,6 +209,7 @@ namespace basic
}
};
+ }
ImplRepository::ImplRepository()
{
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index 46fa3740777a..8adc59a9e874 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -1586,6 +1586,7 @@ ErrCode BasicManager::ExecuteMacro( OUString const& i_fullyQualifiedName, OUStri
return SbxBase::GetError();
}
+namespace {
class ModuleInfo_Impl : public ModuleInfoHelper
{
@@ -1692,6 +1693,8 @@ public:
virtual void SAL_CALL removeByName( const OUString& Name ) override;
};
+}
+
// Methods XElementAccess
uno::Type ModuleContainer_Impl::getElementType()
{
@@ -1794,6 +1797,7 @@ static SbxObject* implCreateDialog( const uno::Sequence< sal_Int8 >& aData )
// which we can't include here, we have to use the value directly
#define SBXID_DIALOG 101
+namespace {
class DialogContainer_Impl : public NameContainerHelper
{
@@ -1820,6 +1824,8 @@ public:
virtual void SAL_CALL removeByName( const OUString& Name ) override;
};
+}
+
// Methods XElementAccess
uno::Type DialogContainer_Impl::getElementType()
{
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 3ee34bc7e2fb..00454a759ef0 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -268,6 +268,8 @@ SbxVariable* StarBASIC::VBAFind( const OUString& rName, SbxClassType t )
return nullptr;
}
+namespace {
+
// Create array for conversion SFX <-> VB error code
struct SFX_VB_ErrorItem
{
@@ -275,6 +277,8 @@ struct SFX_VB_ErrorItem
ErrCode nErrorSFX;
};
+}
+
const SFX_VB_ErrorItem SFX_VB_ErrorTab[] =
{
{ 1, ERRCODE_BASIC_EXCEPTION }, // #87844 Map exception to error code 1
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 8fbb3dd66c03..c8d9b7ec16fb 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -433,6 +433,8 @@ static void implHandleAnyException( const Any& _rCaughtException )
}
}
+namespace {
+
// NativeObjectWrapper handling
struct ObjectItem
{
@@ -443,9 +445,16 @@ struct ObjectItem
{}
};
+}
+
typedef std::vector< ObjectItem > NativeObjectWrapperVector;
+
+namespace {
+
class GaNativeObjectWrapperVector : public rtl::Static<NativeObjectWrapperVector, GaNativeObjectWrapperVector> {};
+}
+
void clearNativeObjectWrapperVector()
{
GaNativeObjectWrapperVector::get().clear();
@@ -3770,6 +3779,7 @@ void SbUnoSingleton::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
}
}
+namespace {
// Implementation of an EventAttacher-drawn AllListener, which
// solely transmits several events to a general AllListener
@@ -3791,6 +3801,7 @@ public:
virtual void SAL_CALL disposing(const EventObject& Source) override;
};
+}
BasicAllListener_Impl::BasicAllListener_Impl(const OUString& aPrefixName_)
: aPrefixName( aPrefixName_ )
@@ -3872,6 +3883,8 @@ void BasicAllListener_Impl ::disposing(const EventObject& )
// class InvocationToAllListenerMapper
// helper class to map XInvocation to XAllListener (also in project eventattacher!)
+namespace {
+
class InvocationToAllListenerMapper : public WeakImplHelper< XInvocation >
{
public:
@@ -3892,6 +3905,7 @@ private:
Any m_Helper;
};
+}
// Function to replace AllListenerAdapterService::createAllListerAdapter
static Reference< XInterface > createAllListenerAdapter
@@ -4158,6 +4172,7 @@ void RTL_Impl_CreateUnoValue( SbxArray& rPar )
refVar->PutObject( xUnoAnyObject.get() );
}
+namespace {
class ModuleInvocationProxy : public WeakImplHelper< XInvocation, XComponent >
{
@@ -4189,6 +4204,8 @@ public:
virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) override;
};
+}
+
ModuleInvocationProxy::ModuleInvocationProxy( OUString const & aPrefix, SbxObjectRef const & xScopeObj )
: m_aMutex()
, m_aPrefix( aPrefix + "_" )
@@ -4400,6 +4417,8 @@ Reference< XInterface > createComListener( const Any& aControlAny, const OUStrin
typedef std::vector< WeakReference< XComponent > > ComponentRefVector;
+namespace {
+
struct StarBasicDisposeItem
{
StarBASIC* m_pBasic;
@@ -4413,6 +4432,8 @@ struct StarBasicDisposeItem
}
};
+}
+
typedef std::vector< StarBasicDisposeItem* > DisposeItemVector;
static DisposeItemVector GaDisposeItemVector;
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index c837105a4dfe..f288f0ec99ae 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -83,6 +83,8 @@ using namespace com::sun::star::uno;
typedef ::cppu::WeakImplHelper< XInvocation > DocObjectWrapper_BASE;
typedef std::map< sal_Int16, Any > OutParamMap;
+namespace {
+
class DocObjectWrapper : public DocObjectWrapper_BASE
{
Reference< XAggregation > m_xAggProxy;
@@ -115,6 +117,8 @@ public:
virtual Sequence< Type > SAL_CALL getTypes() override;
};
+}
+
DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar )
{
SbObjModule* pMod = dynamic_cast<SbObjModule*>( pVar );
@@ -1674,6 +1678,8 @@ bool SbModule::ExceedsLegacyModuleSize()
return pImage && pImage->ExceedsLegacyLimits();
}
+namespace {
+
class ErrorHdlResetter
{
Link<StarBASIC*,bool> mErrHandler;
@@ -1695,6 +1701,8 @@ public:
bool HasError() const { return mbError; }
};
+}
+
IMPL_LINK( ErrorHdlResetter, BasicErrorHdl, StarBASIC *, /*pBasic*/, bool)
{
mbError = true;
diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx
index bebedd8f852d..569824648fc1 100644
--- a/basic/source/comp/codegen.cxx
+++ b/basic/source/comp/codegen.cxx
@@ -386,6 +386,8 @@ void SbiCodeGen::Save()
rMod.EndDefinitions();
}
+namespace {
+
template < class T >
class PCodeVisitor
{
@@ -399,9 +401,13 @@ public:
virtual bool processParams() = 0;
};
+}
+
template <class T> PCodeVisitor< T >::~PCodeVisitor()
{}
+namespace {
+
template <class T>
class PCodeBufferWalker
{
@@ -544,6 +550,8 @@ public:
}
};
+}
+
sal_uInt32
SbiCodeGen::calcNewOffSet( sal_uInt8 const * pCode, sal_uInt16 nOffset )
{
diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx
index 01da0420fd5e..d1ebb48c4c09 100644
--- a/basic/source/comp/exprgen.cxx
+++ b/basic/source/comp/exprgen.cxx
@@ -25,11 +25,15 @@
// Transform table for token operators and opcodes
+namespace {
+
struct OpTable {
SbiToken eTok; // Token
SbiOpcode eOp; // Opcode
};
+}
+
static const OpTable aOpTable [] = {
{ EXPON,SbiOpcode::EXP_ },
{ MUL, SbiOpcode::MUL_ },
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index 1de38c9c8541..45cf7e358fe6 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -33,6 +33,8 @@ struct SbiParseStack { // "Stack" for statement-blocks
sal_uInt32 nChain; // JUMP-Chain
};
+namespace {
+
struct SbiStatement {
SbiToken eTok;
void( SbiParser::*Func )();
@@ -40,6 +42,8 @@ struct SbiStatement {
bool bSubr; // true: OK inside the SUB
};
+}
+
#define Y true
#define N false
diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx
index 2e0141827858..92fabfe98ddd 100644
--- a/basic/source/comp/token.cxx
+++ b/basic/source/comp/token.cxx
@@ -26,8 +26,12 @@
#include <basiccharclass.hxx>
#include <token.hxx>
+namespace {
+
struct TokenTable { SbiToken t; const char *s; };
+}
+
static const TokenTable aTokTable_Basic [] = {
{ CAT, "&" },
{ MUL, "*" },
@@ -174,6 +178,8 @@ static const TokenTable aTokTable_Basic [] = {
{ XOR, "Xor" },
};
+namespace {
+
// #i109076
class TokenLabelInfo
{
@@ -188,6 +194,8 @@ public:
class StaticTokenLabelInfo: public ::rtl::Static< TokenLabelInfo, StaticTokenLabelInfo >{};
+}
+
// #i109076
TokenLabelInfo::TokenLabelInfo()
{
diff --git a/basic/source/runtime/inputbox.cxx b/basic/source/runtime/inputbox.cxx
index 24a71850607b..296063d9534e 100644
--- a/basic/source/runtime/inputbox.cxx
+++ b/basic/source/runtime/inputbox.cxx
@@ -25,6 +25,8 @@
#include <rtlproto.hxx>
#include <memory>
+namespace {
+
class SvRTLInputBox : public weld::GenericDialogController
{
std::unique_ptr<weld::Entry> m_xEdit;
@@ -45,6 +47,8 @@ public:
OUString const & GetText() const { return m_aText; }
};
+}
+
SvRTLInputBox::SvRTLInputBox(weld::Window* pParent, const OUString& rPrompt,
const OUString& rTitle, const OUString& rDefault,
long nXTwips, long nYTwips)
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index e58c0a060df2..533ee4f4d6a4 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -47,6 +47,7 @@ using namespace com::sun::star::bridge;
#include <iosys.hxx>
+namespace {
class SbiInputDialog : public weld::GenericDialogController
{
@@ -62,6 +63,8 @@ public:
const OUString& GetInput() const { return m_aText; }
};
+}
+
SbiInputDialog::SbiInputDialog(weld::Window* pParent, const OUString& rPrompt)
: GenericDialogController(pParent, "svt/ui/inputbox.ui", "InputBox")
, m_xInput(m_xBuilder->weld_entry("entry"))
@@ -156,6 +159,7 @@ bool hasUno()
return bRetVal;
}
+namespace {
class OslStream : public SvStream
{
@@ -171,6 +175,8 @@ public:
virtual void SetSize( sal_uInt64 nSize) override;
};
+}
+
OslStream::OslStream( const OUString& rName, StreamMode nStrmMode )
: maFile( rName )
{
@@ -251,6 +257,7 @@ void OslStream::SetSize( sal_uInt64 nSize )
maFile.setSize( nSize );
}
+namespace {
class UCBStream : public SvStream
{
@@ -268,6 +275,8 @@ public:
virtual void SetSize( sal_uInt64 nSize ) override;
};
+}
+
UCBStream::UCBStream( Reference< XInputStream > const & rStm )
: xIS( rStm )
, xSeek( rStm, UNO_QUERY )
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index ea65461ff73c..ad782bc8ef38 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -1787,8 +1787,6 @@ enum Interval
INTERVAL_S
};
-}
-
struct IntervalInfo
{
Interval meInterval;
@@ -1797,6 +1795,8 @@ struct IntervalInfo
bool mbSimple;
};
+}
+
static IntervalInfo const * getIntervalInfo( const OUString& rStringCode )
{
static IntervalInfo const aIntervalTable[] =
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 033285d8f7fe..8451455fbe89 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -1695,6 +1695,7 @@ void SbiRuntime::StepPUT()
refVar->SetFlags( n );
}
+namespace {
// VBA Dim As New behavior handling, save init object information
struct DimAsNewRecoverItem
@@ -1726,11 +1727,17 @@ struct SbxVariablePtrHash
{ return reinterpret_cast<size_t>(pVar); }
};
+}
+
typedef std::unordered_map< SbxVariable*, DimAsNewRecoverItem,
SbxVariablePtrHash > DimAsNewRecoverHash;
+namespace {
+
class GaDimAsNewRecoverHash : public rtl::Static<DimAsNewRecoverHash, GaDimAsNewRecoverHash> {};
+}
+
void removeDimAsNewRecoverItem( SbxVariable* pVar )
{
DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index 234deed57ea0..c8138e34ac60 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -55,6 +55,8 @@
#define RWPROP_ 0x4300 // mask Read/Write-Property
#define CPROP_ 0x4900 // mask for constant
+namespace {
+
struct Methods {
const char* pName;
SbxDataType eType;
@@ -63,6 +65,8 @@ struct Methods {
sal_uInt16 nHash;
};
+}
+
static Methods aMethods[] = {
{ "Abs", SbxDOUBLE, 1 | FUNCTION_, RTLNAME(Abs),0 },