[Lldb-commits] [PATCH] D151962: [lldb][NFCI] Change return type of REPL::GetSourceFileBasename
Alex Langford via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 1 18:39:03 PDT 2023
bulbazord created this revision.
bulbazord added reviewers: wallace, jingham, mib.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151962
Files:
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
Index: lldb/source/Plugins/REPL/Clang/ClangREPL.h
===================================================================
--- lldb/source/Plugins/REPL/Clang/ClangREPL.h
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.h
@@ -36,7 +36,7 @@
protected:
Status DoInitialization() override;
- ConstString GetSourceFileBasename() override;
+ llvm::StringRef GetSourceFileBasename() override;
const char *GetAutoIndentCharacters() override;
Index: lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
===================================================================
--- lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
@@ -62,8 +62,9 @@
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 " "; }
Index: lldb/source/Expression/REPL.cpp
===================================================================
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -57,14 +57,14 @@
}
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();
Index: lldb/include/lldb/Expression/REPL.h
===================================================================
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -131,7 +131,7 @@
virtual Status DoInitialization() = 0;
- virtual ConstString GetSourceFileBasename() = 0;
+ virtual llvm::StringRef GetSourceFileBasename() = 0;
virtual const char *GetAutoIndentCharacters() = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151962.527699.patch
Type: text/x-patch
Size: 2227 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230602/9a818dc2/attachment.bin>
More information about the lldb-commits
mailing list