================ @@ -18843,17 +18843,26 @@ void Sema::DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, LHSExpr = LHSExpr->IgnoreParenImpCasts(); RHSExpr = RHSExpr->IgnoreParenImpCasts(); - // Check for a call expression + // Check for a call expression or static_cast expression const CallExpr *CE = dyn_cast<CallExpr>(RHSExpr); - if (!CE || CE->getNumArgs() != 1) + const auto *CXXSCE = dyn_cast<CXXStaticCastExpr>(RHSExpr); + if (!CE && !CXXSCE) return; // Check for a call to std::move - if (!CE->isCallToStdMove()) + if (CE && (CE->getNumArgs() != 1 || !CE->isCallToStdMove())) return; - // Get argument from std::move - RHSExpr = CE->getArg(0); + // Check for a static_cast<T&&>(..) to an xvalue which we can treat as an + // inlined std::move + if (CXXSCE && !CXXSCE->isXValue()) + return; + + // Get argument from std::move or static_cast + if (CE) + RHSExpr = CE->getArg(0); + else + RHSExpr = CXXSCE->getSubExpr(); ---------------- tbaederr wrote:
```suggestion if (const auto *CE = dyn_cast<CallExpr>(RHSExpr); CE && CE->getNumArgs() == 1 && CE->isCallToStdMove()) RHSExpr = CE->getArg(0); else if (const auto *CXXSCE = dyn_cast<CXXStaticCastExpr>(RHSExpr); CXXSCE && CXXSCE->isXValue()) RHSExpr = CXXSCE->getSubExpr(); else return; ``` I think that would be shorter and cleaner. (This replaces the few lines above as well but I can't add a suggestion like that in Github). https://github.com/llvm/llvm-project/pull/76646 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits