From 7cca2c7fb328e64f1779993b60809eff6974b970 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 16 Nov 2016 08:59:52 +0200 Subject: new loplugin finalprotected look for final classes, and make sure they don't have protected members Change-Id: I1fa810659bba02b61a5160dbfd8e24185ec9abf4 Reviewed-on: https://gerrit.libreoffice.org/30895 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- compilerplugins/clang/finalprotected.cxx | 80 ++++++++++++++++++++++ compilerplugins/clang/test/finalprotected.cxx | 35 ++++++++++ .../drivers/mozab/bootstrap/MNSProfileDiscover.hxx | 2 +- connectivity/source/inc/dbase/DIndexIter.hxx | 1 - filter/source/flash/swfdialog.hxx | 2 - filter/source/pdf/pdfdialog.hxx | 1 - filter/source/svg/svgdialog.hxx | 2 - framework/inc/xml/imagesdocumenthandler.hxx | 2 +- framework/inc/xml/menudocumenthandler.hxx | 2 +- framework/inc/xml/statusbardocumenthandler.hxx | 2 +- framework/inc/xml/toolboxdocumenthandler.hxx | 2 +- hwpfilter/source/hiodev.h | 4 +- include/dbaccess/AsynchronousLink.hxx | 4 +- include/oox/ole/vbacontrol.hxx | 2 +- include/oox/ppt/timenode.hxx | 3 +- include/sfx2/dispatch.hxx | 11 ++- include/sfx2/emojiview.hxx | 2 +- include/sfx2/templatelocalview.hxx | 2 +- include/svtools/imap.hxx | 2 - include/svtools/treelist.hxx | 1 - include/svx/AccessibleTextHelper.hxx | 9 +-- include/svx/ShapeTypeHandler.hxx | 3 +- include/svx/fmsrcimp.hxx | 3 +- include/svx/sdr/contact/displayinfo.hxx | 1 - include/tools/ref.hxx | 2 +- include/tools/simplerm.hxx | 1 - include/vcl/gdimtf.hxx | 2 - include/vcl/svapp.hxx | 8 +-- include/xmloff/xmlnume.hxx | 2 - include/xmloff/xmltabe.hxx | 2 - sc/source/ui/inc/docsh.hxx | 2 - scaddins/source/analysis/analysishelper.hxx | 2 +- sd/inc/CustomAnimationEffect.hxx | 3 +- sd/source/ui/inc/SlideSorter.hxx | 3 +- sfx2/source/inc/workwin.hxx | 2 - solenv/CompilerTest_compilerplugins_clang.mk | 1 + sw/inc/calbck.hxx | 2 +- sw/inc/unotbl.hxx | 6 +- sw/source/uibase/inc/uinums.hxx | 3 +- vcl/inc/BitmapSymmetryCheck.hxx | 2 +- vcl/inc/fontsubset.hxx | 1 - xmloff/inc/txtflde.hxx | 3 +- xmloff/source/forms/formattributes.hxx | 4 +- 43 files changed, 149 insertions(+), 80 deletions(-) create mode 100644 compilerplugins/clang/finalprotected.cxx create mode 100644 compilerplugins/clang/test/finalprotected.cxx diff --git a/compilerplugins/clang/finalprotected.cxx b/compilerplugins/clang/finalprotected.cxx new file mode 100644 index 000000000000..35e41017a011 --- /dev/null +++ b/compilerplugins/clang/finalprotected.cxx @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include + +#include "plugin.hxx" +#include "clang/AST/CXXInheritance.h" + +// Check for final classes that have protected members + +namespace +{ + +class FinalProtected: + public RecursiveASTVisitor, public loplugin::Plugin +{ +public: + explicit FinalProtected(InstantiationData const & data): Plugin(data) {} + + virtual void run() override { + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + } + + bool VisitCXXMethodDecl(CXXMethodDecl const *); + bool VisitFieldDecl(FieldDecl const *); +}; + + +bool FinalProtected::VisitCXXMethodDecl(CXXMethodDecl const * cxxMethodDecl) +{ + if (ignoreLocation(cxxMethodDecl)) { + return true; + } + if (cxxMethodDecl->getAccess() != AS_protected) { + return true; + } + if (!cxxMethodDecl->getParent()->hasAttr()) { + return true; + } + cxxMethodDecl = cxxMethodDecl->getCanonicalDecl(); + report(DiagnosticsEngine::Warning, + "final class should not have protected members - convert them to private", + cxxMethodDecl->getLocStart()) + << cxxMethodDecl->getSourceRange(); + return true; +} + +bool FinalProtected::VisitFieldDecl(FieldDecl const * fieldDecl) +{ + if (ignoreLocation(fieldDecl)) { + return true; + } + if (fieldDecl->getAccess() != AS_protected) { + return true; + } + if (!fieldDecl->getParent()->hasAttr()) { + return true; + } + fieldDecl = fieldDecl->getCanonicalDecl(); + report(DiagnosticsEngine::Warning, + "final class should not have protected members - convert them to private", + fieldDecl->getLocStart()) + << fieldDecl->getSourceRange(); + return true; +} + +loplugin::Plugin::Registration< FinalProtected > X("finalprotected", true); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/compilerplugins/clang/test/finalprotected.cxx b/compilerplugins/clang/test/finalprotected.cxx new file mode 100644 index 000000000000..b1565781af95 --- /dev/null +++ b/compilerplugins/clang/test/finalprotected.cxx @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + + +class S final { +protected: + void f(int f) { f1 = f; } // expected-error {{final class should not have protected members - convert them to private [loplugin:finalprotected]}} expected-error {{Unreferenced externally visible function definition [loplugin:unreffun]}} + int f1; // expected-error {{final class should not have protected members - convert them to private [loplugin:finalprotected]}} +public: + void g(); // expected-error {{extern prototype in main file without definition [loplugin:externandnotdefined]}} expected-error {{Unreferenced function declaration [loplugin:unreffun]}} + int g1; +private: + void h(); // expected-error {{extern prototype in main file without definition [loplugin:externandnotdefined]}} expected-error {{Unreferenced function declaration [loplugin:unreffun]}} + int h1; +}; + +class S2 { +protected: + void f(int f) { f1 = f; } // expected-error {{Unreferenced externally visible function definition [loplugin:unreffun]}} + int f1; +public: + void g(); // expected-error {{extern prototype in main file without definition [loplugin:externandnotdefined]}} expected-error {{Unreferenced function declaration [loplugin:unreffun]}} + int g1; +private: + void h(); // expected-error {{extern prototype in main file without definition [loplugin:externandnotdefined]}} expected-error {{Unreferenced function declaration [loplugin:unreffun]}} + int h1; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx index aabcc49d2d32..40a343c53fa5 100644 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx +++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx @@ -76,7 +76,7 @@ namespace connectivity OUString getDefaultProfile( css::mozilla::MozillaProductType product ) throw (css::uno::RuntimeException); bool SAL_CALL isProfileLocked( css::mozilla::MozillaProductType product, const OUString& profileName ) throw (css::uno::RuntimeException); bool SAL_CALL getProfileExists( css::mozilla::MozillaProductType product, const OUString& profileName ) throw (css::uno::RuntimeException); - protected: + private: ProductStruct m_ProductProfileList[4]; void LoadProductsInfo(); void LoadXPToolkitProfiles(MozillaProductType product); diff --git a/connectivity/source/inc/dbase/DIndexIter.hxx b/connectivity/source/inc/dbase/DIndexIter.hxx index 349182813444..13b239fcc1da 100644 --- a/connectivity/source/inc/dbase/DIndexIter.hxx +++ b/connectivity/source/inc/dbase/DIndexIter.hxx @@ -33,7 +33,6 @@ namespace connectivity class OIndexIterator final { - protected: file::OBoolOperator* m_pOperator; const file::OOperand* m_pOperand; rtl::Reference m_xIndex; diff --git a/filter/source/flash/swfdialog.hxx b/filter/source/flash/swfdialog.hxx index 8875a7e07b61..bcaefaf4c195 100644 --- a/filter/source/flash/swfdialog.hxx +++ b/filter/source/flash/swfdialog.hxx @@ -42,8 +42,6 @@ private: css::uno::Sequence< css::beans::PropertyValue > maFilterData; css::uno::Reference< css::lang::XComponent > mxSrcDoc; -protected: - // XInterface virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw (css::uno::RuntimeException, std::exception) override; virtual void SAL_CALL acquire() throw () override; diff --git a/filter/source/pdf/pdfdialog.hxx b/filter/source/pdf/pdfdialog.hxx index c40adedd9c13..f01d6f72a3d2 100644 --- a/filter/source/pdf/pdfdialog.hxx +++ b/filter/source/pdf/pdfdialog.hxx @@ -39,7 +39,6 @@ private: Sequence< PropertyValue > maFilterData; Reference< XComponent > mxSrcDoc; -protected: // OGenericUnoDialog virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(RuntimeException, std::exception) override; virtual OUString SAL_CALL getImplementationName() throw (RuntimeException, std::exception) override; diff --git a/filter/source/svg/svgdialog.hxx b/filter/source/svg/svgdialog.hxx index 80a4e283aa36..7bfc0ee29917 100644 --- a/filter/source/svg/svgdialog.hxx +++ b/filter/source/svg/svgdialog.hxx @@ -42,8 +42,6 @@ private: css::uno::Sequence< css::beans::PropertyValue > maFilterData; css::uno::Reference< css::lang::XComponent > mxSrcDoc; -protected: - // XInterface virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw (css::uno::RuntimeException, std::exception) override; virtual void SAL_CALL acquire() throw () override; diff --git a/framework/inc/xml/imagesdocumenthandler.hxx b/framework/inc/xml/imagesdocumenthandler.hxx index a3002c02bdbe..7ce55021020a 100644 --- a/framework/inc/xml/imagesdocumenthandler.hxx +++ b/framework/inc/xml/imagesdocumenthandler.hxx @@ -143,7 +143,7 @@ class OWriteImagesDocumentHandler final ( css::xml::sax::SAXException, css::uno::RuntimeException ); - protected: + private: void WriteImageList( const ImageListItemDescriptor* ) throw ( css::xml::sax::SAXException, css::uno::RuntimeException ); diff --git a/framework/inc/xml/menudocumenthandler.hxx b/framework/inc/xml/menudocumenthandler.hxx index d81a00e1bdcb..1c94bc58b566 100644 --- a/framework/inc/xml/menudocumenthandler.hxx +++ b/framework/inc/xml/menudocumenthandler.hxx @@ -261,7 +261,7 @@ class FWE_DLLPUBLIC OWriteMenuDocumentHandler final void WriteMenuDocument() throw ( css::xml::sax::SAXException, css::uno::RuntimeException ); - protected: + private: void WriteMenu( const css::uno::Reference< css::container::XIndexAccess >& rSubMenuContainer ) throw ( css::xml::sax::SAXException, css::uno::RuntimeException ); diff --git a/framework/inc/xml/statusbardocumenthandler.hxx b/framework/inc/xml/statusbardocumenthandler.hxx index 9627f34adc5f..8a2945a8c2ea 100644 --- a/framework/inc/xml/statusbardocumenthandler.hxx +++ b/framework/inc/xml/statusbardocumenthandler.hxx @@ -129,7 +129,7 @@ class FWE_DLLPUBLIC OWriteStatusBarDocumentHandler final ( css::xml::sax::SAXException, css::uno::RuntimeException ); - protected: + private: void WriteStatusBarItem( const OUString& rCommandURL, const OUString& rHelpURL, diff --git a/framework/inc/xml/toolboxdocumenthandler.hxx b/framework/inc/xml/toolboxdocumenthandler.hxx index 7b7363baf0f3..bf57db4be94f 100644 --- a/framework/inc/xml/toolboxdocumenthandler.hxx +++ b/framework/inc/xml/toolboxdocumenthandler.hxx @@ -148,7 +148,7 @@ class FWE_DLLPUBLIC OWriteToolBoxDocumentHandler final ( css::xml::sax::SAXException, css::uno::RuntimeException ); - protected: + private: void WriteToolBoxItem( const OUString& aCommandURL, const OUString& aLabel, const OUString& aHelpURL, sal_Int16 nStyle, bool bVisible ) throw ( css::xml::sax::SAXException, diff --git a/hwpfilter/source/hiodev.h b/hwpfilter/source/hiodev.h index ab90435de58c..7c20e1ffa699 100644 --- a/hwpfilter/source/hiodev.h +++ b/hwpfilter/source/hiodev.h @@ -122,7 +122,7 @@ class HStreamIODev final: public HIODev * Move current pointer of stream as amount of size */ virtual int skipBlock( int size ) override; - protected: + private: /** * Initialize this object */ @@ -157,7 +157,7 @@ class HMemIODev final: public HIODev virtual bool read4b(int &out) override; virtual int readBlock( void *ptr, int size ) override; virtual int skipBlock( int size ) override; - protected: + private: virtual void init() override; }; #endif // INCLUDED_HWPFILTER_SOURCE_HIODEV_H diff --git a/include/dbaccess/AsynchronousLink.hxx b/include/dbaccess/AsynchronousLink.hxx index d8ca5b1d3610..c2779be5334a 100644 --- a/include/dbaccess/AsynchronousLink.hxx +++ b/include/dbaccess/AsynchronousLink.hxx @@ -42,6 +42,7 @@ namespace dbaui ::osl::Mutex m_aEventSafety; ::osl::Mutex m_aDestructionSafety; ImplSVEvent * m_nEventId; + DECL_LINK(OnAsyncCall, void*, void); public: /** constructs the object @@ -54,9 +55,6 @@ namespace dbaui void Call( void* _pArgument = nullptr ); void CancelCall(); - - protected: - DECL_LINK(OnAsyncCall, void*, void); }; } #endif // INCLUDED_DBACCESS_ASYNCRONOUSLINK_HXX diff --git a/include/oox/ole/vbacontrol.hxx b/include/oox/ole/vbacontrol.hxx index df1c0410c7cd..f7e22cf68eda 100644 --- a/include/oox/ole/vbacontrol.hxx +++ b/include/oox/ole/vbacontrol.hxx @@ -88,7 +88,7 @@ public: sal_Int32 nCtrlIndex ) const; const OUString& getControlSource() { return maControlSource; } const OUString& getRowSource() { return maRowSource; } -protected: +private: OUString maName; ///< Name of the control. OUString maTag; ///< User defined tag. OUString maToolTip; ///< Tool tip for the control. diff --git a/include/oox/ppt/timenode.hxx b/include/oox/ppt/timenode.hxx index 7e6bd94b672c..0c3cd403b93d 100644 --- a/include/oox/ppt/timenode.hxx +++ b/include/oox/ppt/timenode.hxx @@ -94,7 +94,7 @@ namespace oox { namespace ppt { { return maPrevCondList; } AnimationCondition & getEndSyncValue() { mbHasEndSyncValue = true; return maEndSyncValue; } - protected: + private: static OUString getServiceName( sal_Int16 nNodeType ); @@ -104,7 +104,6 @@ namespace oox { namespace ppt { const OUString& rServiceName, const css::uno::Reference< css::animations::XAnimationNode >& rxNode ); - private: const sal_Int16 mnNodeType; TimeNodePtrList maChildren; diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx index 1b79d9049997..78dc67ea5f47 100644 --- a/include/sfx2/dispatch.hxx +++ b/include/sfx2/dispatch.hxx @@ -80,12 +80,15 @@ class SFX2_DLLPUBLIC SfxDispatcher final { std::unique_ptr xImp; -private: // Search for temporary evaluated Todos SAL_DLLPRIVATE bool CheckVirtualStack( const SfxShell& rShell ); friend class SfxApplication; friend class SfxViewFrame; +friend class SfxBindings; +friend class SfxStateCache; +friend class SfxPopupMenuManager; +friend class SfxHelp; DECL_DLLPRIVATE_LINK( EventHdl_Impl, Idle *, void ); DECL_DLLPRIVATE_LINK( PostMsgHandler, SfxRequest *, void ); @@ -93,11 +96,6 @@ friend class SfxViewFrame; SAL_DLLPRIVATE void Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest &rReq, bool bRecord ); SAL_DLLPRIVATE void Update_Impl_( bool,bool,bool,SfxWorkWindow*); -protected: -friend class SfxBindings; -friend class SfxStateCache; -friend class SfxPopupMenuManager; -friend class SfxHelp; bool FindServer_( sal_uInt16 nId, SfxSlotServer &rServer, bool bModal ); bool FillState_( const SfxSlotServer &rServer, @@ -106,7 +104,6 @@ friend class SfxHelp; SfxRequest &rReq, SfxCallMode eCall = SfxCallMode::RECORD); -protected: void FlushImpl(); public: diff --git a/include/sfx2/emojiview.hxx b/include/sfx2/emojiview.hxx index 80ef8a0c0c36..602fae9e9ec9 100644 --- a/include/sfx2/emojiview.hxx +++ b/include/sfx2/emojiview.hxx @@ -48,7 +48,7 @@ public: static bool isFilteredCategory(FILTER_CATEGORY filter, const OUString &rCategory); -protected: +private: FILTER_CATEGORY mCategory; }; diff --git a/include/sfx2/templatelocalview.hxx b/include/sfx2/templatelocalview.hxx index 4a1579fa9190..8a3bfaeac19d 100644 --- a/include/sfx2/templatelocalview.hxx +++ b/include/sfx2/templatelocalview.hxx @@ -66,7 +66,7 @@ public: static bool isFilteredExtension(FILTER_APPLICATION filter, const OUString &rExt); bool isValid (const OUString& rPath) const; -protected: +private: FILTER_APPLICATION mApp; }; diff --git a/include/svtools/imap.hxx b/include/svtools/imap.hxx index bd317797d92b..da68c639b2f0 100644 --- a/include/svtools/imap.hxx +++ b/include/svtools/imap.hxx @@ -38,8 +38,6 @@ private: ::std::vector< IMapObject* > maList; OUString aName; -protected: - // binary saving/loading void ImpWriteImageMap( SvStream& rOStm, const OUString& ) const ; void ImpReadImageMap( SvStream& rIStm, size_t nCount, const OUString& ); diff --git a/include/svtools/treelist.hxx b/include/svtools/treelist.hxx index 2d162875c8ce..4b2d918c9bd5 100644 --- a/include/svtools/treelist.hxx +++ b/include/svtools/treelist.hxx @@ -130,7 +130,6 @@ class SVT_DLLPUBLIC SvTreeList final SvTreeList(const SvTreeList&) = delete; SvTreeList& operator= (const SvTreeList&) = delete; -protected: SvTreeListEntry* pRootItem; public: diff --git a/include/svx/AccessibleTextHelper.hxx b/include/svx/AccessibleTextHelper.hxx index c264585846e8..7fdee91520de 100644 --- a/include/svx/AccessibleTextHelper.hxx +++ b/include/svx/AccessibleTextHelper.hxx @@ -126,14 +126,9 @@ namespace accessibility ~AccessibleTextHelper(); - protected: + AccessibleTextHelper( const AccessibleTextHelper& ) = delete; + AccessibleTextHelper& operator= ( const AccessibleTextHelper& ) = delete; - // declared, but not defined - AccessibleTextHelper( const AccessibleTextHelper& ); - // declared, but not defined - AccessibleTextHelper& operator= ( const AccessibleTextHelper& ); - - public: /** Query the current edit source @attention This method returns by reference, so you are diff --git a/include/svx/ShapeTypeHandler.hxx b/include/svx/ShapeTypeHandler.hxx index 7e21e384ed93..b2c80e3cac0b 100644 --- a/include/svx/ShapeTypeHandler.hxx +++ b/include/svx/ShapeTypeHandler.hxx @@ -140,7 +140,7 @@ public: const css::uno::Reference< css::drawing::XShape >& rxShape) throw (css::uno::RuntimeException, std::exception); -protected: +private: // Declare default constructor, copy constructor, destructor, and // assignment operation protected so that no one accidentally creates a // second instance of this singleton class or deletes it. @@ -153,7 +153,6 @@ protected: */ ~ShapeTypeHandler(); -private: /// Pointer to the only instance of this class. static ShapeTypeHandler* instance; diff --git a/include/svx/fmsrcimp.hxx b/include/svx/fmsrcimp.hxx index 478b9e1c1e84..467fafabbc9e 100644 --- a/include/svx/fmsrcimp.hxx +++ b/include/svx/fmsrcimp.hxx @@ -310,7 +310,7 @@ public: void SwitchToContext(const css::uno::Reference< css::sdbc::XResultSet >& xCursor, const OUString& strVisibleFields, const InterfaceArray& arrFields, sal_Int32 nFieldIndex); -protected: +private: void Init(const OUString& strVisibleFields); void SearchNextImpl(); @@ -319,7 +319,6 @@ protected: // start a thread-search (or call SearchNextImpl directly, depending on the search mode) void ImplStartNextSearch(); -private: SVX_DLLPRIVATE void clearControlTexts(); SVX_DLLPRIVATE void fillControlTexts(const InterfaceArray& arrFields); diff --git a/include/svx/sdr/contact/displayinfo.hxx b/include/svx/sdr/contact/displayinfo.hxx index 64d15f9564bb..b474cae3377e 100644 --- a/include/svx/sdr/contact/displayinfo.hxx +++ b/include/svx/sdr/contact/displayinfo.hxx @@ -30,7 +30,6 @@ namespace sdr { class SVX_DLLPUBLIC DisplayInfo final { - protected: // The Layers which shall be processed (visible) SetOfByte maProcessLayers; diff --git a/include/tools/ref.hxx b/include/tools/ref.hxx index fd00dad553a1..c251a7839f7a 100644 --- a/include/tools/ref.hxx +++ b/include/tools/ref.hxx @@ -99,7 +99,7 @@ public: bool operator ==(const SvRef &rhs) const { return pObj == rhs.pObj; } bool operator !=(const SvRef &rhs) const { return !(*this == rhs); } -protected: +private: T * pObj; }; diff --git a/include/tools/simplerm.hxx b/include/tools/simplerm.hxx index b670dab21a3d..28d008ed7e59 100644 --- a/include/tools/simplerm.hxx +++ b/include/tools/simplerm.hxx @@ -32,7 +32,6 @@ class InternalResMgr; class TOOLS_DLLPUBLIC SimpleResMgr final { -protected: osl::Mutex m_aAccessSafety; InternalResMgr* m_pResImpl; diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx index fec0cdd04595..d8b8d16e0e60 100644 --- a/include/vcl/gdimtf.hxx +++ b/include/vcl/gdimtf.hxx @@ -98,8 +98,6 @@ private: SAL_DLLPRIVATE bool ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, Size rLogicDestSize ); -protected: - void Linker( OutputDevice* pOut, bool bLink ); public: diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index 4798bf3ac653..23d6e694fa2a 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -1423,6 +1423,7 @@ class VCL_DLLPUBLIC SolarMutexClearableGuard final SolarMutexClearableGuard( const SolarMutexClearableGuard& ) = delete; const SolarMutexClearableGuard& operator = ( const SolarMutexClearableGuard& ) = delete; bool m_bCleared; + comphelper::SolarMutex& m_solarMutex; public: /** Acquires mutex */ @@ -1451,9 +1452,6 @@ public: m_bCleared = true; } } - -protected: - comphelper::SolarMutex& m_solarMutex; }; class VCL_DLLPUBLIC SolarMutexResettableGuard final @@ -1461,6 +1459,7 @@ class VCL_DLLPUBLIC SolarMutexResettableGuard final SolarMutexResettableGuard( const SolarMutexResettableGuard& ) = delete; const SolarMutexResettableGuard& operator = ( const SolarMutexResettableGuard& ) = delete; bool m_bCleared; + comphelper::SolarMutex& m_solarMutex; public: /** Acquires mutex */ @@ -1499,9 +1498,6 @@ public: m_bCleared = false; } } - -protected: - comphelper::SolarMutex& m_solarMutex; }; namespace vcl diff --git a/include/xmloff/xmlnume.hxx b/include/xmloff/xmlnume.hxx index 9d4b253403d9..420e6448127c 100644 --- a/include/xmloff/xmlnume.hxx +++ b/include/xmloff/xmlnume.hxx @@ -54,8 +54,6 @@ class XMLOFF_DLLPUBLIC SvxXMLNumRuleExport final const css::uno::Sequence< css::beans::PropertyValue>& rProps, bool bOutline ); -protected: - SAL_DLLPRIVATE void exportStyle( const css::uno::Reference< css::style::XStyle >& rStyle ); SAL_DLLPRIVATE void exportOutline(); diff --git a/include/xmloff/xmltabe.hxx b/include/xmloff/xmltabe.hxx index 85c182df573f..3bdd0a368406 100644 --- a/include/xmloff/xmltabe.hxx +++ b/include/xmloff/xmltabe.hxx @@ -34,8 +34,6 @@ class SvxXMLTabStopExport final { SvXMLExport& rExport; // for access to document handler -protected: - void exportTabStop( const css::style::TabStop* pTabStop ); public: diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 7f42e336dfae..0abc2890f02a 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -157,8 +157,6 @@ class SC_DLLPUBLIC ScDocShell final: public SfxObjectShell, public SfxListener SAL_DLLPRIVATE ScDocFunc *CreateDocFunc(); -protected: - virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; public: diff --git a/scaddins/source/analysis/analysishelper.hxx b/scaddins/source/analysis/analysishelper.hxx index 13932cbdaf1a..2cd8159ce3bb 100644 --- a/scaddins/source/analysis/analysishelper.hxx +++ b/scaddins/source/analysis/analysishelper.hxx @@ -242,7 +242,7 @@ class SortedIndividualInt32List final { private: std::vector maVector; -protected: + void Insert( sal_Int32 nDay ); void Insert( sal_Int32 nDay, sal_Int32 nNullDate, bool bInsertOnWeekend ); void Insert( double fDay, sal_Int32 nNullDate, bool bInsertOnWeekend ) diff --git a/sd/inc/CustomAnimationEffect.hxx b/sd/inc/CustomAnimationEffect.hxx index 952582b8706b..f9391a4b50cb 100644 --- a/sd/inc/CustomAnimationEffect.hxx +++ b/sd/inc/CustomAnimationEffect.hxx @@ -169,10 +169,9 @@ public: SAL_DLLPRIVATE void updateSdrPathObjFromPath( SdrPathObj& rPathObj ); SAL_DLLPRIVATE void updatePathFromSdrPathObj( const SdrPathObj& rPathObj ); -protected: +private: SAL_DLLPRIVATE void setEffectSequence( EffectSequenceHelper* pSequence ) { mpEffectSequence = pSequence; } -private: sal_Int16 mnNodeType; OUString maPresetId; OUString maPresetSubType; diff --git a/sd/source/ui/inc/SlideSorter.hxx b/sd/source/ui/inc/SlideSorter.hxx index 684f4dbac1a2..0c7dd9554861 100644 --- a/sd/source/ui/inc/SlideSorter.hxx +++ b/sd/source/ui/inc/SlideSorter.hxx @@ -187,7 +187,7 @@ public: */ std::shared_ptr const & GetTheme() const; -protected: +private: /** This virtual method makes it possible to create a specialization of the slide sorter view shell that works with its own implementation of model, view, and controller. The default implementation simply @@ -208,7 +208,6 @@ protected: */ controller::SlideSorterController* CreateController(); -private: bool mbIsValid; std::unique_ptr mpSlideSorterController; diff --git a/sfx2/source/inc/workwin.hxx b/sfx2/source/inc/workwin.hxx index e190516d0505..bf2cabb62ed1 100644 --- a/sfx2/source/inc/workwin.hxx +++ b/sfx2/source/inc/workwin.hxx @@ -191,7 +191,6 @@ class SfxWorkWindow final { friend class LayoutManagerListener; -protected: std::vector aSortedList; SfxStatBar_Impl aStatBar; std::vector< SfxObjectBar_Impl > aObjBarList; @@ -225,7 +224,6 @@ protected: SfxFrame* pMasterFrame; SfxFrame* pFrame; -protected: void CreateChildWin_Impl(SfxChildWin_Impl*,bool); void RemoveChildWin_Impl(SfxChildWin_Impl*); void Sort_Impl(); diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk index 29fb11a14b21..b0ed91699ac8 100644 --- a/solenv/CompilerTest_compilerplugins_clang.mk +++ b/solenv/CompilerTest_compilerplugins_clang.mk @@ -11,6 +11,7 @@ $(eval $(call gb_CompilerTest_CompilerTest,compilerplugins_clang)) $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \ compilerplugins/clang/test/salbool \ + compilerplugins/clang/test/finalprotected \ )) # vim: set noet sw=4 ts=4: diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx index 71a86bb3935b..7ab28b11370c 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -217,7 +217,7 @@ public: /** get Client information */ virtual bool GetInfo( SfxPoolItem& rInfo) const override { return m_pToTell == nullptr || m_pToTell->GetInfo( rInfo ); } -protected: +private: virtual void Modify( const SfxPoolItem* pOldValue, const SfxPoolItem *pNewValue ) override { if( pNewValue && pNewValue->Which() == RES_OBJECTDYING ) diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index a244cb3128e1..f8aa668b897d 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -75,7 +75,6 @@ class SwXCell final : public SwXCellBaseClass, size_t nFndPos; static size_t const NOTFOUND = SAL_MAX_SIZE; -protected: virtual const SwStartNode *GetStartNode() const override; virtual css::uno::Reference< css::text::XTextCursor > @@ -164,7 +163,6 @@ class SwXTextTableRow final : public cppu::WeakImplHelper SwFrameFormat* GetFrameFormat() { return static_cast(GetRegisteredIn()); } const SwFrameFormat* GetFrameFormat() const { return const_cast(this)->GetFrameFormat(); } -protected: virtual ~SwXTextTableRow() override; //SwClient virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; @@ -505,17 +503,15 @@ class SwXTableRows final : public cppu::WeakImplHelper css::lang::XServiceInfo > { -private: class Impl; ::sw::UnoImplPtr m_pImpl; SwFrameFormat* GetFrameFormat(); const SwFrameFormat* GetFrameFormat() const { return const_cast(this)->GetFrameFormat(); } -protected: virtual ~SwXTableRows() override; + public: SwXTableRows(SwFrameFormat& rFrameFormat); - //XIndexAccess virtual sal_Int32 SAL_CALL getCount() throw( css::uno::RuntimeException, std::exception ) override; virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception ) override; diff --git a/sw/source/uibase/inc/uinums.hxx b/sw/source/uibase/inc/uinums.hxx index 5d11b36817e9..08bdb2da43b8 100644 --- a/sw/source/uibase/inc/uinums.hxx +++ b/sw/source/uibase/inc/uinums.hxx @@ -82,7 +82,7 @@ class SW_DLLPUBLIC SwChapterNumRules final { public: enum { nMaxRules = MAX_NUM_RULES }; // currently 9 defined forms -protected: +private: SwNumRulesWithName *pNumRules[ MAX_NUM_RULES ]; void Init(); @@ -96,7 +96,6 @@ public: void CreateEmptyNumRule(sal_uInt16 nIdx); // for import void ApplyNumRules( const SwNumRulesWithName &rCopy, sal_uInt16 nIdx); - }; inline const SwNumRulesWithName *SwChapterNumRules::GetRules(sal_uInt16 nIdx) const diff --git a/vcl/inc/BitmapSymmetryCheck.hxx b/vcl/inc/BitmapSymmetryCheck.hxx index e92f68d8f3ee..ac0425db8bac 100644 --- a/vcl/inc/BitmapSymmetryCheck.hxx +++ b/vcl/inc/BitmapSymmetryCheck.hxx @@ -22,7 +22,7 @@ public: static bool check(Bitmap& rBitmap); -protected: +private: static bool checkImpl(BitmapReadAccess* pReadAccess); }; diff --git a/vcl/inc/fontsubset.hxx b/vcl/inc/fontsubset.hxx index e2d0fbc17d6a..11f58107a5e2 100644 --- a/vcl/inc/fontsubset.hxx +++ b/vcl/inc/fontsubset.hxx @@ -79,7 +79,6 @@ private: const sal_uInt8* mpReqEncodedIds; int mnReqGlyphCount; -protected: bool CreateFontSubsetFromCff( sal_Int32* pOutGlyphWidths ); bool CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths ); static bool CreateFontSubsetFromType1( sal_Int32* pOutGlyphWidths ); diff --git a/xmloff/inc/txtflde.hxx b/xmloff/inc/txtflde.hxx index ba65fd435eff..61090c788738 100644 --- a/xmloff/inc/txtflde.hxx +++ b/xmloff/inc/txtflde.hxx @@ -210,7 +210,7 @@ public: enum ::xmloff::token::XMLTokenEnum MapAuthorFieldName(const css::uno::Reference< css::beans::XPropertySet > & xPropSet); enum ::xmloff::token::XMLTokenEnum MapSenderFieldName(const css::uno::Reference< css::beans::XPropertySet > & xPropSet); -protected: +private: SvXMLExport& GetExport() { return rExport; } @@ -407,7 +407,6 @@ protected: static OUString MakeSequenceRefName(sal_Int16 nSeqNo, const OUString& rSeqName); -private: // constants // service names diff --git a/xmloff/source/forms/formattributes.hxx b/xmloff/source/forms/formattributes.hxx index 5bed7db46f17..7167c1f82ccc 100644 --- a/xmloff/source/forms/formattributes.hxx +++ b/xmloff/source/forms/formattributes.hxx @@ -289,7 +289,7 @@ namespace xmloff AttributeAssignment() : pEnumMap(nullptr), bInverseSemantics(false) { } }; - protected: + private: typedef std::map AttributeAssignments; AttributeAssignments m_aKnownProperties; @@ -381,7 +381,7 @@ namespace xmloff const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry* _pValueMap, const css::uno::Type* _pType = nullptr); - protected: + private: /// some common code for the various add*Property methods AttributeAssignment& implAdd( const sal_Char* _pAttributeName, const OUString& _rPropertyName, -- cgit