compilerplugins/clang/unusedvariablecheck.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
New commits: commit d1eee073ebcd2d4a99209bb12ab13a7cafbb5a89 Author: LuboÅ¡ LuÅák <[email protected]> Date: Fri Oct 12 13:09:08 2012 +0200 avoid crash on pointers to functions Clang's dyn_cast<> crashes on NULL, and getParentFunctionOrMethod() is NULL if the parameter is a part of a pointer-to-function declaration. Change-Id: Iee9eef488746f9a46bc090df8d318f27ad65f0ef diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx index 65cac75..7d9a170 100644 --- a/compilerplugins/clang/unusedvariablecheck.cxx +++ b/compilerplugins/clang/unusedvariablecheck.cxx @@ -83,7 +83,7 @@ bool UnusedVariableCheck::VisitNamedDecl( NamedDecl* declaration ) 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< FunctionDecl >( param->getParentFunctionOrMethod())) + if( const FunctionDecl* func = dyn_cast_or_null< FunctionDecl >( param->getParentFunctionOrMethod())) if( !func->doesThisDeclarationHaveABody()) return true; report( DiagnosticsEngine::Warning, "unused parameter %0 [loplugin]", commit 9c0304f5a725ad0a58afecb96862ecd298ffec06 Author: LuboÅ¡ LuÅák <[email protected]> Date: Fri Oct 12 12:59:31 2012 +0200 do not report unnamed parameters as unused Change-Id: I0cc44354085fbee15aa94d23c29830fd40e8d939 diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx index f291632..65cac75 100644 --- a/compilerplugins/clang/unusedvariablecheck.cxx +++ b/compilerplugins/clang/unusedvariablecheck.cxx @@ -79,6 +79,8 @@ bool UnusedVariableCheck::VisitNamedDecl( NamedDecl* declaration ) { if( const ParmVarDecl* param = dyn_cast< ParmVarDecl >( var )) { + if( !param->getDeclName()) + 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< FunctionDecl >( param->getParentFunctionOrMethod()))
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
