[clang-tools-extra] [clang-tidy] bugprone-lambda-function-name ignore macro in captures (PR #89076)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 17 16:24:51 PDT 2024
================
@@ -69,9 +73,13 @@ void LambdaFunctionNameCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
}
void LambdaFunctionNameCheck::registerMatchers(MatchFinder *Finder) {
- // Match on PredefinedExprs inside a lambda.
- Finder->addMatcher(predefinedExpr(hasAncestor(lambdaExpr())).bind("E"),
- this);
+ Finder->addMatcher(
+ functionDecl(cxxMethodDecl(isInLambda()),
+ hasBody(hasDescendant(expr(
+ predefinedExpr(hasAncestor(functionDecl().bind("fn")))
+ .bind("E")))),
+ functionDecl(equalsBoundNode("fn"))),
+ this);
----------------
5chmidti wrote:
If you make the outer `functionDecl` the `cxxMethodDecl`, then you can remove the inner `cxxMethodDecl` that encloses the lambda. Or was there a reason for doing it this way?
You can also drop the `expr` matcher that surrounds the `predefinedExpr`, and the `functionDecl` surrounding the `equalsBoundNode`.
I.e.:
```c++
cxxMethodDecl(isInLambda(),
hasBody(hasDescendant(
predefinedExpr(hasAncestor(functionDecl().bind("fn")))
.bind("E"))),
equalsBoundNode("fn"))
```
https://github.com/llvm/llvm-project/pull/89076
More information about the cfe-commits
mailing list