misc-unused-parameter: Ignore lambda static invokers.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248252 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
7128dda78c
Коммит
50a5da46a1
|
@ -101,6 +101,9 @@ void UnusedParametersCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
if (!Function->doesThisDeclarationHaveABody() ||
|
||||
!Function->hasWrittenPrototype())
|
||||
return;
|
||||
if (const auto *Method = dyn_cast<CXXMethodDecl>(Function))
|
||||
if (Method->isLambdaStaticInvoker())
|
||||
return;
|
||||
for (unsigned i = 0, e = Function->getNumParams(); i != e; ++i) {
|
||||
const auto *Param = Function->getParamDecl(i);
|
||||
if (Param->isUsed() || Param->isReferenced() || !Param->getDeclName() ||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// RUN: echo "static void staticFunctionHeader(int i) {}" > %T/header.h
|
||||
// RUN: echo "static void staticFunctionHeader(int /*i*/) {}" > %T/header-fixed.h
|
||||
// RUN: %python %S/check_clang_tidy.py %s misc-unused-parameters %t -header-filter='.*' -- -fno-delayed-template-parsing
|
||||
// RUN: %python %S/check_clang_tidy.py %s misc-unused-parameters %t -header-filter='.*' -- -std=c++11 -fno-delayed-template-parsing
|
||||
// RUN: diff %T/header.h %T/header-fixed.h
|
||||
|
||||
#include "header.h"
|
||||
|
@ -25,6 +25,9 @@ void c(int *i) {}
|
|||
void g(int i); // Don't remove stuff in declarations
|
||||
void h(int i) { (void)i; } // Don't remove used parameters
|
||||
|
||||
bool useLambda(int (*fn)(int));
|
||||
static bool static_var = useLambda([] (int a) { return a; });
|
||||
|
||||
// Remove parameters of local functions
|
||||
// ====================================
|
||||
static void staticFunctionA(int i);
|
||||
|
|
Загрузка…
Ссылка в новой задаче