Author: Alex Langford Date: 2023-06-05T12:52:38-07:00 New Revision: 0bb6f832fbf8ae022063c07e2090f07832136bd4
URL: https://github.com/llvm/llvm-project/commit/0bb6f832fbf8ae022063c07e2090f07832136bd4 DIFF: https://github.com/llvm/llvm-project/commit/0bb6f832fbf8ae022063c07e2090f07832136bd4.diff LOG: [lldb][NFCI] Change return type of REPL::GetSourceFileBasename These don't really need to be in the ConstString StringPool. I've changed the return type to StringRef because on llvm.org and downstream in the swift fork, this returns a constant value. We could change it to return a std::string or something else if it needs to be able to change between calls. Differential Revision: https://reviews.llvm.org/D151962 Added: Modified: lldb/include/lldb/Expression/REPL.h lldb/source/Expression/REPL.cpp lldb/source/Plugins/REPL/Clang/ClangREPL.cpp lldb/source/Plugins/REPL/Clang/ClangREPL.h Removed: ################################################################################ diff --git a/lldb/include/lldb/Expression/REPL.h b/lldb/include/lldb/Expression/REPL.h index 1438afdf872bf..95a3a6ebae57e 100644 --- a/lldb/include/lldb/Expression/REPL.h +++ b/lldb/include/lldb/Expression/REPL.h @@ -131,7 +131,7 @@ class REPL : public IOHandlerDelegate, virtual Status DoInitialization() = 0; - virtual ConstString GetSourceFileBasename() = 0; + virtual llvm::StringRef GetSourceFileBasename() = 0; virtual const char *GetAutoIndentCharacters() = 0; diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp index e98ab1e575032..9bb7461e9ad79 100644 --- a/lldb/source/Expression/REPL.cpp +++ b/lldb/source/Expression/REPL.cpp @@ -57,14 +57,14 @@ lldb::REPLSP REPL::Create(Status &err, lldb::LanguageType language, } std::string REPL::GetSourcePath() { - ConstString file_basename = GetSourceFileBasename(); + llvm::StringRef file_basename = GetSourceFileBasename(); FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir(); if (tmpdir_file_spec) { tmpdir_file_spec.SetFilename(file_basename); m_repl_source_path = tmpdir_file_spec.GetPath(); } else { tmpdir_file_spec = FileSpec("/tmp"); - tmpdir_file_spec.AppendPathComponent(file_basename.GetStringRef()); + tmpdir_file_spec.AppendPathComponent(file_basename); } return tmpdir_file_spec.GetPath(); diff --git a/lldb/source/Plugins/REPL/Clang/ClangREPL.cpp b/lldb/source/Plugins/REPL/Clang/ClangREPL.cpp index 36d8ffe74f7c5..0aaddad53126e 100644 --- a/lldb/source/Plugins/REPL/Clang/ClangREPL.cpp +++ b/lldb/source/Plugins/REPL/Clang/ClangREPL.cpp @@ -62,8 +62,9 @@ lldb::REPLSP ClangREPL::CreateInstance(Status &error, Status ClangREPL::DoInitialization() { return Status(); } -ConstString ClangREPL::GetSourceFileBasename() { - return ConstString("repl.c"); +llvm::StringRef ClangREPL::GetSourceFileBasename() { + static constexpr llvm::StringLiteral g_repl("repl.c"); + return g_repl; } const char *ClangREPL::GetAutoIndentCharacters() { return " "; } diff --git a/lldb/source/Plugins/REPL/Clang/ClangREPL.h b/lldb/source/Plugins/REPL/Clang/ClangREPL.h index 46dcd676ef7ee..7d219c46189ea 100644 --- a/lldb/source/Plugins/REPL/Clang/ClangREPL.h +++ b/lldb/source/Plugins/REPL/Clang/ClangREPL.h @@ -36,7 +36,7 @@ class ClangREPL : public llvm::RTTIExtends<ClangREPL, REPL> { protected: Status DoInitialization() override; - ConstString GetSourceFileBasename() override; + llvm::StringRef GetSourceFileBasename() override; const char *GetAutoIndentCharacters() override; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits