[clang-tools-extra] [clang-tidy] Let `bugprone-use-after-move` also handle calls to `std::forward` (PR #82673)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 23 06:59:36 PST 2024


================
@@ -359,24 +360,52 @@ void UseAfterMoveFinder::getReinits(
   }
 }
 
+enum class MoveType {
+  Move,    // std::move
+  Forward, // std::forward
+};
+
+static MoveType determineMoveType(const FunctionDecl *FuncDecl) {
+  if (FuncDecl->getName() == "move")
+    return MoveType::Move;
+  if (FuncDecl->getName() == "forward")
+    return MoveType::Forward;
+
+  assert(false && "Invalid move type");
----------------
5chmidti wrote:

Use `llvm_unreachable("Invalid move type")` if this code should truly be unreachable (which it is from what I can tell).

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


More information about the cfe-commits mailing list