[clang-tools-extra] [clang-tidy] Fix some false positive in bugprone-move-forwarding-reference (PR #191435)
Daniil Dudkin via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 11 01:02:42 PDT 2026
================
@@ -80,13 +88,16 @@ void MoveForwardingReferenceCheck::registerMatchers(MatchFinder *Finder) {
.bind("parm-var");
Finder->addMatcher(
- callExpr(callee(unresolvedLookupExpr(
- hasAnyDeclaration(namedDecl(
- hasUnderlyingDecl(hasName("::std::move")))))
- .bind("lookup")),
- argumentCountIs(1),
- hasArgument(0, ignoringParenImpCasts(declRefExpr(
- to(ForwardingReferenceParmMatcher)))))
+ callExpr(
+ callee(unresolvedLookupExpr(
+ hasAnyDeclaration(
+ namedDecl(hasUnderlyingDecl(hasName("::std::move")))))
+ .bind("lookup")),
+ argumentCountIs(1),
+ hasArgument(0, ignoringParenImpCasts(declRefExpr(
+ to(ForwardingReferenceParmMatcher),
+ // FIXME: allow capture by reference
----------------
unterumarmung wrote:
The intent probably was like you describe it. But it doesn't do what it is intended to do: `t` in the lambda is not a forwarding reference, it is just a reference and `std::forward` will never "move" it.
https://github.com/llvm/llvm-project/pull/191435
More information about the cfe-commits
mailing list