compilerplugins/clang/unusedvariablecheck.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
New commits: commit b927eaa6db173702eb81ca610e751b157978fd9e Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Dec 21 11:18:36 2021 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Tue Dec 21 13:31:35 2021 +0100 Fix loplugin:unusedvariablecheck ...on macOS, where it started to cause false positives like > vcl/inc/osx/a11ywrapper.h:89:98: error: unused parameter 'anAccessibleContext' [loplugin:unusedvariablecheck] > -(id)initWithAccessibleContext: (css::uno::Reference < css::accessibility::XAccessibleContext >) anAccessibleContext; > ^ after a214369f14d3f53d45b1889827057882c0ffd62e "loplugin:unusedvariablecheck improve" Change-Id: I450df3a6d768b4452d0975b5920ea0b3ce53ce13 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127220 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx index c3adfa5b726e..f155219942b6 100644 --- a/compilerplugins/clang/unusedvariablecheck.cxx +++ b/compilerplugins/clang/unusedvariablecheck.cxx @@ -80,9 +80,15 @@ bool UnusedVariableCheck::VisitVarDecl( const VarDecl* var ) return true; // unnamed parameter -> unused // If this declaration does not have a body, then the parameter is indeed not used, // so ignore. - if( const FunctionDecl* func = dyn_cast_or_null< FunctionDecl >( param->getParentFunctionOrMethod())) + auto const parent = param->getParentFunctionOrMethod(); + if( const FunctionDecl* func = dyn_cast_or_null< FunctionDecl >( parent)) if( !func->doesThisDeclarationHaveABody() || func->getBody() == nullptr) return true; + if (auto const d = dyn_cast_or_null<ObjCMethodDecl>(parent)) { + if (!d->hasBody()) { + return true; + } + } report( DiagnosticsEngine::Warning, "unused parameter %0", var->getLocation()) << var->getDeclName(); }