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

Peiqi Li via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 2 05:35:29 PDT 2026


================
@@ -641,6 +641,14 @@ void UseAfterMoveCheck::check(const MatchFinder::MatchResult &Result) {
   const CXXRecordDecl *MovedAs =
       ParentCast ? ParentCast->getType()->getAsCXXRecordDecl() : nullptr;
 
+  if (!MovedAs && CallMove && CallMove->getNumArgs() > 0) {
+    if (const auto *ArgCast =
+            dyn_cast<ImplicitCastExpr>(CallMove->getArg(0)->IgnoreParens())) {
+      if (ArgCast->getCastKind() == CK_DerivedToBase)
+        MovedAs = ArgCast->getType()->getAsCXXRecordDecl();
+    }
+  }
----------------
voyager-jhk wrote:

ok,I will.

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


More information about the cfe-commits mailing list