[clang] [clang][Sema] Warn on self move for inlined static cast (PR #76646)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 31 00:58:23 PST 2023


================
@@ -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 CXXStaticCastExpr *CXXSCE = dyn_cast<CXXStaticCastExpr>(RHSExpr);
----------------
tbaederr wrote:

```suggestion
  const auto *CXXSCE = dyn_cast<CXXStaticCastExpr>(RHSExpr);
```

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


More information about the cfe-commits mailing list