llvm-project
daa49cfc - [clang-tidy] Fix false positive in bugprone-use-after-move with std::forward on derived classes (#199905)

Commit
68 days ago
[clang-tidy] Fix false positive in bugprone-use-after-move with std::forward on derived classes (#199905) The `bugprone-use-after-move` check correctly identified partial moves when using `std::move` by matching the `ImplicitCastExpr` (DerivedToBase) as the parent of the call. However, when using `std::forward<Base>`, the cast occurs inside the argument, causing the matcher to miss the cast and falsely report a use-after-move. This patch uses `traverse(TK_AsIs, expr(hasParent(...)))` on the first argument to navigate bottom-up, reliably capturing the hidden `ImplicitCastExpr`. This ensures both partial moves and forwards are consistently recognized, eliminating the false positive. Assisted by AI to check code. Fixes #63202
Author
Parents
Loading