-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[lldb] Use llvm::replace (NFC) #140343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_range_llvm_replace_lldb
May 17, 2025
Merged
[lldb] Use llvm::replace (NFC) #140343
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_range_llvm_replace_lldb
May 17, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-lldb Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/140343.diff 6 Files Affected:
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index eb4741feb0aa5..34749d890bf03 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -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();
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
index 3b601726388d6..1feeeb64aa9e5 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
@@ -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,
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 3c3a0aa992d9c..262a7dc731713 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -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 &&
diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp
index bb2b8647342b8..69d921643da2a 100644
--- a/lldb/source/Utility/FileSpec.cpp
+++ b/lldb/source/Utility/FileSpec.cpp
@@ -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
diff --git a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
index 735489c0e56a4..2507910d8a97a 100644
--- a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
+++ b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
@@ -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;
diff --git a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
index 8df87fda9f775..1d4495f9281b2 100644
--- a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
+++ b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
@@ -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.
|
tgymnich
approved these changes
May 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.