forked from OSchip/llvm-project
More thorough fix for the spaces-in-typename issue
llvm-svn: 138026
This commit is contained in:
parent
4938edb02c
commit
da616d06e9
|
@ -79,12 +79,24 @@ public:
|
|||
|
||||
};
|
||||
|
||||
static inline bool
|
||||
IsWhitespace (char c)
|
||||
{
|
||||
return ( (c == ' ') || (c == '\t') || (c == '\v') || (c == '\f') );
|
||||
}
|
||||
|
||||
static inline bool
|
||||
HasPrefix (const char* str1, const char* str2)
|
||||
{
|
||||
return ( ::strstr(str1, str2) == str1 );
|
||||
}
|
||||
|
||||
// if the user tries to add formatters for, say, "struct Foo"
|
||||
// those will not match any type because of the way we strip qualifiers from typenames
|
||||
// this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo
|
||||
// and strips the unnecessary qualifier
|
||||
static ConstString
|
||||
GetValidTypeName_Impl(const ConstString& type)
|
||||
GetValidTypeName_Impl (const ConstString& type)
|
||||
{
|
||||
int strip_len = 0;
|
||||
|
||||
|
@ -93,19 +105,23 @@ GetValidTypeName_Impl(const ConstString& type)
|
|||
|
||||
const char* type_cstr = type.AsCString();
|
||||
|
||||
if ( ::strstr(type_cstr, "class ") == type_cstr)
|
||||
if ( HasPrefix(type_cstr, "class ") )
|
||||
strip_len = 6;
|
||||
if ( ::strstr(type_cstr, "enum ") == type_cstr)
|
||||
else if ( HasPrefix(type_cstr, "enum ") )
|
||||
strip_len = 5;
|
||||
if ( ::strstr(type_cstr, "struct ") == type_cstr)
|
||||
else if ( HasPrefix(type_cstr, "struct ") )
|
||||
strip_len = 7;
|
||||
if ( ::strstr(type_cstr, "union ") == type_cstr)
|
||||
else if ( HasPrefix(type_cstr, "union ") )
|
||||
strip_len = 6;
|
||||
|
||||
if (strip_len == 0)
|
||||
return type;
|
||||
|
||||
return ConstString(type_cstr + strip_len);
|
||||
type_cstr += strip_len;
|
||||
while (IsWhitespace(*type_cstr) && ++type_cstr)
|
||||
;
|
||||
|
||||
return ConstString(type_cstr);
|
||||
}
|
||||
|
||||
template<typename KeyType, typename ValueType>
|
||||
|
|
|
@ -218,8 +218,9 @@ class DataFormatterTestCase(TestBase):
|
|||
self.expect("frame variable the_coolest_guy",
|
||||
substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
|
||||
|
||||
# many spaces, but we still do the right thing
|
||||
self.runCmd("type summary delete i_am_cool")
|
||||
self.runCmd("type summary add -f \"goofy\" \"union i_am_cool\"")
|
||||
self.runCmd("type summary add -f \"goofy\" \"union i_am_cool\"")
|
||||
self.expect("frame variable the_coolest_guy",
|
||||
substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
|
||||
|
||||
|
|
Loading…
Reference in New Issue