diff options
-rw-r--r-- | lldb/include/lldb/Interpreter/Args.h | 1 | ||||
-rw-r--r-- | lldb/include/lldb/Utility/StringList.h | 2 | ||||
-rw-r--r-- | lldb/source/Interpreter/Args.cpp | 5 | ||||
-rw-r--r-- | lldb/unittests/Interpreter/TestArgs.cpp | 11 |
4 files changed, 18 insertions, 1 deletions
diff --git a/lldb/include/lldb/Interpreter/Args.h b/lldb/include/lldb/Interpreter/Args.h index 98046cd5954..19d7ac41856 100644 --- a/lldb/include/lldb/Interpreter/Args.h +++ b/lldb/include/lldb/Interpreter/Args.h @@ -86,6 +86,7 @@ public: Args(llvm::StringRef command = llvm::StringRef()); Args(const Args &rhs); + explicit Args(const StringList &list); Args &operator=(const Args &rhs); diff --git a/lldb/include/lldb/Utility/StringList.h b/lldb/include/lldb/Utility/StringList.h index 2be9a6bd834..6553e5dfdfb 100644 --- a/lldb/include/lldb/Utility/StringList.h +++ b/lldb/include/lldb/Utility/StringList.h @@ -29,7 +29,7 @@ class StringList { public: StringList(); - StringList(const char *str); + explicit StringList(const char *str); StringList(const char **strv, int strc); diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index a23ba3094b2..07e5191f898 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/lldb/source/Interpreter/Args.cpp @@ -185,6 +185,11 @@ Args::Args(llvm::StringRef command) { SetCommandString(command); } Args::Args(const Args &rhs) { *this = rhs; } +Args::Args(const StringList &list) : Args() { + for(size_t i = 0; i < list.GetSize(); ++i) + AppendArgument(list[i]); +} + Args &Args::operator=(const Args &rhs) { Clear(); diff --git a/lldb/unittests/Interpreter/TestArgs.cpp b/lldb/unittests/Interpreter/TestArgs.cpp index 2aeed0f542b..2aaaab84e21 100644 --- a/lldb/unittests/Interpreter/TestArgs.cpp +++ b/lldb/unittests/Interpreter/TestArgs.cpp @@ -10,6 +10,7 @@ #include "gtest/gtest.h" #include "lldb/Interpreter/Args.h" +#include "lldb/Utility/StringList.h" #include <limits> #include <sstream> @@ -117,6 +118,16 @@ TEST(ArgsTest, TestArgv) { EXPECT_EQ(nullptr, args.GetArgumentVector()[5]); } +TEST(ArgsTest, StringListConstructor) { + StringList list; + list << "foo" << "bar" << "baz"; + Args args(list); + ASSERT_EQ(3u, args.GetArgumentCount()); + EXPECT_EQ("foo", args[0].ref); + EXPECT_EQ("bar", args[1].ref); + EXPECT_EQ("baz", args[2].ref); +} + TEST(ArgsTest, GetQuotedCommandString) { Args args; const char *str = "process launch -o stdout.txt -- \"a b c\""; |