[Lldb-commits] [lldb] r138026 - in /lldb/trunk: include/lldb/Core/FormatManager.h test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py

Enrico Granata granata.enrico at gmail.com
Thu Aug 18 18:47:11 PDT 2011


Author: enrico
Date: Thu Aug 18 20:47:11 2011
New Revision: 138026

URL: http://llvm.org/viewvc/llvm-project?rev=138026&view=rev
Log:
More thorough fix for the spaces-in-typename issue

Modified:
    lldb/trunk/include/lldb/Core/FormatManager.h
    lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py

Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=138026&r1=138025&r2=138026&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Thu Aug 18 20:47:11 2011
@@ -79,12 +79,24 @@
     
 };
     
+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 @@
     
     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>

Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py?rev=138026&r1=138025&r2=138026&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py Thu Aug 18 20:47:11 2011
@@ -218,8 +218,9 @@
         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'])
 





More information about the lldb-commits mailing list