Minor loplugin:unnecessaryoverride improvement

Change-Id: I3afb31b642a47e767dda0614d223b6b7f22e5d54
This commit is contained in:
Stephan Bergmann
2017-03-13 17:24:09 +01:00
parent e20d9867e2
commit 6661bdb076
3 changed files with 8 additions and 14 deletions

View File

@@ -114,10 +114,6 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
// operator to change from being an obsolete feature to being a standard // operator to change from being an obsolete feature to being a standard
// feature. That difference is not taken into account here. // feature. That difference is not taken into account here.
auto cls = methodDecl->getParent(); auto cls = methodDecl->getParent();
if (methodDecl->isVirtual() && cls->getNumBases() == 0)
{
return true;
}
if (methodDecl->getAccess() != AS_public) if (methodDecl->getAccess() != AS_public)
{ {
return true; return true;
@@ -131,6 +127,7 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
// if it's virtual, but it has a base-class with a non-virtual destructor // if it's virtual, but it has a base-class with a non-virtual destructor
if (methodDecl->isVirtual()) if (methodDecl->isVirtual())
{ {
bool baseWithVirtualDtor = false;
for (auto baseSpecifier = cls->bases_begin(); baseSpecifier != cls->bases_end(); ++baseSpecifier) for (auto baseSpecifier = cls->bases_begin(); baseSpecifier != cls->bases_end(); ++baseSpecifier)
{ {
const RecordType* baseRecordType = baseSpecifier->getType()->getAs<RecordType>(); const RecordType* baseRecordType = baseSpecifier->getType()->getAs<RecordType>();
@@ -138,15 +135,16 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
{ {
const CXXRecordDecl* baseRecordDecl = dyn_cast<CXXRecordDecl>(baseRecordType->getDecl()); const CXXRecordDecl* baseRecordDecl = dyn_cast<CXXRecordDecl>(baseRecordType->getDecl());
if (baseRecordDecl && baseRecordDecl->getDestructor() if (baseRecordDecl && baseRecordDecl->getDestructor()
&& !baseRecordDecl->getDestructor()->isVirtual()) && baseRecordDecl->getDestructor()->isVirtual())
{ {
return true; baseWithVirtualDtor = true;
break;
} }
} }
else }
{ if (!baseWithVirtualDtor)
return true; // dependent base {
} return true;
} }
} }
// corner case // corner case

View File

@@ -245,7 +245,6 @@ public:
SwUnoCursor& GetCursor(); SwUnoCursor& GetCursor();
sw::UnoCursorPointer m_pUnoCursor; sw::UnoCursorPointer m_pUnoCursor;
SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); } SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
virtual ~SwXTextTableCursor() override { };
}; };
struct SwRangeDescriptor struct SwRangeDescriptor

View File

@@ -192,9 +192,6 @@ public:
maTempFile.EnableKillingFile(); maTempFile.EnableKillingFile();
} }
virtual ~SwModelTestBase() override
{}
virtual void setUp() override virtual void setUp() override
{ {
test::BootstrapFixture::setUp(); test::BootstrapFixture::setUp();