[llvm] [mlir] [TableGen] Tach getInputFilename to return StringRef (NFC) (PR #140690)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue May 20 00:27:45 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/140690
AFAICT, all callers of getInputFilename consume the string right away.
Nobody seems to rely on the "copy" behavior that comes with returning
"const std::string".
>From 22ca0746de7112a4ee4214851134c6544b13fcda Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 20 May 2025 00:04:36 -0700
Subject: [PATCH] [TableGen] Tach getInputFilename to return StringRef (NFC)
AFAICT, all callers of getInputFilename consume the string right away.
Nobody seems to rely on the "copy" behavior that comes with returning
"const std::string".
---
llvm/include/llvm/TableGen/Record.h | 2 +-
mlir/lib/TableGen/CodeGenHelpers.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index 593688e7cfc0e..5849344bcb0b5 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -1981,7 +1981,7 @@ class RecordKeeper {
detail::RecordKeeperImpl &getImpl() { return *Impl; }
/// Get the main TableGen input file's name.
- const std::string getInputFilename() const { return InputFilename; }
+ StringRef getInputFilename() const { return InputFilename; }
/// Get the map of classes.
const RecordMap &getClasses() const { return Classes; }
diff --git a/mlir/lib/TableGen/CodeGenHelpers.cpp b/mlir/lib/TableGen/CodeGenHelpers.cpp
index 0a07071fea217..f4031be24dfdb 100644
--- a/mlir/lib/TableGen/CodeGenHelpers.cpp
+++ b/mlir/lib/TableGen/CodeGenHelpers.cpp
@@ -27,7 +27,7 @@ using namespace mlir::tblgen;
static std::string getUniqueOutputLabel(const RecordKeeper &records,
StringRef tag) {
// Use the input file name when generating a unique name.
- std::string inputFilename = records.getInputFilename();
+ StringRef inputFilename = records.getInputFilename();
// Drop all but the base filename.
StringRef nameRef = sys::path::filename(inputFilename);
More information about the llvm-commits
mailing list