https://github.com/shafik created 
https://github.com/llvm/llvm-project/pull/146127

Static analysis flagged some cases we could avoid copies by using std::move in 
Disasm.cpp.

>From 6dbfe12457e7fd7dbb62d4cb5d53b3206b78e492 Mon Sep 17 00:00:00 2001
From: Shafik Yaghmour <shafik.yaghm...@intel.com>
Date: Fri, 27 Jun 2025 10:43:30 -0700
Subject: [PATCH] [Clang][ByteCode][NFC] Avoid copies by using move in
 Disasm.cpp

Static analysis flagged some cases we could avoid copies by using std::move in
Disasm.cpp.
---
 clang/lib/AST/ByteCode/Disasm.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Disasm.cpp 
b/clang/lib/AST/ByteCode/Disasm.cpp
index a3eecd06369b1..f64501f4a31e8 100644
--- a/clang/lib/AST/ByteCode/Disasm.cpp
+++ b/clang/lib/AST/ByteCode/Disasm.cpp
@@ -63,7 +63,7 @@ template <> inline std::string printArg<Floating>(Program &P, 
CodePtr &OpPC) {
 
   std::string S;
   llvm::raw_string_ostream SS(S);
-  SS << Result;
+  SS << std::move(Result);
   return S;
 }
 
@@ -81,7 +81,7 @@ inline std::string printArg<IntegralAP<false>>(Program &P, 
CodePtr &OpPC) {
 
   std::string Str;
   llvm::raw_string_ostream SS(Str);
-  SS << Result;
+  SS << std::move(Result);
   return Str;
 }
 
@@ -99,7 +99,7 @@ inline std::string printArg<IntegralAP<true>>(Program &P, 
CodePtr &OpPC) {
 
   std::string Str;
   llvm::raw_string_ostream SS(Str);
-  SS << Result;
+  SS << std::move(Result);
   return Str;
 }
 
@@ -109,7 +109,7 @@ template <> inline std::string printArg<FixedPoint>(Program 
&P, CodePtr &OpPC) {
 
   std::string Result;
   llvm::raw_string_ostream SS(Result);
-  SS << F;
+  SS << std::move(F);
   return Result;
 }
 

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to