diff options
20 files changed, 111 insertions, 152 deletions
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index 306267c44de5..2fa4f4e66dd0 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -90,12 +90,6 @@ AreaChart::~AreaChart() { } -double AreaChart::getMaximumX() -{ - double fMax = VSeriesPlotter::getMaximumX(); - return fMax; -} - bool AreaChart::isSeparateStackingForDifferentSigns( sal_Int32 /*nDimensionIndex*/ ) { // no separate stacking in all types of line/area charts diff --git a/chart2/source/view/charttypes/AreaChart.hxx b/chart2/source/view/charttypes/AreaChart.hxx index 6c8bdba51c09..786fcba8310e 100644 --- a/chart2/source/view/charttypes/AreaChart.hxx +++ b/chart2/source/view/charttypes/AreaChart.hxx @@ -45,7 +45,6 @@ public: virtual css::drawing::Direction3D getPreferredDiagramAspectRatio() const override; // MinimumAndMaximumSupplier - virtual double getMaximumX() override; virtual bool isSeparateStackingForDifferentSigns( sal_Int32 nDimensionIndex ) override; virtual LegendSymbolStyle getLegendSymbolStyle() override; diff --git a/compilerplugins/clang/test/unnecessaryoverride.cxx b/compilerplugins/clang/test/unnecessaryoverride.cxx index 89b772e04698..f8c210213922 100644 --- a/compilerplugins/clang/test/unnecessaryoverride.cxx +++ b/compilerplugins/clang/test/unnecessaryoverride.cxx @@ -177,4 +177,17 @@ struct Derived5 : public Base5_1, public Base5_2 void f1() { Base5_1::f1(); } // no warning expected }; +struct Base6_1 +{ + bool f1(); +}; +struct Derived6 : public Base6_1 +{ + bool + f1() // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}} + { + bool ret = Base6_1::f1(); + return ret; + } +}; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/compilerplugins/clang/unnecessaryoverride.cxx b/compilerplugins/clang/unnecessaryoverride.cxx index f906621a2844..00a1f7686c21 100644 --- a/compilerplugins/clang/unnecessaryoverride.cxx +++ b/compilerplugins/clang/unnecessaryoverride.cxx @@ -101,6 +101,7 @@ public: private: const CXXMethodDecl * findOverriddenOrSimilarMethodInSuperclasses(const CXXMethodDecl *); bool BaseCheckCallback(const CXXRecordDecl *BaseDefinition); + CXXMemberCallExpr const * extractCallExpr(Expr const *); }; bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl) @@ -280,66 +281,58 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl) //TODO: check for identical exception specifications const CompoundStmt* compoundStmt = dyn_cast<CompoundStmt>(methodDecl->getBody()); - if (!compoundStmt || compoundStmt->size() != 1) + if (!compoundStmt || compoundStmt->size() > 2) return true; const CXXMemberCallExpr* callExpr = nullptr; - if (methodDecl->getReturnType().getCanonicalType()->isVoidType()) + if (compoundStmt->size() == 1) { - if (auto const e = dyn_cast<Expr>(*compoundStmt->body_begin())) { - callExpr = dyn_cast<CXXMemberCallExpr>(e->IgnoreImplicit()->IgnoreParens()); + if (methodDecl->getReturnType().getCanonicalType()->isVoidType()) + { + if (auto const e = dyn_cast<Expr>(*compoundStmt->body_begin())) { + callExpr = dyn_cast<CXXMemberCallExpr>(e->IgnoreImplicit()->IgnoreParens()); + } + } + else + { + auto returnStmt = dyn_cast<ReturnStmt>(*compoundStmt->body_begin()); + if (returnStmt == nullptr) { + return true; + } + auto returnExpr = returnStmt->getRetValue(); + if (returnExpr == nullptr) { + return true; + } + callExpr = extractCallExpr(returnExpr); } } - else + else if (!methodDecl->getReturnType().getCanonicalType()->isVoidType()) { - auto returnStmt = dyn_cast<ReturnStmt>(*compoundStmt->body_begin()); - if (returnStmt == nullptr) { + /** handle constructions like + bool foo() { + bool ret = Base::foo(); + return ret; + } + */ + auto bodyIt = compoundStmt->body_begin(); + auto declStmt = dyn_cast<DeclStmt>(*bodyIt); + if (!declStmt || !declStmt->isSingleDecl()) return true; - } - auto returnExpr = returnStmt->getRetValue(); - if (returnExpr == nullptr) { + auto varDecl = dyn_cast<VarDecl>(declStmt->getSingleDecl()); + ++bodyIt; + auto returnStmt = dyn_cast<ReturnStmt>(*bodyIt); + if (!varDecl || !returnStmt) return true; + Expr const * retValue = returnStmt->getRetValue()->IgnoreParenImpCasts(); + if (auto exprWithCleanups = dyn_cast<ExprWithCleanups>(retValue)) + retValue = exprWithCleanups->getSubExpr()->IgnoreParenImpCasts(); + if (auto constructExpr = dyn_cast<CXXConstructExpr>(retValue)) { + if (constructExpr->getNumArgs() == 1) + retValue = constructExpr->getArg(0)->IgnoreParenImpCasts(); } - returnExpr = returnExpr->IgnoreImplicit(); - - // In something like - // - // Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( - // const rtl::OUString& sql) - // throw(SQLException, RuntimeException, std::exception) - // { - // return OCommonStatement::executeQuery( sql ); - // } - // - // look down through all the - // - // ReturnStmt - // `-ExprWithCleanups - // `-CXXConstructExpr - // `-MaterializeTemporaryExpr - // `-ImplicitCastExpr - // `-CXXBindTemporaryExpr - // `-CXXMemberCallExpr - // - // where the fact that the overriding and overridden function have identical - // return types makes us confident that all we need to check here is whether - // there's an (arbitrary, one-argument) CXXConstructorExpr and - // CXXBindTemporaryExpr in between: - if (auto ctorExpr = dyn_cast<CXXConstructExpr>(returnExpr)) { - if (ctorExpr->getNumArgs() == 1) { - auto tempExpr1 = ctorExpr->getArg(0)->IgnoreImplicit(); - if (auto tempExpr2 = dyn_cast<CXXBindTemporaryExpr>(tempExpr1)) - { - returnExpr = tempExpr2->getSubExpr(); - } - else if (auto tempExpr2 = dyn_cast<CXXMemberCallExpr>(tempExpr1)) - { - returnExpr = tempExpr2; - } - } - } - - callExpr = dyn_cast<CXXMemberCallExpr>(returnExpr->IgnoreParenImpCasts()); + if (!isa<DeclRefExpr>(retValue)) + return true; + callExpr = extractCallExpr(varDecl->getInit()); } if (!callExpr || callExpr->getMethodDecl() != overriddenMethodDecl) @@ -362,6 +355,18 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl) return true; } + const CXXMethodDecl* pOther = nullptr; + if (methodDecl->getCanonicalDecl()->getLocation() != methodDecl->getLocation()) + pOther = methodDecl->getCanonicalDecl(); + + if (pOther) { + StringRef aFileName = getFileNameOfSpellingLoc( + compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(pOther))); + // SFX_DECL_CHILDWINDOW_WITHID macro + if (loplugin::isSamePathname(aFileName, SRCDIR "/include/sfx2/childwin.hxx")) + return true; + } + report( DiagnosticsEngine::Warning, "%0%1 function just calls %2 parent", methodDecl->getLocation()) @@ -466,6 +471,49 @@ const CXXMethodDecl* UnnecessaryOverride::findOverriddenOrSimilarMethodInSupercl return similarMethod; } +CXXMemberCallExpr const * UnnecessaryOverride::extractCallExpr(Expr const *returnExpr) +{ + returnExpr = returnExpr->IgnoreImplicit(); + + // In something like + // + // Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( + // const rtl::OUString& sql) + // throw(SQLException, RuntimeException, std::exception) + // { + // return OCommonStatement::executeQuery( sql ); + // } + // + // look down through all the + // + // ReturnStmt + // `-ExprWithCleanups + // `-CXXConstructExpr + // `-MaterializeTemporaryExpr + // `-ImplicitCastExpr + // `-CXXBindTemporaryExpr + // `-CXXMemberCallExpr + // + // where the fact that the overriding and overridden function have identical + // return types makes us confident that all we need to check here is whether + // there's an (arbitrary, one-argument) CXXConstructorExpr and + // CXXBindTemporaryExpr in between: + if (auto ctorExpr = dyn_cast<CXXConstructExpr>(returnExpr)) { + if (ctorExpr->getNumArgs() == 1) { + auto tempExpr1 = ctorExpr->getArg(0)->IgnoreImplicit(); + if (auto tempExpr2 = dyn_cast<CXXBindTemporaryExpr>(tempExpr1)) + { + returnExpr = tempExpr2->getSubExpr(); + } + else if (auto tempExpr2 = dyn_cast<CXXMemberCallExpr>(tempExpr1)) + { + returnExpr = tempExpr2; + } + } + } + + return dyn_cast<CXXMemberCallExpr>(returnExpr->IgnoreParenImpCasts()); +} loplugin::Plugin::Registration< UnnecessaryOverride > X("unnecessaryoverride", true); diff --git a/dbaccess/source/filter/xml/xmlStyleImport.cxx b/dbaccess/source/filter/xml/xmlStyleImport.cxx index dd9da597c94a..e94d8e43e609 100644 --- a/dbaccess/source/filter/xml/xmlStyleImport.cxx +++ b/dbaccess/source/filter/xml/xmlStyleImport.cxx @@ -220,13 +220,6 @@ SvXMLStyleContext *OTableStylesContext::CreateStyleStyleChildContext( return pStyle; } -Reference < XNameContainer > - OTableStylesContext::GetStylesContainer( sal_uInt16 nFamily ) const -{ - Reference < XNameContainer > xStyles = SvXMLStylesContext::GetStylesContainer(nFamily); - return xStyles; -} - OUString OTableStylesContext::GetServiceName( sal_uInt16 nFamily ) const { OUString sServiceName = SvXMLStylesContext::GetServiceName(nFamily); diff --git a/dbaccess/source/filter/xml/xmlStyleImport.hxx b/dbaccess/source/filter/xml/xmlStyleImport.hxx index f8d0b4ea54dd..6d8b72069f39 100644 --- a/dbaccess/source/filter/xml/xmlStyleImport.hxx +++ b/dbaccess/source/filter/xml/xmlStyleImport.hxx @@ -103,9 +103,6 @@ namespace dbaxml virtual rtl::Reference < SvXMLImportPropertyMapper > GetImportPropertyMapper( sal_uInt16 nFamily ) const override; - virtual css::uno::Reference < - css::container::XNameContainer > - GetStylesContainer( sal_uInt16 nFamily ) const override; virtual OUString GetServiceName( sal_uInt16 nFamily ) const override; sal_Int32 GetIndex(const sal_Int16 nContextID); diff --git a/include/toolkit/awt/vclxtabpagecontainer.hxx b/include/toolkit/awt/vclxtabpagecontainer.hxx index 732c386e0ea1..be3a8b9674c1 100644 --- a/include/toolkit/awt/vclxtabpagecontainer.hxx +++ b/include/toolkit/awt/vclxtabpagecontainer.hxx @@ -40,9 +40,6 @@ public: // css::awt::XView void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; - // css::awt::XDevice, - css::awt::DeviceInfo SAL_CALL getInfo() override; - // css::awt::grid::XTabPageContainer virtual ::sal_Int16 SAL_CALL getActiveTabPageID() override; virtual void SAL_CALL setActiveTabPageID( ::sal_Int16 _activetabpageid ) override; diff --git a/include/toolkit/awt/vclxwindows.hxx b/include/toolkit/awt/vclxwindows.hxx index 6982c6dbee3d..6c6288975fb8 100644 --- a/include/toolkit/awt/vclxwindows.hxx +++ b/include/toolkit/awt/vclxwindows.hxx @@ -344,9 +344,6 @@ public: // css::awt::XView void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; - // css::awt::XDevice, - css::awt::DeviceInfo SAL_CALL getInfo() override; - // css::awt::XVclWindowPeer void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; @@ -416,9 +413,6 @@ public: // css::awt::XView void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; - // css::awt::XDevice, - css::awt::DeviceInfo SAL_CALL getInfo() override; - // css::awt::XVclWindowPeer void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; @@ -453,9 +447,6 @@ public: // css::awt::XView void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; - // css::awt::XDevice, - css::awt::DeviceInfo SAL_CALL getInfo() override; - // css::awt::XVclWindowPeer void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; diff --git a/reportdesign/source/filter/xml/xmlStyleImport.cxx b/reportdesign/source/filter/xml/xmlStyleImport.cxx index 704641996661..931eeda4587f 100644 --- a/reportdesign/source/filter/xml/xmlStyleImport.cxx +++ b/reportdesign/source/filter/xml/xmlStyleImport.cxx @@ -406,12 +406,6 @@ sal_Int32 OReportStylesContext::GetIndex(const sal_Int16 nContextID) } -sal_uInt16 OReportStylesContext::GetFamily( const OUString& rFamily ) const -{ - sal_uInt16 nFamily = SvXMLStylesContext::GetFamily(rFamily); - return nFamily; -} - } // rptxml diff --git a/reportdesign/source/filter/xml/xmlStyleImport.hxx b/reportdesign/source/filter/xml/xmlStyleImport.hxx index 5a59b8dab229..e5fce77c154a 100644 --- a/reportdesign/source/filter/xml/xmlStyleImport.hxx +++ b/reportdesign/source/filter/xml/xmlStyleImport.hxx @@ -123,7 +123,6 @@ namespace rptxml virtual css::uno::Reference< css::container::XNameContainer > GetStylesContainer( sal_uInt16 nFamily ) const override; virtual OUString GetServiceName( sal_uInt16 nFamily ) const override; - virtual sal_uInt16 GetFamily( const OUString& rFamily ) const override; sal_Int32 GetIndex(const sal_Int16 nContextID); }; diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx index 00a13cf106b8..89b725d97be0 100644 --- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx +++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx @@ -825,17 +825,6 @@ sal_uInt16 Clipboard::DetermineInsertPosition (const SdTransferable& ) return 0; } -sal_uInt16 Clipboard::InsertSlides ( - const SdTransferable& rTransferable, - sal_uInt16 nInsertPosition) -{ - sal_uInt16 nInsertedPageCount = ViewClipboard::InsertSlides ( - rTransferable, - nInsertPosition); - - return nInsertedPageCount; -} - Clipboard::DropType Clipboard::IsDropAccepted() const { const SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; diff --git a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx index f86c129b77a7..a77de34d9f18 100644 --- a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx +++ b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx @@ -101,10 +101,6 @@ protected: virtual sal_uInt16 DetermineInsertPosition ( const SdTransferable& rTransferable) override; - virtual sal_uInt16 InsertSlides ( - const SdTransferable& rTransferable, - sal_uInt16 nInsertPosition) override; - private: SlideSorter& mrSlideSorter; SlideSorterController& mrController; diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx index d023348f4548..e283d9221f09 100644 --- a/sfx2/source/dialog/recfloat.cxx +++ b/sfx2/source/dialog/recfloat.cxx @@ -93,12 +93,6 @@ SfxRecordingFloat_Impl::~SfxRecordingFloat_Impl() disposeOnce(); } -bool SfxRecordingFloat_Impl::Close() -{ - bool bRet = SfxFloatingWindow::Close(); - return bRet; -} - void SfxRecordingFloat_Impl::FillInfo( SfxChildWinInfo& rInfo ) const { SfxFloatingWindow::FillInfo( rInfo ); diff --git a/sfx2/source/inc/recfloat.hxx b/sfx2/source/inc/recfloat.hxx index 9862927bb492..7fc02c97dcee 100644 --- a/sfx2/source/inc/recfloat.hxx +++ b/sfx2/source/inc/recfloat.hxx @@ -44,7 +44,6 @@ public: SfxChildWindow* pChildWin , vcl::Window* pParent ); virtual ~SfxRecordingFloat_Impl() override; - virtual bool Close() override; virtual void FillInfo( SfxChildWinInfo& rInfo ) const override; virtual void StateChanged( StateChangedType nStateChange ) override; }; diff --git a/svx/inc/uiobject.hxx b/svx/inc/uiobject.hxx index 1cf2a33ef449..6805e35646f6 100644 --- a/svx/inc/uiobject.hxx +++ b/svx/inc/uiobject.hxx @@ -22,8 +22,6 @@ class SvxShowCharSetUIObject : public WindowUIObject public: SvxShowCharSetUIObject(const VclPtr<vcl::Window>& xCharSetWin, SvxShowCharSet* pCharSet); - virtual StringMap get_state() override; - virtual void execute(const OUString& rAction, const StringMap& rParameters) override; diff --git a/svx/source/uitest/uiobject.cxx b/svx/source/uitest/uiobject.cxx index b393ea83be82..9568f4cc75ef 100644 --- a/svx/source/uitest/uiobject.cxx +++ b/svx/source/uitest/uiobject.cxx @@ -18,13 +18,6 @@ SvxShowCharSetUIObject::SvxShowCharSetUIObject(const VclPtr<vcl::Window>& xCharS { } -StringMap SvxShowCharSetUIObject::get_state() -{ - StringMap aMap = WindowUIObject::get_state(); - - return aMap; -} - void SvxShowCharSetUIObject::execute(const OUString& rAction, const StringMap& rParameters) { diff --git a/sw/source/uibase/inc/conpoly.hxx b/sw/source/uibase/inc/conpoly.hxx index f44ed07d5adc..d1fad7db3e94 100644 --- a/sw/source/uibase/inc/conpoly.hxx +++ b/sw/source/uibase/inc/conpoly.hxx @@ -28,7 +28,6 @@ public: ConstPolygon(SwWrtShell* pSh, SwEditWin* pWin, SwView* pView); // Mouse- & Key-Events - virtual bool MouseMove(const MouseEvent& rMEvt) override; virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; virtual void Activate(const sal_uInt16 nSlotId) override; // activate function diff --git a/sw/source/uibase/ribbar/conpoly.cxx b/sw/source/uibase/ribbar/conpoly.cxx index 247306be78b6..a7ee32b2249f 100644 --- a/sw/source/uibase/ribbar/conpoly.cxx +++ b/sw/source/uibase/ribbar/conpoly.cxx @@ -33,13 +33,6 @@ ConstPolygon::ConstPolygon(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* p { } -bool ConstPolygon::MouseMove(const MouseEvent& rMEvt) -{ - bool bReturn = SwDrawBase::MouseMove(rMEvt); - - return bReturn; -} - bool ConstPolygon::MouseButtonUp(const MouseEvent& rMEvt) { bool bReturn = false; diff --git a/toolkit/source/awt/vclxtabpagecontainer.cxx b/toolkit/source/awt/vclxtabpagecontainer.cxx index 5ef02d4e2919..da6ed54f8941 100644 --- a/toolkit/source/awt/vclxtabpagecontainer.cxx +++ b/toolkit/source/awt/vclxtabpagecontainer.cxx @@ -78,12 +78,6 @@ void SAL_CALL VCLXTabPageContainer::draw( sal_Int32 nX, sal_Int32 nY ) VCLXWindow::draw( nX, nY ); } -css::awt::DeviceInfo VCLXTabPageContainer::getInfo() -{ - css::awt::DeviceInfo aInfo = VCLXDevice::getInfo(); - return aInfo; -} - void SAL_CALL VCLXTabPageContainer::setProperty(const OUString& PropertyName, const Any& Value ) { SolarMutexGuard aGuard; diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index 2a296cda4ab2..af82ca3be2c7 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -2486,13 +2486,6 @@ void SAL_CALL VCLXMultiPage::draw( sal_Int32 nX, sal_Int32 nY ) } } -// css::awt::XDevice, -css::awt::DeviceInfo SAL_CALL VCLXMultiPage::getInfo() -{ - css::awt::DeviceInfo aInfo = VCLXDevice::getInfo(); - return aInfo; -} - uno::Any SAL_CALL VCLXMultiPage::getProperty( const OUString& PropertyName ) { SAL_INFO("toolkit", " **** VCLXMultiPage::getProperty " << PropertyName ); @@ -2744,13 +2737,6 @@ void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY ) } } -// css::awt::XDevice, -css::awt::DeviceInfo SAL_CALL VCLXTabPage::getInfo() -{ - css::awt::DeviceInfo aInfo = VCLXDevice::getInfo(); - return aInfo; -} - void SAL_CALL VCLXTabPage::setProperty( const OUString& PropertyName, const css::uno::Any& Value ) @@ -6555,13 +6541,6 @@ void SAL_CALL VCLXFrame::draw( sal_Int32 nX, sal_Int32 nY ) } } -// css::awt::XDevice, -css::awt::DeviceInfo SAL_CALL VCLXFrame::getInfo() -{ - css::awt::DeviceInfo aInfo = VCLXDevice::getInfo(); - return aInfo; -} - void SAL_CALL VCLXFrame::setProperty( const OUString& PropertyName, const css::uno::Any& Value ) |