forked from OSchip/llvm-project
Fixed a crasher when using 1 character type names in “type summary”, “type synthetic” and “type filter”.
Also fixed a missing return when making python summary functions on the fly. <rdar://problem/16265491> llvm-svn: 204867
This commit is contained in:
parent
23798a9731
commit
bc711e0575
|
@ -17,6 +17,8 @@
|
|||
|
||||
// C++ Includes
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
#include "lldb/Core/ConstString.h"
|
||||
#include "lldb/Core/Debugger.h"
|
||||
#include "lldb/Core/IOHandler.h"
|
||||
|
@ -204,7 +206,7 @@ public:
|
|||
static const char *g_summary_addreader_instructions = "Enter your Python command(s). Type 'DONE' to end.\n"
|
||||
"def function (valobj,internal_dict):\n"
|
||||
" \"\"\"valobj: an SBValue which you want to provide a summary for\n"
|
||||
" internal_dict: an LLDB support object not to be used\"\"\"";
|
||||
" internal_dict: an LLDB support object not to be used\"\"\"\n";
|
||||
|
||||
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
|
||||
if (output_sp)
|
||||
|
@ -1814,6 +1816,25 @@ CommandObjectTypeSummaryAdd::DoExecute (Args& command, CommandReturnObject &resu
|
|||
return Execute_StringSummary(command, result);
|
||||
}
|
||||
|
||||
static bool
|
||||
FixArrayTypeNameWithRegex (ConstString &type_name)
|
||||
{
|
||||
llvm::StringRef type_name_ref(type_name.GetStringRef());
|
||||
|
||||
if (type_name_ref.endswith("[]"))
|
||||
{
|
||||
std::string type_name_str(type_name.GetCString());
|
||||
type_name_str.resize(type_name_str.length()-2);
|
||||
if (type_name_str.back() != ' ')
|
||||
type_name_str.append(" \\[[0-9]+\\]");
|
||||
else
|
||||
type_name_str.append("\\[[0-9]+\\]");
|
||||
type_name.SetCString(type_name_str.c_str());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name,
|
||||
TypeSummaryImplSP entry,
|
||||
|
@ -1826,17 +1847,8 @@ CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name,
|
|||
|
||||
if (type == eRegularSummary)
|
||||
{
|
||||
std::string type_name_str(type_name.GetCString());
|
||||
if (type_name_str.compare(type_name_str.length() - 2, 2, "[]") == 0)
|
||||
{
|
||||
type_name_str.resize(type_name_str.length()-2);
|
||||
if (type_name_str.back() != ' ')
|
||||
type_name_str.append(" \\[[0-9]+\\]");
|
||||
else
|
||||
type_name_str.append("\\[[0-9]+\\]");
|
||||
type_name.SetCString(type_name_str.c_str());
|
||||
if (FixArrayTypeNameWithRegex (type_name))
|
||||
type = eRegexSummary;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == eRegexSummary)
|
||||
|
@ -3897,17 +3909,8 @@ CommandObjectTypeSynthAdd::AddSynth(ConstString type_name,
|
|||
|
||||
if (type == eRegularSynth)
|
||||
{
|
||||
std::string type_name_str(type_name.GetCString());
|
||||
if (type_name_str.compare(type_name_str.length() - 2, 2, "[]") == 0)
|
||||
{
|
||||
type_name_str.resize(type_name_str.length()-2);
|
||||
if (type_name_str.back() != ' ')
|
||||
type_name_str.append(" \\[[0-9]+\\]");
|
||||
else
|
||||
type_name_str.append("\\[[0-9]+\\]");
|
||||
type_name.SetCString(type_name_str.c_str());
|
||||
type = eRegularSynth;
|
||||
}
|
||||
if (FixArrayTypeNameWithRegex (type_name))
|
||||
type = eRegexSynth;
|
||||
}
|
||||
|
||||
if (category->AnyMatches(type_name,
|
||||
|
@ -4076,17 +4079,8 @@ private:
|
|||
|
||||
if (type == eRegularFilter)
|
||||
{
|
||||
std::string type_name_str(type_name.GetCString());
|
||||
if (type_name_str.compare(type_name_str.length() - 2, 2, "[]") == 0)
|
||||
{
|
||||
type_name_str.resize(type_name_str.length()-2);
|
||||
if (type_name_str.back() != ' ')
|
||||
type_name_str.append(" \\[[0-9]+\\]");
|
||||
else
|
||||
type_name_str.append("\\[[0-9]+\\]");
|
||||
type_name.SetCString(type_name_str.c_str());
|
||||
if (FixArrayTypeNameWithRegex (type_name))
|
||||
type = eRegexFilter;
|
||||
}
|
||||
}
|
||||
|
||||
if (category->AnyMatches(type_name,
|
||||
|
|
Loading…
Reference in New Issue