[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:54 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-tablegen

Author: None (JaydeepChauhan14)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/180785.diff


3 Files Affected:

- (modified) llvm/include/llvm/TableGen/TableGenBackend.h (+1-1) 
- (modified) llvm/lib/TableGen/Main.cpp (+1-1) 
- (modified) llvm/lib/TableGen/TableGenBackend.cpp (+1-1) 


``````````diff
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) {

``````````

</details>


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


More information about the llvm-commits mailing list