forked from OSchip/llvm-project
<rdar://problem/12857181>
When a user says type formatter add ... unsigned int he most probably means to deal with the "unsigned int" type. However, given how the LLDB command parser works, that command will try to add the formatter to the TWO types 'unsigned' AND 'int' Since this is unlikely to be what the user wants, warn about it, and suggest they can use quotes to override the debugger's understanding llvm-svn: 200996
This commit is contained in:
parent
c1690d0c2b
commit
41c440fbfe
|
@ -95,7 +95,32 @@ public:
|
|||
|
||||
};
|
||||
|
||||
|
||||
static bool
|
||||
WarnOnPotentialUnquotedUnsignedType (Args& command, CommandReturnObject &result)
|
||||
{
|
||||
for (int idx = 0; idx < command.GetArgumentCount(); idx++)
|
||||
{
|
||||
const char* arg = command.GetArgumentAtIndex(idx);
|
||||
if (idx+1 < command.GetArgumentCount())
|
||||
{
|
||||
if (arg && 0 == strcmp(arg,"unsigned"))
|
||||
{
|
||||
const char* next = command.GetArgumentAtIndex(idx+1);
|
||||
if (next &&
|
||||
(0 == strcmp(next, "int") ||
|
||||
0 == strcmp(next, "short") ||
|
||||
0 == strcmp(next, "char") ||
|
||||
0 == strcmp(next, "long")))
|
||||
{
|
||||
result.AppendWarningWithFormat("%s %s being treated as two types. if you meant the combined type name use quotes, as in \"%s %s\"\n",
|
||||
arg,next,arg,next);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class CommandObjectTypeSummaryAdd :
|
||||
public CommandObjectParsed,
|
||||
|
@ -454,6 +479,8 @@ protected:
|
|||
bool
|
||||
DoExecute (Args& command, CommandReturnObject &result)
|
||||
{
|
||||
WarnOnPotentialUnquotedUnsignedType(command, result);
|
||||
|
||||
if (m_options.handwrite_python)
|
||||
return Execute_HandwritePython(command, result);
|
||||
else if (m_options.is_class_based)
|
||||
|
@ -810,6 +837,8 @@ protected:
|
|||
if (!category_sp)
|
||||
return false;
|
||||
|
||||
WarnOnPotentialUnquotedUnsignedType(command, result);
|
||||
|
||||
for (size_t i = 0; i < argc; i++)
|
||||
{
|
||||
const char* typeA = command.GetArgumentAtIndex(i);
|
||||
|
@ -1769,6 +1798,8 @@ CommandObjectTypeSummaryAdd::CommandObjectTypeSummaryAdd (CommandInterpreter &in
|
|||
bool
|
||||
CommandObjectTypeSummaryAdd::DoExecute (Args& command, CommandReturnObject &result)
|
||||
{
|
||||
WarnOnPotentialUnquotedUnsignedType(command, result);
|
||||
|
||||
if (m_options.m_is_add_script)
|
||||
{
|
||||
#ifndef LLDB_DISABLE_PYTHON
|
||||
|
@ -4183,6 +4214,8 @@ protected:
|
|||
|
||||
Error error;
|
||||
|
||||
WarnOnPotentialUnquotedUnsignedType(command, result);
|
||||
|
||||
for (size_t i = 0; i < argc; i++)
|
||||
{
|
||||
const char* typeA = command.GetArgumentAtIndex(i);
|
||||
|
|
Loading…
Reference in New Issue