[all-commits] [llvm/llvm-project] daa49c: [clang-tidy] Fix false positive in bugprone-use-af...

Peiqi Li via All-commits all-commits at lists.llvm.org
Wed Jun 10 00:54:12 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: daa49cfc2e01ff9df3400321ee308ec82b23ff34
      https://github.com/llvm/llvm-project/commit/daa49cfc2e01ff9df3400321ee308ec82b23ff34
  Author: Peiqi Li <voyager.lpq at gmail.com>
  Date:   2026-06-10 (Wed, 10 Jun 2026)

  Changed paths:
    M clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp

  Log Message:
  -----------
  [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



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list