[Lldb-commits] [lldb] r262909 - Turn GetAliasOptions() into GetAlias()
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 7 19:56:13 PST 2016
Author: enrico
Date: Mon Mar 7 21:56:12 2016
New Revision: 262909
URL: http://llvm.org/viewvc/llvm-project?rev=262909&view=rev
Log:
Turn GetAliasOptions() into GetAlias()
Eventually, there will be more things that CommandAlias contains, and I don't want accessors for each of them on the CommandIntepreter
Eventually, we also won't pass around copies of CommandAlias, but that's for a later patch
Modified:
lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
lldb/trunk/source/Interpreter/CommandInterpreter.cpp
Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=262909&r1=262908&r2=262909&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Mon Mar 7 21:56:12 2016
@@ -202,13 +202,27 @@ class CommandInterpreter :
public:
struct CommandAlias
{
- lldb::CommandObjectSP m_underlying_command_sp;
- OptionArgVectorSP m_option_args_sp;
+ lldb::CommandObjectSP m_underlying_command_sp = nullptr;
+ OptionArgVectorSP m_option_args_sp = nullptr;
+
+ CommandAlias (lldb::CommandObjectSP cmd_sp = nullptr,
+ OptionArgVectorSP args_sp = nullptr);
static bool
ProcessAliasOptionsArgs (lldb::CommandObjectSP &cmd_obj_sp,
const char *options_args,
OptionArgVectorSP &option_arg_vector_sp);
+
+ bool
+ IsValid ()
+ {
+ return m_underlying_command_sp && m_option_args_sp;
+ }
+
+ explicit operator bool ()
+ {
+ return IsValid();
+ }
};
typedef std::map<std::string, CommandAlias> CommandAliasMap;
@@ -312,8 +326,8 @@ public:
m_user_dict.clear();
}
- OptionArgVectorSP
- GetAliasOptions (const char *alias_name);
+ CommandAlias
+ GetAlias (const char *alias_name);
CommandObject *
BuildAliasResult (const char *alias_name,
Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=262909&r1=262908&r2=262909&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Mar 7 21:56:12 2016
@@ -97,6 +97,13 @@ enum
eSpaceReplPrompts = 3
};
+CommandInterpreter::CommandAlias::CommandAlias (lldb::CommandObjectSP cmd_sp,
+ OptionArgVectorSP args_sp) :
+ m_underlying_command_sp(cmd_sp),
+ m_option_args_sp(args_sp)
+{
+}
+
bool
CommandInterpreter::CommandAlias::ProcessAliasOptionsArgs (lldb::CommandObjectSP &cmd_obj_sp,
const char *options_args,
@@ -1170,7 +1177,7 @@ void
CommandInterpreter::GetAliasHelp (const char *alias_name, const char *command_name, StreamString &help_string)
{
help_string.Printf ("'%s", command_name);
- OptionArgVectorSP option_arg_vector_sp = GetAliasOptions (alias_name);
+ OptionArgVectorSP option_arg_vector_sp = GetAlias(alias_name).m_option_args_sp;
if (option_arg_vector_sp)
{
@@ -1456,7 +1463,7 @@ CommandInterpreter::BuildAliasResult (co
cmd_args.Unshift (alias_name);
result_str.Printf ("%s", alias_cmd_obj->GetCommandName ());
- OptionArgVectorSP option_arg_vector_sp = GetAliasOptions (alias_name);
+ OptionArgVectorSP option_arg_vector_sp = GetAlias(alias_name).m_option_args_sp;
if (option_arg_vector_sp.get())
{
@@ -2083,8 +2090,8 @@ CommandInterpreter::Confirm (const char
return confirm->GetResponse();
}
-OptionArgVectorSP
-CommandInterpreter::GetAliasOptions (const char *alias_name)
+CommandInterpreter::CommandAlias
+CommandInterpreter::GetAlias (const char *alias_name)
{
OptionArgVectorSP ret_val;
@@ -2092,9 +2099,9 @@ CommandInterpreter::GetAliasOptions (con
auto pos = m_alias_dict.find(alias);
if (pos != m_alias_dict.end())
- ret_val = pos->second.m_option_args_sp;
+ return pos->second;
- return ret_val;
+ return CommandInterpreter::CommandAlias();
}
bool
@@ -2128,7 +2135,7 @@ CommandInterpreter::BuildAliasCommandArg
std::string &raw_input_string,
CommandReturnObject &result)
{
- OptionArgVectorSP option_arg_vector_sp = GetAliasOptions (alias_name);
+ OptionArgVectorSP option_arg_vector_sp = GetAlias(alias_name).m_option_args_sp;
bool wants_raw_input = alias_cmd_obj->WantsRawCommandString();
More information about the lldb-commits
mailing list