[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Enhance the check for the scenario with MemberExpr initialization. (PR #151936)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 6 09:56:24 PDT 2025


================
@@ -369,6 +387,18 @@ void UnnecessaryCopyInitialization::diagnoseCopyFromLocalVar(
   maybeIssueFixes(Ctx, Diagnostic);
 }
 
+void UnnecessaryCopyInitialization::diagnoseCopyFromConstLocalVarMember(
+    const CheckContext &Ctx, const VarDecl &OldVar) {
+  auto Diagnostic =
+      diag(Ctx.Var.getLocation(),
+           "local copy %1 of the field of the variable %0 is never "
----------------
vbvictor wrote:

Also, with the latest trunk type information of copied variables are emitted, please adjust your message.

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


More information about the cfe-commits mailing list