Skip to content

Commit 68e4f60

Browse files
[lldb] Use llvm::replace (NFC) (#140343)
1 parent fcef8a4 commit 68e4f60

File tree

6 files changed

+12
-15
lines changed

6 files changed

+12
-15
lines changed

lldb/source/Interpreter/CommandInterpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3346,9 +3346,9 @@ bool CommandInterpreter::SaveTranscript(
33463346
CommandReturnObject &result, std::optional<std::string> output_file) {
33473347
if (output_file == std::nullopt || output_file->empty()) {
33483348
std::string now = llvm::to_string(std::chrono::system_clock::now());
3349-
std::replace(now.begin(), now.end(), ' ', '_');
3349+
llvm::replace(now, ' ', '_');
33503350
// Can't have file name with colons on Windows
3351-
std::replace(now.begin(), now.end(), ':', '-');
3351+
llvm::replace(now, ':', '-');
33523352
const std::string file_name = "lldb_session_" + now + ".log";
33533353

33543354
FileSpec save_location = GetSaveSessionDirectory();

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ TokenVerifier::TokenVerifier(std::string body) {
251251
// We only care about tokens and not their original source locations. If we
252252
// move the whole expression to only be in one line we can simplify the
253253
// following code that extracts the token contents.
254-
std::replace(body.begin(), body.end(), '\n', ' ');
255-
std::replace(body.begin(), body.end(), '\r', ' ');
254+
llvm::replace(body, '\n', ' ');
255+
llvm::replace(body, '\r', ' ');
256256

257257
FileSystemOptions file_opts;
258258
FileManager file_mgr(file_opts,

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,9 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
237237
// ScriptInterpreter. For now, we just replace dots with
238238
// underscores, but if we ever support anything other than
239239
// Python we will need to rework this
240-
std::replace(module_basename.begin(), module_basename.end(), '.',
241-
'_');
242-
std::replace(module_basename.begin(), module_basename.end(), ' ',
243-
'_');
244-
std::replace(module_basename.begin(), module_basename.end(), '-',
245-
'_');
240+
llvm::replace(module_basename, '.', '_');
241+
llvm::replace(module_basename, ' ', '_');
242+
llvm::replace(module_basename, '-', '_');
246243
ScriptInterpreter *script_interpreter =
247244
target->GetDebugger().GetScriptInterpreter();
248245
if (script_interpreter &&

lldb/source/Utility/FileSpec.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void Denormalize(llvm::SmallVectorImpl<char> &path, FileSpec::Style style) {
6060
if (PathStyleIsPosix(style))
6161
return;
6262

63-
std::replace(path.begin(), path.end(), '/', '\\');
63+
llvm::replace(path, '/', '\\');
6464
}
6565

6666
} // end anonymous namespace
@@ -186,7 +186,7 @@ void FileSpec::SetFile(llvm::StringRef pathname, Style style) {
186186

187187
// Normalize back slashes to forward slashes
188188
if (m_style == Style::windows)
189-
std::replace(resolved.begin(), resolved.end(), '\\', '/');
189+
llvm::replace(resolved, '\\', '/');
190190

191191
if (resolved.empty()) {
192192
// If we have no path after normalization set the path to the current

lldb/utils/TableGen/LLDBOptionDefEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static void emitOptions(std::string Command, ArrayRef<const Record *> Records,
150150
std::vector<CommandOption> Options(Records.begin(), Records.end());
151151

152152
std::string ID = Command;
153-
std::replace(ID.begin(), ID.end(), ' ', '_');
153+
llvm::replace(ID, ' ', '_');
154154
// Generate the macro that the user needs to define before including the
155155
// *.inc file.
156156
std::string NeededMacro = "LLDB_OPTIONS_" + ID;

lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static void emityProperties(std::string PropertyName,
131131
// Generate the macro that the user needs to define before including the
132132
// *.inc file.
133133
std::string NeededMacro = "LLDB_PROPERTIES_" + PropertyName;
134-
std::replace(NeededMacro.begin(), NeededMacro.end(), ' ', '_');
134+
llvm::replace(NeededMacro, ' ', '_');
135135

136136
// All options are in one file, so we need put them behind macros and ask the
137137
// user to define the macro for the options that are needed.
@@ -154,7 +154,7 @@ static void emitPropertyEnum(std::string PropertyName,
154154
// Generate the macro that the user needs to define before including the
155155
// *.inc file.
156156
std::string NeededMacro = "LLDB_PROPERTIES_" + PropertyName;
157-
std::replace(NeededMacro.begin(), NeededMacro.end(), ' ', '_');
157+
llvm::replace(NeededMacro, ' ', '_');
158158

159159
// All options are in one file, so we need put them behind macros and ask the
160160
// user to define the macro for the options that are needed.

0 commit comments

Comments
 (0)