loplugin:unnecessaryoverride

Change-Id: I08c55a3023ec2e8990098eeb60e91cd18556e7ae
Reviewed-on: https://gerrit.libreoffice.org/29656
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2016-10-05 09:34:05 +02:00
parent 14a7ac2033
commit 62223f9a8a
24 changed files with 79 additions and 154 deletions

View File

@@ -39,6 +39,19 @@ public:
return;
if (fn == SRCDIR "/forms/source/component/Time.cxx")
return;
if (fn == SRCDIR "/svx/source/dialog/hyperdlg.cxx")
return;
if (fn == SRCDIR "/svx/source/dialog/rubydialog.cxx")
return;
if (fn.startswith(SRCDIR "/canvas"))
return;
if (fn == SRCDIR "/sc/source/ui/view/spelldialog.cxx")
return;
if (fn == SRCDIR "/sd/source/ui/dlg/SpellDialogChildWindow.cxx")
return;
// HAVE_ODBC_ADMINISTRATION
if (fn == SRCDIR "/dbaccess/source/ui/dlg/dsselect.cxx")
return;
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
@@ -72,6 +85,10 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
// entertaining template magic
if (aFileName == SRCDIR "/sc/source/ui/vba/vbaformatcondition.cxx")
return true;
// not sure what is going on here, but removing the override causes a crash
if (methodDecl->getQualifiedNameAsString() == "SwXTextDocument::queryAdapter")
return true;
const CXXMethodDecl* overriddenMethodDecl = *methodDecl->begin_overridden_methods();
@@ -80,11 +97,22 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
{
return true;
}
if (methodDecl->getAccess() == AS_public && overriddenMethodDecl->getAccess() == AS_protected)
return true;
//TODO: check for identical exception specifications
const CompoundStmt* compoundStmt = dyn_cast<CompoundStmt>(methodDecl->getBody());
if (!compoundStmt || compoundStmt->size() != 1)
return true;
const CXXMemberCallExpr* callExpr;
if (compat::getReturnType(*methodDecl).getCanonicalType()->isVoidType())
{
callExpr = dyn_cast<CXXMemberCallExpr>(*compoundStmt->body_begin());
}
else
{
auto returnStmt = dyn_cast<ReturnStmt>(*compoundStmt->body_begin());
if (returnStmt == nullptr) {
return true;
@@ -120,22 +148,27 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
// CXXBindTemporaryExpr in between:
if (auto ctorExpr = dyn_cast<CXXConstructExpr>(returnExpr)) {
if (ctorExpr->getNumArgs() == 1) {
if (auto tempExpr = dyn_cast<CXXBindTemporaryExpr>(
ctorExpr->getArg(0)->IgnoreImplicit()))
auto tempExpr1 = ctorExpr->getArg(0)->IgnoreImplicit();
if (auto tempExpr2 = dyn_cast<CXXBindTemporaryExpr>(tempExpr1))
{
returnExpr = tempExpr->getSubExpr();
returnExpr = tempExpr2->getSubExpr();
}
else if (auto tempExpr2 = dyn_cast<CXXMemberCallExpr>(tempExpr1))
{
returnExpr = tempExpr2;
}
}
}
const CXXMemberCallExpr* callExpr = dyn_cast<CXXMemberCallExpr>(
returnExpr->IgnoreParenImpCasts());
callExpr = dyn_cast<CXXMemberCallExpr>(returnExpr->IgnoreParenImpCasts());
}
if (!callExpr || callExpr->getMethodDecl() != overriddenMethodDecl)
return true;
const ImplicitCastExpr* expr1 = dyn_cast_or_null<ImplicitCastExpr>(callExpr->getImplicitObjectArgument());
const Expr* expr1 = callExpr->getImplicitObjectArgument()->IgnoreImpCasts();
if (!expr1)
return true;
const CXXThisExpr* expr2 = dyn_cast_or_null<CXXThisExpr>(expr1->getSubExpr());
const CXXThisExpr* expr2 = dyn_cast_or_null<CXXThisExpr>(expr1);
if (!expr2)
return true;
for (unsigned i = 0; i<callExpr->getNumArgs(); ++i) {
@@ -148,7 +181,8 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
report(
DiagnosticsEngine::Warning, "%0 virtual function just calls %1 parent",
methodDecl->getSourceRange().getBegin())
<< methodDecl->getAccess() << overriddenMethodDecl->getAccess()
<< methodDecl->getAccess()
<< overriddenMethodDecl->getAccess()
<< methodDecl->getSourceRange();
if (methodDecl->getCanonicalDecl()->getLocation() != methodDecl->getLocation()) {
const CXXMethodDecl* pOther = methodDecl->getCanonicalDecl();

View File

@@ -61,11 +61,6 @@ OCatalog::~OCatalog()
delete m_pUsers;
}
void SAL_CALL OCatalog::acquire() throw()
{
OCatalog_BASE::acquire();
}
void SAL_CALL OCatalog::release() throw()
{
release_ChildImpl();

View File

@@ -183,11 +183,6 @@ namespace drawinglayer
{
}
bool SdrCubePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
{
return SdrPrimitive3D::operator==(rPrimitive);
}
basegfx::B3DRange SdrCubePrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const
{
// use default from sdrPrimitive3D which uses transformation expanded by line width/2.

View File

@@ -99,12 +99,6 @@ namespace accessibility
}
}
uno::Any SAL_CALL AccessibleImageBullet::queryInterface (const uno::Type & rType) throw (uno::RuntimeException, std::exception)
{
return AccessibleImageBulletInterfaceBase::queryInterface(rType);
}
uno::Reference< XAccessibleContext > SAL_CALL AccessibleImageBullet::getAccessibleContext( ) throw (uno::RuntimeException, std::exception)
{

View File

@@ -31,8 +31,6 @@ typedef SvRefMemberList< SvMetaSlot* > SvSlotElementList;
class SvMetaAttribute : public SvMetaReference
{
public:
virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase,
SvTokenStream & rInStm ) override;
tools::SvRef<SvMetaType> aType;
SvIdentifier aSlotId;
SvMetaAttribute();

View File

@@ -97,12 +97,6 @@ bool SvMetaAttribute::ReadSvIdl( SvIdlDataBase & rBase,
return bOk;
}
void SvMetaAttribute::ReadAttributesSvIdl( SvIdlDataBase & rBase,
SvTokenStream & rInStm )
{
SvMetaReference::ReadAttributesSvIdl( rBase, rInStm );
}
sal_uLong SvMetaAttribute::MakeSfx( OStringBuffer& rAttrArray )
{
SvMetaType * pType = GetType();

View File

@@ -105,7 +105,6 @@ namespace connectivity
// ::cppu::OComponentHelper
virtual void SAL_CALL disposing() override;
// XInterface
void SAL_CALL acquire() throw() override;
void SAL_CALL release() throw() override;
// XTablesSupplier
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables( ) throw(css::uno::RuntimeException, std::exception) override;

View File

@@ -49,9 +49,6 @@ namespace drawinglayer
const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute);
/// compare operator
virtual bool operator==(const BasePrimitive3D& rPrimitive) const override;
/// get range
virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const override;

View File

@@ -53,9 +53,6 @@ namespace accessibility
virtual ~AccessibleImageBullet () override;
// XInterface
virtual css::uno::Any SAL_CALL queryInterface (const css::uno::Type & rType) throw (css::uno::RuntimeException, std::exception) override;
// XAccessible
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (css::uno::RuntimeException, std::exception) override;

View File

@@ -67,8 +67,6 @@ public:
basegfx::B2DHomMatrix& aTransformation,
::oox::drawingml::ShapeIdMap* pShapeMap = nullptr );
virtual void applyShapeReference( const oox::drawingml::Shape& rReferencedShape, bool bUseText = true ) override;
ShapeLocation getShapeLocation() const { return meShapeLocation; };
void setReferenced( bool bReferenced ){ mbReferenced = bReferenced; };
void setPlaceholder( oox::drawingml::ShapePtr pPlaceholder ) { mpPlaceholder = pPlaceholder; }

View File

@@ -49,7 +49,6 @@ public:
virtual ~ScreenshotTest() override;
virtual void setUp() override;
virtual void tearDown() override;
/// Dialog creation for known dialogs by Name (path and UIXMLDescription, *.ui file).
/// This uses maKnownDialogs to check if known, and if so, calls createDialogByID

View File

@@ -378,7 +378,6 @@ public:
virtual ~VCLXFrame() override;
// css::uno::XInterface
css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception) override;
void SAL_CALL acquire() throw() override { OWeakObject::acquire(); }
void SAL_CALL release() throw() override { OWeakObject::release(); }
@@ -452,7 +451,6 @@ public:
virtual ~VCLXTabPage() override;
// css::uno::XInterface
css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception) override;
void SAL_CALL acquire() throw() override { OWeakObject::acquire(); }
void SAL_CALL release() throw() override { OWeakObject::release(); }

