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
This commit is contained in:
@@ -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]",
|
||||
|
Reference in New Issue
Block a user