https://github.com/bulbazord created https://github.com/llvm/llvm-project/pull/214874
Basename is read-only, so it can be a StringRef. Similarly, there's no need to create a ConstString of a dylib name that may or may not exist. >From 5bba84c235fba595899f9f65d46c5ed6cb0d350d Mon Sep 17 00:00:00 2001 From: Alex Langford <[email protected]> Date: Fri, 7 Aug 2026 15:45:03 -0700 Subject: [PATCH] [lldb] Replace ConstString in Platform::GetFullNameForDylib Basename is read-only, so it can be a StringRef. Similarly, there's no need to create a ConstString of a dylib name that may or may not exist. --- lldb/include/lldb/Target/Platform.h | 2 +- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp | 10 ++++------ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h | 2 +- lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 10 ++++------ lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h | 2 +- .../Plugins/Platform/Windows/PlatformWindows.cpp | 10 ++++------ lldb/source/Plugins/Platform/Windows/PlatformWindows.h | 2 +- lldb/source/Target/Platform.cpp | 4 ++-- 8 files changed, 18 insertions(+), 24 deletions(-) diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 8760cb9fc6a8c..bf7a3faf30eaf 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -204,7 +204,7 @@ class Platform : public PluginInterface { virtual const char *GetHostname(); - virtual ConstString GetFullNameForDylib(ConstString basename); + virtual std::string GetFullNameForDylib(llvm::StringRef basename); virtual llvm::StringRef GetDescription() = 0; diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 8efe164dd2901..daddc2b162ef4 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1249,13 +1249,11 @@ void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType( } } -ConstString PlatformDarwin::GetFullNameForDylib(ConstString basename) { - if (basename.IsEmpty()) - return basename; +std::string PlatformDarwin::GetFullNameForDylib(llvm::StringRef basename) { + if (basename.empty()) + return basename.str(); - StreamString stream; - stream.Printf("lib%s.dylib", basename.GetCString()); - return ConstString(stream.GetString()); + return llvm::formatv("lib{0}.dylib", basename).str(); } llvm::VersionTuple PlatformDarwin::GetOSVersion(Process *process) { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h index 7c10216bb8b2e..3415f74a8fbe8 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h @@ -110,7 +110,7 @@ class PlatformDarwin : public PlatformPOSIX { bool SupportsModules() override { return true; } - ConstString GetFullNameForDylib(ConstString basename) override; + std::string GetFullNameForDylib(llvm::StringRef basename) override; FileSpec LocateExecutable(const char *basename) override; diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index 1a62145083f8f..d297b97ab24f7 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -999,11 +999,9 @@ PlatformPOSIX::GetLibdlFunctionDeclarations(lldb_private::Process *process) { )"; } -ConstString PlatformPOSIX::GetFullNameForDylib(ConstString basename) { - if (basename.IsEmpty()) - return basename; +std::string PlatformPOSIX::GetFullNameForDylib(llvm::StringRef basename) { + if (basename.empty()) + return basename.str(); - StreamString stream; - stream.Printf("lib%s.so", basename.GetCString()); - return ConstString(stream.GetString()); + return llvm::formatv("lib{0}.so", basename).str(); } diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h index 511797ce6bb7c..0a02ecd279cfe 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h @@ -67,7 +67,7 @@ class PlatformPOSIX : public lldb_private::RemoteAwarePlatform { lldb_private::Status UnloadImage(lldb_private::Process *process, uint32_t image_token) override; - lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override; + std::string GetFullNameForDylib(llvm::StringRef basename) override; protected: std::unique_ptr<lldb_private::OptionGroupPlatformRSync> diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp index 224d13babfd12..7aadc37d0e1fc 100644 --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -686,13 +686,11 @@ void PlatformWindows::GetStatus(Stream &strm) { bool PlatformWindows::CanDebugProcess() { return true; } -ConstString PlatformWindows::GetFullNameForDylib(ConstString basename) { - if (basename.IsEmpty()) - return basename; +std::string PlatformWindows::GetFullNameForDylib(llvm::StringRef basename) { + if (basename.empty()) + return basename.str(); - StreamString stream; - stream.Printf("%s.dll", basename.GetCString()); - return ConstString(stream.GetString()); + return llvm::formatv("{0}.dll", basename).str(); } size_t diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h index dff3113686c39..6f8c20a8456a2 100644 --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h @@ -77,7 +77,7 @@ class PlatformWindows : public RemoteAwarePlatform { // FIXME not sure what the _sigtramp equivalent would be on this platform void CalculateTrapHandlerSymbolNames() override {} - ConstString GetFullNameForDylib(ConstString basename) override; + std::string GetFullNameForDylib(llvm::StringRef basename) override; size_t GetSoftwareBreakpointTrapOpcode(Target &target, BreakpointSite *bp_site) override; diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 0b2290c98d55e..4113592bddec3 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -791,8 +791,8 @@ const char *Platform::GetHostname() { return m_hostname.c_str(); } -ConstString Platform::GetFullNameForDylib(ConstString basename) { - return basename; +std::string Platform::GetFullNameForDylib(llvm::StringRef basename) { + return basename.str(); } bool Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir) { _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
