Move Args::StringTo*** functions to a new OptionArgParser class

Summary:
The idea behind this is to move the functionality which depend on other lldb
classes into a separate class. This way, the Args class can be turned
into a lightweight arc+argv wrapper and moved into the lower lldb
layers.

Reviewers: jingham, zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D44306

llvm-svn: 329677
This commit is contained in:
Pavel Labath
2018-04-10 09:03:59 +00:00
parent bfa20dddcb
commit 47cbf4a07b
35 changed files with 555 additions and 454 deletions

View File

@@ -24,6 +24,7 @@
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupArchitecture.h"
#include "lldb/Interpreter/OptionGroupBoolean.h"
#include "lldb/Interpreter/OptionGroupFile.h"
@@ -1983,7 +1984,7 @@ public:
switch (short_option) {
case 's':
m_sort_order = (SortOrder)Args::StringToOptionEnum(
m_sort_order = (SortOrder)OptionArgParser::ToOptionEnum(
option_arg, GetDefinitions()[option_idx].enum_values,
eSortOrderNone, error);
break;
@@ -2885,8 +2886,8 @@ public:
if (short_option == 'g') {
m_use_global_module_list = true;
} else if (short_option == 'a') {
m_module_addr = Args::StringToAddress(execution_context, option_arg,
LLDB_INVALID_ADDRESS, &error);
m_module_addr = OptionArgParser::ToAddress(
execution_context, option_arg, LLDB_INVALID_ADDRESS, &error);
} else {
unsigned long width = 0;
option_arg.getAsInteger(0, width);
@@ -3251,8 +3252,8 @@ public:
case 'a': {
m_str = option_arg;
m_type = eLookupTypeAddress;
m_addr = Args::StringToAddress(execution_context, option_arg,
LLDB_INVALID_ADDRESS, &error);
m_addr = OptionArgParser::ToAddress(execution_context, option_arg,
LLDB_INVALID_ADDRESS, &error);
if (m_addr == LLDB_INVALID_ADDRESS)
error.SetErrorStringWithFormat("invalid address string '%s'",
option_arg.str().c_str());
@@ -3567,8 +3568,8 @@ public:
switch (short_option) {
case 'a': {
m_type = eLookupTypeAddress;
m_addr = Args::StringToAddress(execution_context, option_arg,
LLDB_INVALID_ADDRESS, &error);
m_addr = OptionArgParser::ToAddress(execution_context, option_arg,
LLDB_INVALID_ADDRESS, &error);
} break;
case 'o':