bulbazord created this revision. bulbazord added reviewers: JDevlieghere, mib, jingham, jasonmolenda. Herald added a project: All. bulbazord requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
Having the names of various shells in ConstString's StringPool is not really necessary, especially if they are otherwise not going to be there in the first place. For example, if the person debugging uses bash on their system, the `shell` parameter will have its `m_filename` set to a ConstString containing "bash". However, fish, tcsh, zsh, and sh will probably never be used and are just taking up space in the StringPool. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D148402 Files: lldb/source/Utility/Args.cpp Index: lldb/source/Utility/Args.cpp =================================================================== --- lldb/source/Utility/Args.cpp +++ lldb/source/Utility/Args.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/Utility/Args.h" -#include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StringList.h" @@ -385,20 +384,21 @@ std::string Args::GetShellSafeArgument(const FileSpec &shell, llvm::StringRef unsafe_arg) { struct ShellDescriptor { - ConstString m_basename; + llvm::StringRef m_basename; llvm::StringRef m_escapables; }; - static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&;"}, - {ConstString("fish"), " '\"<>()&\\|;"}, - {ConstString("tcsh"), " '\"<>()&;"}, - {ConstString("zsh"), " '\"<>()&;\\|"}, - {ConstString("sh"), " '\"<>()&;"}}; + static ShellDescriptor g_Shells[] = {{"bash", " '\"<>()&;"}, + {"fish", " '\"<>()&\\|;"}, + {"tcsh", " '\"<>()&;"}, + {"zsh", " '\"<>()&;\\|"}, + {"sh", " '\"<>()&;"}}; // safe minimal set llvm::StringRef escapables = " '\""; - if (auto basename = shell.GetFilename()) { + auto basename = shell.GetFilename().GetStringRef(); + if (!basename.empty()) { for (const auto &Shell : g_Shells) { if (Shell.m_basename == basename) { escapables = Shell.m_escapables;
Index: lldb/source/Utility/Args.cpp =================================================================== --- lldb/source/Utility/Args.cpp +++ lldb/source/Utility/Args.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/Utility/Args.h" -#include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StringList.h" @@ -385,20 +384,21 @@ std::string Args::GetShellSafeArgument(const FileSpec &shell, llvm::StringRef unsafe_arg) { struct ShellDescriptor { - ConstString m_basename; + llvm::StringRef m_basename; llvm::StringRef m_escapables; }; - static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&;"}, - {ConstString("fish"), " '\"<>()&\\|;"}, - {ConstString("tcsh"), " '\"<>()&;"}, - {ConstString("zsh"), " '\"<>()&;\\|"}, - {ConstString("sh"), " '\"<>()&;"}}; + static ShellDescriptor g_Shells[] = {{"bash", " '\"<>()&;"}, + {"fish", " '\"<>()&\\|;"}, + {"tcsh", " '\"<>()&;"}, + {"zsh", " '\"<>()&;\\|"}, + {"sh", " '\"<>()&;"}}; // safe minimal set llvm::StringRef escapables = " '\""; - if (auto basename = shell.GetFilename()) { + auto basename = shell.GetFilename().GetStringRef(); + if (!basename.empty()) { for (const auto &Shell : g_Shells) { if (Shell.m_basename == basename) { escapables = Shell.m_escapables;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits