compilerplugins/clang/test/unnecessaryoverride.cxx | 12 ++++++++++++ compilerplugins/clang/unnecessaryoverride.cxx | 9 +++++++++ 2 files changed, 21 insertions(+)
New commits: commit a11e0d428c7a17fd1d7689add10de413cc0ea81c Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Nov 10 13:39:08 2017 +0100 loplugin:unnecessaryoverride: no warnings when fns are actually different Change-Id: I90d8af7a1affa459400b1cae4805e3a80b6c5200 Reviewed-on: https://gerrit.libreoffice.org/44593 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Stephan Bergmann <sberg...@redhat.com> 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()) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits