void UnusedParametersCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
- parmVarDecl(hasAncestor(functionDecl().bind("function"))).bind("x"),
+ parmVarDecl(hasParent(functionDecl().bind("function"))).bind("x"),
this);
}
return;
const auto *Param = Result.Nodes.getNodeAs<ParmVarDecl>("x");
if (Param->isUsed() || Param->isReferenced() || !Param->getDeclName() ||
- Param->hasAttr<UnusedAttr>())
+ Param->hasAttr<UnusedAttr>())
return;
auto MyDiag = diag(Param->getLocation(), "parameter '%0' is unused")
// Handle local functions by deleting the parameters.
unsigned ParamIndex = Param->getFunctionScopeIndex();
+ assert(ParamIndex < Function->getNumParams());
+
// Fix all redeclarations.
for (const FunctionDecl *FD : Function->redecls())
MyDiag << removeParameter(FD, ParamIndex);
// CHECK-MESSAGES: :[[@LINE-1]]:66: warning
// CHECK-MESSAGES: :[[@LINE-2]]:71: warning
// CHECK-FIXES: {{^}}template <typename T> void someFunctionTemplateAllUnusedParams(T /*b*/, T /*e*/) {}
+
+static void dontGetConfusedByParametersInFunctionTypes() { void (*F)(int i); }