mboehme added inline comments. Herald added a project: All.
================ Comment at: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp:403 hasArgument(0, declRefExpr().bind("arg")), - anyOf(hasAncestor(lambdaExpr().bind("containing-lambda")), - hasAncestor(functionDecl().bind("containing-func"))), ---------------- mboehme wrote: > I believe this can be done more simply. > > IIUC, the root of the problem is that a std::move() in a lambda capture is > being associated with the lambda, when in fact it should be associated with > the function that contains the lambda. > > This is because the `hasAncestor(lambdaExpr())` matches not just a > `std::move` inside the body of the lambda, but also in captures. > > I believe this can be solved simply by changing this line so that it only > matches a `std::move` inside the body of the lambda, i.e. something like this: > > ``` > hasAncestor(compoundStmt(hasParent(lambdaExpr().bind("containing-lambda")))) > ``` > > This would then no longer match a `std::move` in a capture; the existing > logic would instead associate it with the function that contains the lambda. > ``` It appears that this works: https://reviews.llvm.org/D126780 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119165/new/ https://reviews.llvm.org/D119165 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits