[lldb] Use llvm::replace (NFC) (#140343)

This commit is contained in:
Kazu Hirata 2025-05-17 09:09:10 -07:00 committed by GitHub
parent fcef8a471e
commit 68e4f6090b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 12 additions and 15 deletions

View File

@ -3346,9 +3346,9 @@ bool CommandInterpreter::SaveTranscript(
CommandReturnObject &result, std::optional<std::string> output_file) {
if (output_file == std::nullopt || output_file->empty()) {
std::string now = llvm::to_string(std::chrono::system_clock::now());
std::replace(now.begin(), now.end(), ' ', '_');
llvm::replace(now, ' ', '_');
// Can't have file name with colons on Windows
std::replace(now.begin(), now.end(), ':', '-');
llvm::replace(now, ':', '-');
const std::string file_name = "lldb_session_" + now + ".log";
FileSpec save_location = GetSaveSessionDirectory();

View File

@ -251,8 +251,8 @@ TokenVerifier::TokenVerifier(std::string body) {
// We only care about tokens and not their original source locations. If we
// move the whole expression to only be in one line we can simplify the
// following code that extracts the token contents.
std::replace(body.begin(), body.end(), '\n', ' ');
std::replace(body.begin(), body.end(), '\r', ' ');
llvm::replace(body, '\n', ' ');
llvm::replace(body, '\r', ' ');
FileSystemOptions file_opts;
FileManager file_mgr(file_opts,

View File

@ -237,12 +237,9 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
// ScriptInterpreter. For now, we just replace dots with
// underscores, but if we ever support anything other than
// Python we will need to rework this
std::replace(module_basename.begin(), module_basename.end(), '.',
'_');
std::replace(module_basename.begin(), module_basename.end(), ' ',
'_');
std::replace(module_basename.begin(), module_basename.end(), '-',
'_');
llvm::replace(module_basename, '.', '_');
llvm::replace(module_basename, ' ', '_');
llvm::replace(module_basename, '-', '_');
ScriptInterpreter *script_interpreter =
target->GetDebugger().GetScriptInterpreter();
if (script_interpreter &&

View File

@ -60,7 +60,7 @@ void Denormalize(llvm::SmallVectorImpl<char> &path, FileSpec::Style style) {
if (PathStyleIsPosix(style))
return;
std::replace(path.begin(), path.end(), '/', '\\');
llvm::replace(path, '/', '\\');
}
} // end anonymous namespace
@ -186,7 +186,7 @@ void FileSpec::SetFile(llvm::StringRef pathname, Style style) {
// Normalize back slashes to forward slashes
if (m_style == Style::windows)
std::replace(resolved.begin(), resolved.end(), '\\', '/');
llvm::replace(resolved, '\\', '/');
if (resolved.empty()) {
// If we have no path after normalization set the path to the current

View File

@ -150,7 +150,7 @@ static void emitOptions(std::string Command, ArrayRef<const Record *> Records,
std::vector<CommandOption> Options(Records.begin(), Records.end());
std::string ID = Command;
std::replace(ID.begin(), ID.end(), ' ', '_');
llvm::replace(ID, ' ', '_');
// Generate the macro that the user needs to define before including the
// *.inc file.
std::string NeededMacro = "LLDB_OPTIONS_" + ID;

View File

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