[clang-tools-extra] [clang-tidy] Don't suggest const on `std::moved` locals in templates … (PR #226577)

Zeyi Xu via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 27 04:51:25 PDT 2026


================
@@ -199,6 +199,25 @@ void ConstCorrectnessCheck::registerMatchers(MatchFinder *Finder) {
   }
 }
 
+static bool isStdMoveOperandInTemplate(const VarDecl *Variable,
+                                       const FunctionDecl *Func,
+                                       ASTContext &Context) {
+  if (Func->isTemplateInstantiation())
+    if (const Stmt *Body = Func->getBody()) {
+      // Match on the instantiated body where `std::move` is resolved to a
+      // concrete function and the argument references the instantiated
+      // variable.
+      const auto Moves =
+          match(stmt(forEachDescendant(
+                    callExpr(callee(functionDecl(hasName("std::move"))),
+                             hasArgument(0, ignoringImpCasts(declRefExpr(
----------------
zeyi2 wrote:

Could we use `ignoringParenImpCasts` here?

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


More information about the cfe-commits mailing list