Refactor the Args class.
authorZachary Turner <zturner@google.com>
Mon, 3 Oct 2016 22:51:09 +0000 (22:51 +0000)
committerZachary Turner <zturner@google.com>
Mon, 3 Oct 2016 22:51:09 +0000 (22:51 +0000)
commit691405be388fd7ad8d0cc792cc9b56f94c7e401d
tree4a8ab166d0f5323f112307c62976d62917234be6
parent44761a6e47f8ebe314bfd4c7278e630538c286b8
Refactor the Args class.

There were a number of issues with the Args class preventing
efficient use of strings and incoporating LLVM's StringRef class.
The two biggest were:

1. Backing memory stored in a std::string, so we would frequently
   have to use const_cast to get a mutable buffer for passing to
   various low level APIs.
2. backing std::strings stored in a std::list, which doesn't
   provide random access.

I wanted to solve these two issues so that we could provide
StringRef access to the underlying arguments, and also a way
to provide range-based access to the underlying argument array
while still providing convenient c-style access via an argv style
const char**.

The solution here is to store arguments in a single "entry" class
which contains the backing memory, a StringRef with precomputed
length, and the quote char.  The backing memory is a manually
allocated const char* so that it is not invalidated when the
container is resized, and there is a separate argv array provided
for c-style access.

Differential revision: https://reviews.llvm.org/D25099

llvm-svn: 283157
lldb/include/lldb/Interpreter/Args.h
lldb/source/Core/Logging.cpp
lldb/source/Core/StringList.cpp
lldb/source/Interpreter/Args.cpp
lldb/unittests/Interpreter/TestArgs.cpp