Improve loplugin:unnecessaryoverride

<sberg> thorsten, remember what that "TODO" in
 SvxAccessibleTextPropertySet::getSupportedServiceNames was to be about exactly,
 in a909acb700 ?
<thorsten> sberg: that's a nonsense, prolly copy'n'pasted, or a 'please review
 me'
<sberg> thorsten, OK, thanks (that override will eventually go away with
 loplugin:unnecessaryoverride, and the TODO comment be lost)

Change-Id: Iba964c61768459aac4067bbd4e1f7d4f78f6adac
Reviewed-on: https://gerrit.libreoffice.org/27232
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2016-07-15 12:26:27 +02:00
parent 5a3653f875
commit 018e89337d
18 changed files with 56 additions and 151 deletions

View File

@@ -108,7 +108,6 @@ public:
virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw(css::uno::RuntimeException, std::exception) override;
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw (css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (css::uno::RuntimeException, std::exception) override;
// XServiceInfo

View File

@@ -153,11 +153,6 @@ Any SAL_CALL VCLXAccessibleListItem::queryInterface( Type const & rType ) throw
// XTypeProvider
Sequence< Type > SAL_CALL VCLXAccessibleListItem::getTypes( ) throw (RuntimeException, std::exception)
{
return VCLXAccessibleListItem_BASE::getTypes();
}
Sequence< sal_Int8 > VCLXAccessibleListItem::getImplementationId() throw (RuntimeException, std::exception)
{
return css::uno::Sequence<sal_Int8>();

View File

@@ -12,6 +12,8 @@
#include <iostream>
#include <fstream>
#include <set>
#include "compat.hxx"
#include "plugin.hxx"
/**
@@ -67,16 +69,61 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
const CXXMethodDecl* overriddenMethodDecl = *methodDecl->begin_overridden_methods();
if (compat::getReturnType(*methodDecl).getCanonicalType()
!= compat::getReturnType(*overriddenMethodDecl).getCanonicalType())
{
return true;
}
//TODO: check for identical exception specifications
const CompoundStmt* compoundStmt = dyn_cast<CompoundStmt>(methodDecl->getBody());
if (!compoundStmt || compoundStmt->size() != 1)
return true;
const Stmt* firstStmt = compoundStmt->body_front();
if (const ReturnStmt* returnStmt = dyn_cast<ReturnStmt>(firstStmt)) {
firstStmt = returnStmt->getRetValue();
}
if (!firstStmt)
auto returnStmt = dyn_cast<ReturnStmt>(compoundStmt->body_front());
if (returnStmt == nullptr) {
return true;
const CXXMemberCallExpr* callExpr = dyn_cast<CXXMemberCallExpr>(firstStmt);
}
auto returnExpr = returnStmt->getRetValue();
if (returnExpr == nullptr) {
return true;
}
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) {
if (auto tempExpr = dyn_cast<CXXBindTemporaryExpr>(
ctorExpr->getArg(0)->IgnoreImplicit()))
{
returnExpr = tempExpr->getSubExpr();
}
}
}
const CXXMemberCallExpr* callExpr = dyn_cast<CXXMemberCallExpr>(
returnExpr->IgnoreParenImpCasts());
if (!callExpr || callExpr->getMethodDecl() != overriddenMethodDecl)
return true;
const ImplicitCastExpr* expr1 = dyn_cast_or_null<ImplicitCastExpr>(callExpr->getImplicitObjectArgument());
@@ -92,9 +139,10 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
}
report(
DiagnosticsEngine::Warning, "method just calls parent method",
DiagnosticsEngine::Warning, "%0 virtual function just calls %1 parent",
methodDecl->getSourceRange().getBegin())
<< methodDecl->getSourceRange();
<< methodDecl->getAccess() << overriddenMethodDecl->getAccess()
<< methodDecl->getSourceRange();
if (methodDecl->getCanonicalDecl()->getLocation() != methodDecl->getLocation()) {
const CXXMethodDecl* pOther = methodDecl->getCanonicalDecl();
report(

View File

@@ -111,10 +111,4 @@ sal_Bool SAL_CALL SvxAccessibleTextPropertySet::supportsService (const OUString&
return cppu::supportsService(this, sServiceName);
}
uno::Sequence< OUString> SAL_CALL SvxAccessibleTextPropertySet::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
{
// TODO
return SvxUnoTextRangeBase::getSupportedServiceNames();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -45,12 +45,6 @@ OCurrencyControl::OCurrencyControl(const Reference<XComponentContext>& _rxFactor
{
}
Sequence<Type> OCurrencyControl::_getTypes()
{
return OBoundControl::_getTypes();
}
css::uno::Sequence<OUString> SAL_CALL OCurrencyControl::getSupportedServiceNames() throw(std::exception)
{
css::uno::Sequence<OUString> aSupported = OBoundControl::getSupportedServiceNames();

View File

@@ -69,9 +69,6 @@ protected:
class OCurrencyControl: public OBoundControl
{
protected:
virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
public:
explicit OCurrencyControl(const css::uno::Reference< css::uno::XComponentContext>& _rxContext);
// css::lang::XServiceInfo

View File

@@ -53,13 +53,6 @@ css::uno::Sequence<OUString> ONumericControl::getSupportedServiceNames() throw(s
return aSupported;
}
Sequence<Type> ONumericControl::_getTypes()
{
return OBoundControl::_getTypes();
}
// ONumericModel
Sequence<Type> ONumericModel::_getTypes()

View File

@@ -68,9 +68,6 @@ protected:
class ONumericControl: public OBoundControl
{
protected:
virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
public:
explicit ONumericControl(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory);

View File

@@ -41,13 +41,6 @@ OPatternControl::OPatternControl(const Reference<XComponentContext>& _rxFactory)
{
}
Sequence<Type> OPatternControl::_getTypes()
{
return OBoundControl::_getTypes();
}
css::uno::Sequence<OUString> OPatternControl::getSupportedServiceNames() throw(std::exception)
{
css::uno::Sequence<OUString> aSupported = OBoundControl::getSupportedServiceNames();

View File

@@ -75,9 +75,6 @@ protected:
class OPatternControl: public OBoundControl
{
protected:
virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
public:
explicit OPatternControl(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory);

View File

@@ -49,7 +49,6 @@ public:
// lang::XServiceInfo
virtual OUString SAL_CALL getImplementationName() throw(css::uno::RuntimeException, std::exception) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ) throw (css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) override;
// lang::XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() throw(css::uno::RuntimeException, std::exception) override;

View File

@@ -59,9 +59,6 @@ public:
// XFormsSupplier2
virtual sal_Bool SAL_CALL hasForms() throw( css::uno::RuntimeException, std::exception ) override;
// css::lang::XServiceInfo
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override;
};
#endif // INCLUDED_SVX_FMDPAGE_HXX

View File

@@ -434,11 +434,7 @@ public:
virtual void SAL_CALL enterGroup( ) throw(css::uno::RuntimeException, std::exception) override;
virtual void SAL_CALL leaveGroup( ) throw(css::uno::RuntimeException, std::exception) override;
// XServiceInfo
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(css::uno::RuntimeException, std::exception) override;
};
#include <com/sun/star/drawing/XConnectorShape.hpp>
@@ -474,9 +470,6 @@ public:
virtual void SAL_CALL disconnectBegin( const css::uno::Reference< css::drawing::XConnectableShape >& xShape ) throw(css::uno::RuntimeException, std::exception) override;
virtual void SAL_CALL disconnectEnd( const css::uno::Reference< css::drawing::XConnectableShape >& xShape ) throw(css::uno::RuntimeException, std::exception) override;
// XServiceInfo
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(css::uno::RuntimeException, std::exception) override;
@@ -524,9 +517,6 @@ public:
virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getControl() throw(css::uno::RuntimeException, std::exception) override;
virtual void SAL_CALL setControl( const css::uno::Reference< css::awt::XControlModel >& xControl ) throw(css::uno::RuntimeException, std::exception) override;
// XServiceInfo
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(css::uno::RuntimeException, std::exception) override;
@@ -540,9 +530,6 @@ class SvxShapeDimensioning : public SvxShapeText
public:
SvxShapeDimensioning( SdrObject* pObj ) throw();
virtual ~SvxShapeDimensioning() throw();
// XServiceInfo
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
};
/***********************************************************************
@@ -553,9 +540,6 @@ class SvxShapeCircle : public SvxShapeText
public:
SvxShapeCircle( SdrObject* pObj ) throw ();
virtual ~SvxShapeCircle() throw ();
// XServiceInfo
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
};
/***********************************************************************
@@ -613,9 +597,6 @@ public:
css::drawing::PolygonKind GetPolygonKind() const throw() { return mePolygonKind;}
void SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw(css::uno::RuntimeException);
basegfx::B2DPolyPolygon GetPolygon() const throw();
// XServiceInfo
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
};
/***********************************************************************
@@ -643,9 +624,6 @@ public:
css::drawing::PolygonKind GetPolygonKind() const throw() { return mePolygonKind;}
void SetPolygon(const basegfx::B2DPolyPolygon & rNew) throw(css::uno::RuntimeException);
basegfx::B2DPolyPolygon GetPolygon() const throw();
// XServiceInfo
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
};
/***********************************************************************
@@ -716,7 +694,6 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(css::uno::RuntimeException, std::exception) override;
};

View File

@@ -113,11 +113,4 @@ sal_Bool SAL_CALL SvxFmDrawPage::hasForms() throw( css::uno::RuntimeException, s
return bHas;
}
// css::lang::XServiceInfo
css::uno::Sequence< OUString > SAL_CALL SvxFmDrawPage::getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception )
{
return SvxDrawPage::getSupportedServiceNames();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -129,12 +129,6 @@ void SAL_CALL SvxShapeGroup::release() throw ( )
SvxShape::release();
}
uno::Sequence< uno::Type > SAL_CALL SvxShapeGroup::getTypes()
throw (uno::RuntimeException, std::exception)
{
return SvxShape::getTypes();
}
uno::Sequence< sal_Int8 > SAL_CALL SvxShapeGroup::getImplementationId()
throw (uno::RuntimeException, std::exception)
{
@@ -367,14 +361,6 @@ sal_Bool SAL_CALL SvxShapeGroup::hasElements() throw( uno::RuntimeException, std
return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0);
}
// css::lang::XServiceInfo
uno::Sequence< OUString > SAL_CALL SvxShapeGroup::getSupportedServiceNames()
throw(uno::RuntimeException, std::exception)
{
return SvxShape::getSupportedServiceNames();
}
SvxShapeConnector::SvxShapeConnector( SdrObject* pObj ) throw() :
SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CONNECTOR), getSvxMapProvider().GetPropertySet(SVXMAP_CONNECTOR, SdrObject::GetGlobalDrawObjectItemPool()) )
{
@@ -519,14 +505,6 @@ void SAL_CALL SvxShapeConnector::disconnectEnd( const uno::Reference< drawing::X
mpModel->SetChanged();
}
// css::lang::XServiceInfo
uno::Sequence< OUString > SAL_CALL SvxShapeConnector::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
{
return SvxShapeText::getSupportedServiceNames();
}
SvxShapeControl::SvxShapeControl( SdrObject* pObj ) throw() :
SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CONTROL), getSvxMapProvider().GetPropertySet(SVXMAP_CONTROL, SdrObject::GetGlobalDrawObjectItemPool()) )
{
@@ -643,12 +621,6 @@ void SAL_CALL SvxShapeControl::setControl( const Reference< awt::XControlModel >
mpModel->SetChanged();
}
// XServiceInfo
uno::Sequence< OUString > SAL_CALL SvxShapeControl::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
{
return SvxShapeText::getSupportedServiceNames();
}
static struct
{
const sal_Char* mpAPIName;
@@ -991,11 +963,6 @@ SvxShapeDimensioning::~SvxShapeDimensioning() throw()
{
}
// css::lang::XServiceInfo
uno::Sequence< OUString > SAL_CALL SvxShapeDimensioning::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
{
return SvxShapeText::getSupportedServiceNames();
}
SvxShapeCircle::SvxShapeCircle( SdrObject* pObj ) throw()
: SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CIRCLE), getSvxMapProvider().GetPropertySet(SVXMAP_CIRCLE, SdrObject::GetGlobalDrawObjectItemPool()) )
{
@@ -1006,14 +973,6 @@ SvxShapeCircle::~SvxShapeCircle() throw()
{
}
// css::lang::XServiceInfo
// XServiceInfo
uno::Sequence< OUString > SAL_CALL SvxShapeCircle::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
{
return SvxShapeText::getSupportedServiceNames();
}
SvxShapePolyPolygon::SvxShapePolyPolygon( SdrObject* pObj , drawing::PolygonKind eNew )
throw( css::beans::PropertyVetoException, css::lang::IllegalArgumentException)
: SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_POLYPOLYGON), getSvxMapProvider().GetPropertySet(SVXMAP_POLYPOLYGON, SdrObject::GetGlobalDrawObjectItemPool()) )
@@ -1263,12 +1222,6 @@ basegfx::B2DPolyPolygon SvxShapePolyPolygon::GetPolygon() const throw()
}
}
// css::lang::XServiceInfo
uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygon::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
{
return SvxShapeText::getSupportedServiceNames();
}
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
#include <com/sun/star/drawing/FlagSequence.hpp>
@@ -1386,13 +1339,6 @@ basegfx::B2DPolyPolygon SvxShapePolyPolygonBezier::GetPolygon() const throw()
}
}
// css::lang::XServiceInfo
uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygonBezier::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
{
return SvxShapeText::getSupportedServiceNames();
}
SvxGraphicObject::SvxGraphicObject( SdrObject* pObj, OUString const & referer ) throw()
: SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_GRAPHICOBJECT), getSvxMapProvider().GetPropertySet(SVXMAP_GRAPHICOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ), referer_(referer)
{

View File

@@ -105,13 +105,6 @@ void SAL_CALL Svx3DSceneObject::release() throw ( )
// XTypeProvider
uno::Sequence< uno::Type > SAL_CALL Svx3DSceneObject::getTypes()
throw (uno::RuntimeException, std::exception)
{
return SvxShape::getTypes();
}
uno::Sequence< sal_Int8 > SAL_CALL Svx3DSceneObject::getImplementationId()
throw (uno::RuntimeException, std::exception)
{

View File

@@ -72,8 +72,6 @@ public:
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( )
throw (css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL getImplementationId( )
throw (css::uno::RuntimeException, std::exception) override;
// XTempFile
virtual sal_Bool SAL_CALL getRemoveFile()

View File

@@ -88,11 +88,6 @@ throw ( css::uno::RuntimeException, std::exception )
}
return pTypeCollection->getTypes();
};
css::uno::Sequence< sal_Int8 > SAL_CALL OTempFileService::getImplementationId( )
throw ( css::uno::RuntimeException, std::exception )
{
return OTempFileBase::getImplementationId();
}
// XTempFile