[clang-tools-extra] [clang-tidy] Ignore non-forwarded arguments if they are unnamed (PR #87832)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 7 00:17:20 PDT 2024


Danny =?utf-8?q?Mösch?= <danny.moesch at icloud.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/87832 at github.com>


================
@@ -125,12 +127,13 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
                    hasAncestor(expr(hasUnevaluatedContext())))));
 
   Finder->addMatcher(
-      parmVarDecl(parmVarDecl().bind("param"), isTemplateTypeParameter(),
-                  hasAncestor(functionDecl().bind("func")),
-                  hasAncestor(functionDecl(
-                      isDefinition(), equalsBoundNode("func"), ToParam,
-                      unless(anyOf(isDeleted(), hasDescendant(std::move(
-                                                    ForwardCallMatcher))))))),
+      parmVarDecl(
+          parmVarDecl().bind("param"), hasAnyName(), isTemplateTypeParameter(),
----------------
PiotrZSL wrote:


You should also ignore unused variables, like `[[maybe_unused]]` with:
```
unless(hasAttr(attr::Kind::Unused)),
```

And you could also use:
```
unless(isReferenced()),

with:

AST_MATCHER(VarDecl, isReferenced) { return Node.isReferenced(); }
```

https://github.com/llvm/llvm-project/pull/87832


More information about the cfe-commits mailing list