forked from OSchip/llvm-project
misc-unused-parameters: Fix crasher with C forward declarations that
can leave out the parameter list. llvm-svn: 245048
This commit is contained in:
parent
90eb70c8a7
commit
ea223a7a6a
|
@ -84,7 +84,8 @@ void UnusedParametersCheck::warnOnUnusedParameter(
|
|||
|
||||
// Fix all redeclarations.
|
||||
for (const FunctionDecl *FD : Function->redecls())
|
||||
MyDiag << removeParameter(FD, ParamIndex);
|
||||
if (FD->param_size())
|
||||
MyDiag << removeParameter(FD, ParamIndex);
|
||||
|
||||
// Fix all call sites.
|
||||
auto CallMatches = ast_matchers::match(
|
||||
|
|
|
@ -7,6 +7,11 @@ void a(int i) {}
|
|||
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters]
|
||||
// CHECK-FIXES: {{^}}void a(int /*i*/) {}{{$}}
|
||||
|
||||
static void b(); // In C, forward declarations can leave out parameters.
|
||||
static void b(int i) {}
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i' is unused [misc-unused-parameters]
|
||||
// CHECK-FIXES: {{^}}static void b() {}{{$}}
|
||||
|
||||
// Unchanged cases
|
||||
// ===============
|
||||
void h(i, c, d) int i; char *c, *d; {} // Don't mess with K&R style
|
||||
|
|
Loading…
Reference in New Issue