summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-12-21 11:18:36 +0100
committerStephan Bergmann <sbergman@redhat.com>2021-12-21 13:31:35 +0100
commitb927eaa6db173702eb81ca610e751b157978fd9e (patch)
treeb3a5b96fa0daf48efea62b232500e958a76f347e /compilerplugins
parent8d7e266943447a97ad09caebc263f3b2d6abdbde (diff)
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 <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/unusedvariablecheck.cxx8
1 files changed, 7 insertions, 1 deletions
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();
}