[llvm] [NFC][TableGen] Use std::move to avoid copy (PR #180785)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 10 09:18:15 PST 2026


https://github.com/JaydeepChauhan14 created https://github.com/llvm/llvm-project/pull/180785

None

>From b55609681d66b6013ddf5af5a5f7d935c7ead3b4 Mon Sep 17 00:00:00 2001
From: Chauhan Jaydeep Ashwinbhai <chauhan.jaydeep.ashwinbhai at intel.com>
Date: Tue, 10 Feb 2026 09:17:43 -0800
Subject: [PATCH] [NFC][TableGen] Use std::move to avoid copy

---
 llvm/include/llvm/TableGen/TableGenBackend.h | 2 +-
 llvm/lib/TableGen/Main.cpp                   | 2 +-
 llvm/lib/TableGen/TableGenBackend.cpp        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/TableGen/TableGenBackend.h b/llvm/include/llvm/TableGen/TableGenBackend.h
index 8450a02eb19e7..2080b8245e11a 100644
--- a/llvm/include/llvm/TableGen/TableGenBackend.h
+++ b/llvm/include/llvm/TableGen/TableGenBackend.h
@@ -62,7 +62,7 @@ template <class EmitterC> class OptClass : Opt {
     std::string S;
     raw_string_ostream OS(S);
     EmitterC(RK).run(OS);
-    return {S, {}};
+    return {std::move(S), {}};
   }
 
 public:
diff --git a/llvm/lib/TableGen/Main.cpp b/llvm/lib/TableGen/Main.cpp
index ec4579f378dcb..cac70165b4131 100644
--- a/llvm/lib/TableGen/Main.cpp
+++ b/llvm/lib/TableGen/Main.cpp
@@ -214,7 +214,7 @@ int llvm::TableGenMain(const char *argv0, TableGenMainFn MainFn) {
     std::string S;
     raw_string_ostream OS(S);
     int Res = MainFn(OS, Records);
-    OutFiles = {S, {}};
+    OutFiles = {std::move(S), {}};
     return Res;
   });
 }
diff --git a/llvm/lib/TableGen/TableGenBackend.cpp b/llvm/lib/TableGen/TableGenBackend.cpp
index 116c3fcca8bd8..eabc4651b52c0 100644
--- a/llvm/lib/TableGen/TableGenBackend.cpp
+++ b/llvm/lib/TableGen/TableGenBackend.cpp
@@ -68,7 +68,7 @@ bool llvm::TableGen::Emitter::ApplyCallback(const RecordKeeper &Records,
     std::string S;
     raw_string_ostream OS(S);
     Fn.SingleFileGenerator(Records, OS);
-    OutFiles = {S, {}};
+    OutFiles = {std::move(S), {}};
     return false;
   }
   if (Fn.MultiFileGenerator) {



More information about the llvm-commits mailing list