[llvm] fixed #95641 pointless string copy (PR #127325)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 15 06:01:03 PST 2025
https://github.com/sommersun created https://github.com/llvm/llvm-project/pull/127325
fixed #95641 by using std::move for T&&.
>From 4230d2138933eedb12ed1e9c8eec8e48ee106bed Mon Sep 17 00:00:00 2001
From: sxx <948074686 at qq.com>
Date: Sat, 15 Feb 2025 21:56:28 +0800
Subject: [PATCH] fixed #95641 pointless string copy
---
llvm/include/llvm/TableGen/Record.h | 3 ++-
llvm/lib/TableGen/Main.cpp | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index e04ed34823148..08d8e2a94c0aa 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -142,6 +142,7 @@ class BitsRecTy : public RecTy {
unsigned getNumBits() const { return Size; }
+
std::string getAsString() const override;
bool typeIsConvertibleTo(const RecTy *RHS) const override;
@@ -1966,7 +1967,7 @@ class RecordKeeper {
return It == ExtraGlobals.end() ? nullptr : It->second;
}
- void saveInputFilename(std::string Filename) {
+ void saveInputFilename(std::string && Filename) {
InputFilename = Filename;
}
diff --git a/llvm/lib/TableGen/Main.cpp b/llvm/lib/TableGen/Main.cpp
index 35600bf2f1f86..81b2e81dc6064 100644
--- a/llvm/lib/TableGen/Main.cpp
+++ b/llvm/lib/TableGen/Main.cpp
@@ -113,7 +113,7 @@ int llvm::TableGenMain(const char *argv0,
return reportError(argv0, "Could not open input file '" + InputFilename +
"': " + EC.message() + "\n");
- Records.saveInputFilename(InputFilename);
+ Records.saveInputFilename(std::move(InputFilename));
// Tell SrcMgr about this buffer, which is what TGParser will pick up.
SrcMgr.AddNewSourceBuffer(std::move(*FileOrErr), SMLoc());
More information about the llvm-commits
mailing list