summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/unnecessaryoverride.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-11-10 13:40:12 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-11-11 00:04:25 +0100
commit5d12237d79f289a1dcf8e07aa03df329e136f078 (patch)
tree1654bf34307bfc56b8db479e9934efb8a7cb1186 /compilerplugins/clang/unnecessaryoverride.cxx
parent1fc79c3491906d85ed9972e161112459035b62ed (diff)
loplugin:unnecessaryoverride: suppress warnings when default args differ
...instead of blacklisting such cases. Reuses the checkIdenticalDefaultArguments code that was originally in loplugin:overrideparam (and appears to work reasonably well for the default arguments that actually happen in practice). Change-Id: I9cf2db17101beb135b2039a9b7ed335bd2af2c08 Reviewed-on: https://gerrit.libreoffice.org/44594 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/unnecessaryoverride.cxx')
-rw-r--r--compilerplugins/clang/unnecessaryoverride.cxx16
1 files changed, 13 insertions, 3 deletions
diff --git a/compilerplugins/clang/unnecessaryoverride.cxx b/compilerplugins/clang/unnecessaryoverride.cxx
index 07f902158efd..13ed723385d8 100644
--- a/compilerplugins/clang/unnecessaryoverride.cxx
+++ b/compilerplugins/clang/unnecessaryoverride.cxx
@@ -258,15 +258,25 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
return true;
}
}
- // some very creative method hiding going on here
- if (loplugin::isSamePathname(aFileName, SRCDIR "/svx/source/dialog/checklbx.cxx"))
- return true;
const CXXMethodDecl* overriddenMethodDecl = findOverriddenOrSimilarMethodInSuperclasses(methodDecl);
if (!overriddenMethodDecl) {
return true;
}
+ // Check for differences in default parameters:
+ unsigned const numParams = methodDecl->getNumParams();
+ assert(overriddenMethodDecl->getNumParams() == numParams);
+ for (unsigned i = 0; i != numParams; ++i) {
+ if (checkIdenticalDefaultArguments(
+ methodDecl->getParamDecl(i)->getDefaultArg(),
+ overriddenMethodDecl->getParamDecl(i)->getDefaultArg())
+ != IdenticalDefaultArgumentsResult::Yes)
+ {
+ return true;
+ }
+ }
+
if (compat::getReturnType(*methodDecl).getCanonicalType()
!= compat::getReturnType(*overriddenMethodDecl).getCanonicalType())
{