Skip to content

[TableGen] Tach getInputFilename to return StringRef (NFC) #140690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kazutakahirata
Copy link
Contributor

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".

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".
@llvmbot
Copy link
Member

llvmbot commented May 20, 2025

@llvm/pr-subscribers-mlir

Author: Kazu Hirata (kazutakahirata)

Changes

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".


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

2 Files Affected:

  • (modified) llvm/include/llvm/TableGen/Record.h (+1-1)
  • (modified) mlir/lib/TableGen/CodeGenHelpers.cpp (+1-1)
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);

@kazutakahirata kazutakahirata merged commit 86f2fdd into llvm:main May 20, 2025
13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_drop_const_llvm_TableGen branch May 20, 2025 13:47
@topperc topperc changed the title [TableGen] Tach getInputFilename to return StringRef (NFC) [TableGen] Teach getInputFilename to return StringRef (NFC) May 29, 2025
@topperc topperc changed the title [TableGen] Teach getInputFilename to return StringRef (NFC) [TableGen] Tach getInputFilename to return StringRef (NFC) May 29, 2025
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
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".
ajaden-codes pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 6, 2025
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".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants