diff options
| author | Enrico Granata <egranata@apple.com> | 2014-02-07 22:12:55 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2014-02-07 22:12:55 +0000 |
| commit | 41c440fbfea9112d4e8a9dfd8c851fe39a04525d (patch) | |
| tree | 180d8c3d029ee4d08141f34df5a1b3b5c148a9e8 /lldb/source/Commands | |
| parent | c1690d0c2b13280c484cbd4399abc489df35d707 (diff) | |
| download | bcm5719-llvm-41c440fbfea9112d4e8a9dfd8c851fe39a04525d.tar.gz bcm5719-llvm-41c440fbfea9112d4e8a9dfd8c851fe39a04525d.zip | |
<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
Diffstat (limited to 'lldb/source/Commands')
| -rw-r--r-- | lldb/source/Commands/CommandObjectType.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index 7ee93dea921..f1b1d2c1900 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -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); |

