This revision was automatically updated to reflect the committed changes. Closed by commit rGeaa55590945a: [clang-tidy] misc-unused-parameters: Don't remove parameter from lambda (authored by mgehre).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77680/new/ https://reviews.llvm.org/D77680 Files: clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp Index: clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp +++ clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp @@ -276,3 +276,13 @@ // CHECK-FIXES: {{^}} B(int /*i*/) : A() {}{{$}} }; } // namespace strict_mode_off + +namespace lambda { +using fn = void(int); +void f(fn *); +void test() { + // CHECK-MESSAGES: :[[@LINE+2]]:12: warning: parameter 'I' is unused + // CHECK-FIXES: {{^}} f([](int /*I*/) { + f([](int I) { return; }); +} +} // namespace lambda Index: clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp +++ clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp @@ -8,6 +8,7 @@ #include "UnusedParametersCheck.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/ASTLambda.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Lex/Lexer.h" @@ -141,7 +142,8 @@ // Cannot remove parameter for non-local functions. if (Function->isExternallyVisible() || !Result.SourceManager->isInMainFile(Function->getLocation()) || - !Indexer->getOtherRefs(Function).empty() || isOverrideMethod(Function)) { + !Indexer->getOtherRefs(Function).empty() || isOverrideMethod(Function) || + isLambdaCallOperator(Function)) { // It is illegal to omit parameter name here in C code, so early-out. if (!Result.Context->getLangOpts().CPlusPlus)
Index: clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp +++ clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp @@ -276,3 +276,13 @@ // CHECK-FIXES: {{^}} B(int /*i*/) : A() {}{{$}} }; } // namespace strict_mode_off + +namespace lambda { +using fn = void(int); +void f(fn *); +void test() { + // CHECK-MESSAGES: :[[@LINE+2]]:12: warning: parameter 'I' is unused + // CHECK-FIXES: {{^}} f([](int /*I*/) { + f([](int I) { return; }); +} +} // namespace lambda Index: clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp +++ clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp @@ -8,6 +8,7 @@ #include "UnusedParametersCheck.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/ASTLambda.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Lex/Lexer.h" @@ -141,7 +142,8 @@ // Cannot remove parameter for non-local functions. if (Function->isExternallyVisible() || !Result.SourceManager->isInMainFile(Function->getLocation()) || - !Indexer->getOtherRefs(Function).empty() || isOverrideMethod(Function)) { + !Indexer->getOtherRefs(Function).empty() || isOverrideMethod(Function) || + isLambdaCallOperator(Function)) { // It is illegal to omit parameter name here in C code, so early-out. if (!Result.Context->getLangOpts().CPlusPlus)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits