Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[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

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented May 17, 2025

@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/140343.diff

6 Files Affected:

  • (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+2-2)
  • (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp (+2-2)
  • (modified) lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (+3-6)
  • (modified) lldb/source/Utility/FileSpec.cpp (+2-2)
  • (modified) lldb/utils/TableGen/LLDBOptionDefEmitter.cpp (+1-1)
  • (modified) lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp (+2-2)
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.

@kazutakahirata kazutakahirata merged commit 68e4f60 into llvm:main May 17, 2025
12 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_range_llvm_replace_lldb branch May 17, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.