loplugin:unnecessaryoverride: no warnings when fns are actually different

Change-Id: I90d8af7a1affa459400b1cae4805e3a80b6c5200
Reviewed-on: https://gerrit.libreoffice.org/44593
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2017-11-10 13:39:08 +01:00
parent 2b88ea29a1
commit a11e0d428c
2 changed files with 21 additions and 0 deletions

View File

@@ -11,6 +11,10 @@ struct Base
{
virtual ~Base();
virtual void f();
void variadic(int, ...);
void cv() const volatile;
void ref();
static void staticFn();
};
struct SimpleDerived : Base
@@ -45,4 +49,12 @@ struct MultiClassDerived : Intermediate1, MultiClassIntermediate2
void f() override { Intermediate1::f(); } // no warning
};
struct DerivedDifferent : Base
{
void variadic(int x) { Base::variadic(x); } // no warning
void cv() { Base::cv(); } // no warning
void ref() && { Base::ref(); } // no warning
void staticFn() { Base::staticFn(); } // no warning
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */

View File

@@ -399,6 +399,15 @@ const CXXMethodDecl* UnnecessaryOverride::findOverriddenOrSimilarMethodInSupercl
if (!baseMethod->getDeclName().isIdentifier() || methodDecl->getName() != baseMethod->getName()) {
continue;
}
if (methodDecl->isStatic() != baseMethod->isStatic()
|| methodDecl->isConst() != baseMethod->isConst()
|| methodDecl->isVolatile() != baseMethod->isVolatile()
|| (methodDecl->getRefQualifier()
!= baseMethod->getRefQualifier())
|| methodDecl->isVariadic() != baseMethod->isVariadic())
{
continue;
}
if (compat::getReturnType(*methodDecl).getCanonicalType()
!= compat::getReturnType(*baseMethod).getCanonicalType())
{