[clang] [clang-tools-extra] [clang-tidy] New performance linter: performance-use-std-move (PR #179467)

via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 7 02:59:47 PST 2026


================
@@ -0,0 +1,118 @@
+//===--- UseStdMoveCheck.cpp - clang-tidy ---------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "UseStdMoveCheck.h"
+
+#include "../utils/DeclRefExprUtils.h"
+
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h"
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/STLExtras.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::performance {
+
+namespace {
+AST_MATCHER(CXXRecordDecl, hasTrivialMoveAssignment) {
+  return Node.hasTrivialMoveAssignment();
+}
+
+AST_MATCHER(VarDecl, isMovableAndProfitable) {
+  const QualType NodeQual = Node.getType();
+
+  // Not profitable.
+  if (NodeQual->isScalarType())
+    return false;
+
+  // Not valid.
+  if (NodeQual->isLValueReferenceType() || NodeQual.isConstQualified())
+    return false;
+
+  return true;
+}
----------------
serge-sans-paille wrote:

Done

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


More information about the cfe-commits mailing list