Skip to content

Commit 0bb6f83

Browse files
committed
[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
1 parent 73464e3 commit 0bb6f83

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

lldb/include/lldb/Expression/REPL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class REPL : public IOHandlerDelegate,
131131

132132
virtual Status DoInitialization() = 0;
133133

134-
virtual ConstString GetSourceFileBasename() = 0;
134+
virtual llvm::StringRef GetSourceFileBasename() = 0;
135135

136136
virtual const char *GetAutoIndentCharacters() = 0;
137137

lldb/source/Expression/REPL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ lldb::REPLSP REPL::Create(Status &err, lldb::LanguageType language,
5757
}
5858

5959
std::string REPL::GetSourcePath() {
60-
ConstString file_basename = GetSourceFileBasename();
60+
llvm::StringRef file_basename = GetSourceFileBasename();
6161
FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir();
6262
if (tmpdir_file_spec) {
6363
tmpdir_file_spec.SetFilename(file_basename);
6464
m_repl_source_path = tmpdir_file_spec.GetPath();
6565
} else {
6666
tmpdir_file_spec = FileSpec("/tmp");
67-
tmpdir_file_spec.AppendPathComponent(file_basename.GetStringRef());
67+
tmpdir_file_spec.AppendPathComponent(file_basename);
6868
}
6969

7070
return tmpdir_file_spec.GetPath();

lldb/source/Plugins/REPL/Clang/ClangREPL.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ lldb::REPLSP ClangREPL::CreateInstance(Status &error,
6262

6363
Status ClangREPL::DoInitialization() { return Status(); }
6464

65-
ConstString ClangREPL::GetSourceFileBasename() {
66-
return ConstString("repl.c");
65+
llvm::StringRef ClangREPL::GetSourceFileBasename() {
66+
static constexpr llvm::StringLiteral g_repl("repl.c");
67+
return g_repl;
6768
}
6869

6970
const char *ClangREPL::GetAutoIndentCharacters() { return " "; }

lldb/source/Plugins/REPL/Clang/ClangREPL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ClangREPL : public llvm::RTTIExtends<ClangREPL, REPL> {
3636
protected:
3737
Status DoInitialization() override;
3838

39-
ConstString GetSourceFileBasename() override;
39+
llvm::StringRef GetSourceFileBasename() override;
4040

4141
const char *GetAutoIndentCharacters() override;
4242

0 commit comments

Comments
 (0)