[Lldb-commits] [lldb] r284362 - Interpreter: Don't return StringRef from functions whose return value is never used

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 17 10:51:33 PDT 2016


lgtm

On Mon, Oct 17, 2016 at 10:37 AM Justin Bogner via lldb-commits <
lldb-commits at lists.llvm.org> wrote:

> Author: bogner
> Date: Mon Oct 17 01:17:56 2016
> New Revision: 284362
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284362&view=rev
> Log:
> Interpreter: Don't return StringRef from functions whose return value is
> never used
>
> StringRef is passed through all of these APIs but never actually
> used. Just remove it from the API for now and if people want to use it
> they can add it back.
>
> Modified:
>     lldb/trunk/include/lldb/Interpreter/Args.h
>     lldb/trunk/source/Interpreter/Args.cpp
>
> Modified: lldb/trunk/include/lldb/Interpreter/Args.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=284362&r1=284361&r2=284362&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Interpreter/Args.h (original)
> +++ lldb/trunk/include/lldb/Interpreter/Args.h Mon Oct 17 01:17:56 2016
> @@ -193,12 +193,8 @@ public:
>    ///
>    /// @param[in] quote_char
>    ///     If the argument was originally quoted, put in the quote char
> here.
> -  ///
> -  /// @return
> -  ///     The NULL terminated C string of the copy of \a arg_cstr.
>    //------------------------------------------------------------------
> -  llvm::StringRef AppendArgument(llvm::StringRef arg_str,
> -                                 char quote_char = '\0');
> +  void AppendArgument(llvm::StringRef arg_str, char quote_char = '\0');
>
>    void AppendArguments(const Args &rhs);
>
> @@ -219,8 +215,8 @@ public:
>    /// @return
>    ///     The NULL terminated C string of the copy of \a arg_cstr.
>    //------------------------------------------------------------------
> -  llvm::StringRef InsertArgumentAtIndex(size_t idx, llvm::StringRef
> arg_str,
> -                                        char quote_char = '\0');
> +  void InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
> +                             char quote_char = '\0');
>
>    //------------------------------------------------------------------
>    /// Replaces the argument value at index \a idx to \a arg_cstr
> @@ -234,13 +230,9 @@ public:
>    ///
>    /// @param[in] quote_char
>    ///     If the argument was originally quoted, put in the quote char
> here.
> -  ///
> -  /// @return
> -  ///     The NULL terminated C string of the copy of \a arg_cstr if
> -  ///     \a idx was a valid index, NULL otherwise.
>    //------------------------------------------------------------------
> -  llvm::StringRef ReplaceArgumentAtIndex(size_t idx, llvm::StringRef
> arg_str,
> -                                         char quote_char = '\0');
> +  void ReplaceArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
> +                              char quote_char = '\0');
>
>    //------------------------------------------------------------------
>    /// Deletes the argument value at index
> @@ -289,11 +281,8 @@ public:
>    ///
>    /// @param[in] quote_char
>    ///     If the argument was originally quoted, put in the quote char
> here.
> -  ///
> -  /// @return
> -  ///     A pointer to the copy of \a arg_cstr that was made.
>    //------------------------------------------------------------------
> -  llvm::StringRef Unshift(llvm::StringRef arg_str, char quote_char =
> '\0');
> +  void Unshift(llvm::StringRef arg_str, char quote_char = '\0');
>
>    //------------------------------------------------------------------
>    /// Parse the arguments in the contained arguments.
>
> Modified: lldb/trunk/source/Interpreter/Args.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=284362&r1=284361&r2=284362&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Interpreter/Args.cpp (original)
> +++ lldb/trunk/source/Interpreter/Args.cpp Mon Oct 17 01:17:56 2016
> @@ -332,8 +332,8 @@ void Args::Shift() {
>    m_entries.erase(m_entries.begin());
>  }
>
> -llvm::StringRef Args::Unshift(llvm::StringRef arg_str, char quote_char) {
> -  return InsertArgumentAtIndex(0, arg_str, quote_char);
> +void Args::Unshift(llvm::StringRef arg_str, char quote_char) {
> +  InsertArgumentAtIndex(0, arg_str, quote_char);
>  }
>
>  void Args::AppendArguments(const Args &rhs) {
> @@ -361,30 +361,28 @@ void Args::AppendArguments(const char **
>    m_argv.push_back(nullptr);
>  }
>
> -llvm::StringRef Args::AppendArgument(llvm::StringRef arg_str, char
> quote_char) {
> -  return InsertArgumentAtIndex(GetArgumentCount(), arg_str, quote_char);
> +void Args::AppendArgument(llvm::StringRef arg_str, char quote_char) {
> +  InsertArgumentAtIndex(GetArgumentCount(), arg_str, quote_char);
>  }
>
> -llvm::StringRef Args::InsertArgumentAtIndex(size_t idx, llvm::StringRef
> arg_str,
> -                                            char quote_char) {
> +void Args::InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
> +                                 char quote_char) {
>    assert(m_argv.size() == m_entries.size() + 1);
>    assert(m_argv.back() == nullptr);
>
>    if (idx > m_entries.size())
> -    return llvm::StringRef();
> +    return;
>    m_entries.emplace(m_entries.begin() + idx, arg_str, quote_char);
>    m_argv.insert(m_argv.begin() + idx, m_entries[idx].data());
> -  return m_entries[idx].ref;
>  }
>
> -llvm::StringRef Args::ReplaceArgumentAtIndex(size_t idx,
> -                                             llvm::StringRef arg_str,
> -                                             char quote_char) {
> +void Args::ReplaceArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
> +                                  char quote_char) {
>    assert(m_argv.size() == m_entries.size() + 1);
>    assert(m_argv.back() == nullptr);
>
>    if (idx >= m_entries.size())
> -    return llvm::StringRef();
> +    return;
>
>    if (arg_str.size() > m_entries[idx].ref.size()) {
>      m_entries[idx] = ArgEntry(arg_str, quote_char);
> @@ -395,8 +393,6 @@ llvm::StringRef Args::ReplaceArgumentAtI
>      m_entries[idx].ptr[arg_str.size()] = 0;
>      m_entries[idx].ref = m_entries[idx].ref.take_front(arg_str.size());
>    }
> -
> -  return m_entries[idx].ref;
>  }
>
>  void Args::DeleteArgumentAtIndex(size_t idx) {
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20161017/2c4ad629/attachment.html>


More information about the lldb-commits mailing list