View File

@@ -88,8 +88,6 @@ public:
virtual css::uno::Reference< ov::msforms::XShapeRange > SAL_CALL Range( const css::uno::Any& shapes ) throw (css::uno::RuntimeException, std::exception) override;
// ScVbaCollectionBaseImpl
virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) throw (css::uno::RuntimeException) override;
virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& Index2)
throw (css::lang::IndexOutOfBoundsException, css::script::BasicErrorException, css::uno::RuntimeException) override;
};
#endif // INCLUDED_VBAHELPER_VBASHAPES_HXX

View File

@@ -174,7 +174,6 @@ public:
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
virtual void CreateAndInsert(bool bOverwrite) override;
virtual void Finish(bool bOverwrite) override;
SvXMLNumImpData* GetData() const { return pData; }
sal_Int32 GetKey();

View File

@@ -376,11 +376,6 @@ void PPTShape::addShape(
}
}
void PPTShape::applyShapeReference( const oox::drawingml::Shape& rReferencedShape, bool bUseText )
{
Shape::applyShapeReference( rReferencedShape, bUseText );
}
namespace
{
bool ShapeLocationIsMaster(oox::drawingml::Shape *pInShape)

View File

@@ -50,7 +50,6 @@ class ParserTest: public test::BootstrapFixture
public:
virtual void setUp() override;
virtual void tearDown() override;
void parse();
@@ -70,11 +69,6 @@ void ParserTest::setUp()
mxParser->setTokenHandler( mxTokenHandler.get() );
}
void ParserTest::tearDown()
{
test::BootstrapFixture::tearDown();
}
uno::Reference< io::XInputStream > ParserTest::createStream(const OString& sInput)
{
uno::Reference< io::XOutputStream > xPipe( io::Pipe::create(m_xContext) );

View File

@@ -343,7 +343,6 @@ private:
public:
virtual void setUp() override;
virtual void tearDown() override;
XMLImportTest() : BootstrapFixture(true, false) {}
void parse();
@@ -390,11 +389,6 @@ void XMLImportTest::setUp()
m_sDirPath = m_directories.getPathFromSrc( "/sax/qa/data/" );
}
void XMLImportTest::tearDown()
{
test::BootstrapFixture::tearDown();
}
void XMLImportTest::parse()
{
OUString fileNames[] = {"simple.xml", "defaultns.xml", "inlinens.xml",

View File

@@ -66,8 +66,6 @@ class Test : public test::BootstrapFixture, public XmlTestTools
Primitive2DSequence parseSvg(const char* aSource);
public:
virtual void tearDown() override;
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testStyles);
CPPUNIT_TEST(testTdf87309);
@@ -115,11 +113,6 @@ Primitive2DSequence Test::parseSvg(const char* aSource)
return xSvgParser->getDecomposition(aInputStream, aPath);
}
void Test::tearDown()
{
BootstrapFixture::tearDown();
}
void Test::checkRectPrimitive(Primitive2DSequence& rPrimitive)
{
Primitive2dXmlDump dumper;

View File

@@ -59,11 +59,6 @@ void ScreenshotTest::setUp()
}
}
void ScreenshotTest::tearDown()
{
test::BootstrapFixture::tearDown();
}
void ScreenshotTest::implSaveScreenshot(const Bitmap& rScreenshot, const OString& rScreenshotId)
{
OUString aDirname, aBasename;

View File

@@ -2727,12 +2727,6 @@ VCLXTabPage::~VCLXTabPage()
{
}
css::uno::Any SAL_CALL VCLXTabPage::queryInterface(const css::uno::Type & rType )
throw(css::uno::RuntimeException, std::exception)
{
return VCLXContainer::queryInterface( rType );
}
// css::lang::XTypeProvider
IMPL_XTYPEPROVIDER_START( VCLXTabPage )
VCLXContainer::getTypes()
@@ -6537,12 +6531,6 @@ VCLXFrame::~VCLXFrame()
{
}
css::uno::Any SAL_CALL VCLXFrame::queryInterface(const css::uno::Type & rType )
throw(css::uno::RuntimeException, std::exception)
{
return VCLXContainer::queryInterface( rType );
}
// css::lang::XTypeProvider
IMPL_XTYPEPROVIDER_START( VCLXFrame )
VCLXContainer::getTypes()

View File

@@ -320,11 +320,6 @@ namespace cmis
XTYPEPROVIDER_COMMON_IMPL( RepoContent );
uno::Any SAL_CALL RepoContent::queryInterface( const uno::Type & rType ) throw ( uno::RuntimeException, std::exception )
{
return ContentImplHelper::queryInterface(rType);
}
OUString SAL_CALL RepoContent::getImplementationName() throw( uno::RuntimeException, std::exception )
{
return OUString("com.sun.star.comp.CmisRepoContent");

View File

@@ -89,8 +89,6 @@ public:
virtual OUString getParentURL() override;
// XInterface
virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
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

@@ -173,23 +173,6 @@ ScVbaShapes::getShapesByArrayIndices( const uno::Any& Index ) throw (uno::Runti
return xIndexAccess;
}
uno::Any SAL_CALL
ScVbaShapes::Item(const uno::Any& Index, const uno::Any& Index2)
throw (lang::IndexOutOfBoundsException, script::BasicErrorException, uno::RuntimeException)
{
// I don't think we need to support Array of indices for shapes
/*
if ( Index.getValueTypeClass() == uno::TypeClass_SEQUENCE )
{
uno::Reference< container::XIndexAccess > xIndexAccess( getShapesByArrayIndices( Index ) );
// return new collection instance
uno::Reference< XCollection > xShapesCollection( new ScVbaShapes( this->getParent(), mxContext, xIndexAccess ) );
return uno::makeAny( xShapesCollection );
}
*/
return ScVbaShapes_BASE::Item( Index, Index2 );
}
uno::Reference< msforms::XShapeRange > SAL_CALL
ScVbaShapes::Range( const uno::Any& shapes ) throw (css::uno::RuntimeException, std::exception)
{

View File

@@ -1829,11 +1829,6 @@ sal_Int32 SvXMLNumFormatContext::CreateAndInsert(SvNumberFormatter* pFormatter)
return nKey;
}
void SvXMLNumFormatContext::Finish( bool bOverwrite )
{
SvXMLStyleContext::Finish( bOverwrite );
}
const LocaleDataWrapper& SvXMLNumFormatContext::GetLocaleData() const
{
return pData->GetLocaleData( nFormatLang );