diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-10-12 13:09:08 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-10-12 13:10:55 +0200 |
commit | d1eee073ebcd2d4a99209bb12ab13a7cafbb5a89 (patch) | |
tree | 60d69cdf544fe93b0c77ea04ff34550ee643bb6b /compilerplugins | |
parent | 9c0304f5a725ad0a58afecb96862ecd298ffec06 (diff) |
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
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/unusedvariablecheck.cxx | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx index 65cac7573588..7d9a170153ca 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]", |