[clang-tools-extra] [clang-tidy] Fix FP/FN in cppcoreguidelines-missing-std-forward (PR #178651)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 11 08:35:47 PST 2026


================
@@ -107,19 +107,21 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
 
   auto CapturedInLambda = hasDeclContext(cxxRecordDecl(
       isLambda(),
-      hasParent(lambdaExpr(forCallable(equalsBoundNode("func")),
-                           anyOf(CapturedInCaptureList, CapturedInBody)))));
+      hasAncestor(lambdaExpr(forCallable(equalsBoundNode("func")),
+                             anyOf(CapturedInCaptureList, CapturedInBody)))));
----------------
zwuis wrote:

IIUC he meant writing a new matcher to check if the argument of `forward` refers to function parameter, so that we can handle any combination of `[&]` (implicit capture), `[&t]` (explicit capture), and `[&x = t]` (rename).

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


More information about the cfe-commits mailing list