summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-11-10 13:39:08 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-11-10 19:13:38 +0100
commita11e0d428c7a17fd1d7689add10de413cc0ea81c (patch)
treebc2b796d2db011de85308e1227c326cdcb6f208e /compilerplugins
parent2b88ea29a183aa049b2e4d10414f4d43649874a9 (diff)
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>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/test/unnecessaryoverride.cxx12
-rw-r--r--compilerplugins/clang/unnecessaryoverride.cxx9
2 files changed, 21 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/unnecessaryoverride.cxx b/compilerplugins/clang/test/unnecessaryoverride.cxx
index f50869e542ee..91e8a4003296 100644
--- a/compilerplugins/clang/test/unnecessaryoverride.cxx
+++ b/compilerplugins/clang/test/unnecessaryoverride.cxx
@@ -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: */
diff --git a/compilerplugins/clang/unnecessaryoverride.cxx b/compilerplugins/clang/unnecessaryoverride.cxx
index 94713eb597df..07f902158efd 100644
--- a/compilerplugins/clang/unnecessaryoverride.cxx
+++ b/compilerplugins/clang/unnecessaryoverride.cxx
@@ -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())
{