[Lldb-commits] [lldb] r209072 - Introduce the concept of a "display name" for types

Enrico Granata egranata at apple.com
Sat May 17 12:14:18 PDT 2014


Author: enrico
Date: Sat May 17 14:14:17 2014
New Revision: 209072

URL: http://llvm.org/viewvc/llvm-project?rev=209072&view=rev
Log:
Introduce the concept of a "display name" for types

Rationale:
Pretty simply, the idea is that sometimes type names are way too long and contain way too many details for the average developer to care about. For instance, a plain ol' vector of int might be shown as
std::__1::vector<int, std::__1::allocator<....
rather than the much simpler std::vector<int> form, which is what most developers would actually type in their code

Proposed solution:
Introduce a notion of "display name" and a corresponding API GetDisplayTypeName() to return such a crafted for visual representation type name
Obviously, the display name and the fully qualified (or "true") name are not necessarily the same - that's the whole point
LLDB could choose to pick the "display name" as its one true notion of a type name, and if somebody really needs the fully qualified version of it, let them deal with the problem
Or, LLDB could rename what it currently calls the "type name" to be the "display name", and add new APIs for the fully qualified name, making the display name the default choice

The choice that I am making here is that the type name will keep meaning the same, and people who want a type name suited for display will explicitly ask for one
It is the less risky/disruptive choice - and it should eventually make it fairly obvious when someone is asking for the wrong type

Caveats:
- for now, GetDisplayTypeName() == GetTypeName(), there is no logic to produce customized display type names yet.
- while the fully-qualified type name is still the main key to the kingdom of data formatters, if we start showing custom names to people, those should match formatters


Modified:
    lldb/trunk/include/lldb/API/SBType.h
    lldb/trunk/include/lldb/API/SBValue.h
    lldb/trunk/include/lldb/Core/ValueObject.h
    lldb/trunk/include/lldb/Core/ValueObjectChild.h
    lldb/trunk/include/lldb/Core/ValueObjectConstResult.h
    lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h
    lldb/trunk/include/lldb/Core/ValueObjectMemory.h
    lldb/trunk/include/lldb/Core/ValueObjectRegister.h
    lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
    lldb/trunk/include/lldb/Core/ValueObjectVariable.h
    lldb/trunk/include/lldb/Symbol/ClangASTType.h
    lldb/trunk/include/lldb/Symbol/Type.h
    lldb/trunk/scripts/Python/interface/SBType.i
    lldb/trunk/scripts/Python/interface/SBValue.i
    lldb/trunk/source/API/SBType.cpp
    lldb/trunk/source/API/SBValue.cpp
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Core/ValueObjectChild.cpp
    lldb/trunk/source/Core/ValueObjectConstResult.cpp
    lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
    lldb/trunk/source/Core/ValueObjectMemory.cpp
    lldb/trunk/source/Core/ValueObjectRegister.cpp
    lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
    lldb/trunk/source/Core/ValueObjectVariable.cpp
    lldb/trunk/source/DataFormatters/FormatManager.cpp
    lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp
    lldb/trunk/source/Symbol/ClangASTType.cpp
    lldb/trunk/source/Symbol/Type.cpp

Modified: lldb/trunk/include/lldb/API/SBType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBType.h (original)
+++ lldb/trunk/include/lldb/API/SBType.h Sat May 17 14:14:17 2014
@@ -161,6 +161,9 @@ public:
     const char*
     GetName();
     
+    const char *
+    GetDisplayTypeName ();
+    
     lldb::TypeClass
     GetTypeClass ();
     

Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Sat May 17 14:14:17 2014
@@ -50,6 +50,9 @@ public:
 
     const char *
     GetTypeName ();
+    
+    const char *
+    GetDisplayTypeName ();
 
     size_t
     GetByteSize ();

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Sat May 17 14:14:17 2014
@@ -395,6 +395,9 @@ public:
     GetTypeName();
     
     virtual ConstString
+    GetDisplayTypeName();
+    
+    virtual ConstString
     GetQualifiedTypeName();
 
     virtual lldb::LanguageType

Modified: lldb/trunk/include/lldb/Core/ValueObjectChild.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectChild.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectChild.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectChild.h Sat May 17 14:14:17 2014
@@ -62,6 +62,9 @@ public:
     virtual ConstString
     GetQualifiedTypeName();
     
+    virtual ConstString
+    GetDisplayTypeName();
+    
     virtual bool
     IsInScope ();
 

Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Sat May 17 14:14:17 2014
@@ -80,6 +80,9 @@ public:
     virtual ConstString
     GetTypeName();
 
+    virtual ConstString
+    GetDisplayTypeName();
+    
     virtual bool
     IsInScope ();
 

Modified: lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h Sat May 17 14:14:17 2014
@@ -37,6 +37,9 @@ public:
 
     virtual ConstString
     GetQualifiedTypeName();
+
+    virtual ConstString
+    GetDisplayTypeName();
     
     virtual size_t
     CalculateNumChildren();

Modified: lldb/trunk/include/lldb/Core/ValueObjectMemory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectMemory.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectMemory.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectMemory.h Sat May 17 14:14:17 2014
@@ -47,6 +47,9 @@ public:
     virtual ConstString
     GetTypeName();
 
+    virtual ConstString
+    GetDisplayTypeName();
+    
     virtual size_t
     CalculateNumChildren();
 

Modified: lldb/trunk/include/lldb/Core/ValueObjectRegister.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectRegister.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectRegister.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectRegister.h Sat May 17 14:14:17 2014
@@ -45,6 +45,9 @@ public:
     
     virtual ConstString
     GetQualifiedTypeName();
+    
+    virtual ConstString
+    GetDisplayTypeName();
 
     virtual size_t
     CalculateNumChildren();

Modified: lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h Sat May 17 14:14:17 2014
@@ -41,6 +41,9 @@ public:
     
     virtual ConstString
     GetQualifiedTypeName();
+    
+    virtual ConstString
+    GetDisplayTypeName();
 
     virtual bool
     MightHaveChildren();

Modified: lldb/trunk/include/lldb/Core/ValueObjectVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectVariable.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectVariable.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectVariable.h Sat May 17 14:14:17 2014
@@ -39,6 +39,9 @@ public:
 
     virtual ConstString
     GetQualifiedTypeName();
+    
+    virtual ConstString
+    GetDisplayTypeName();
 
     virtual size_t
     CalculateNumChildren();

Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Sat May 17 14:14:17 2014
@@ -264,6 +264,9 @@ public:
     ConstString
     GetTypeName () const;
 
+    ConstString
+    GetDisplayTypeName () const;
+
     uint32_t
     GetTypeInfo (ClangASTType *pointee_or_element_clang_type = NULL) const;
     

Modified: lldb/trunk/include/lldb/Symbol/Type.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Type.h (original)
+++ lldb/trunk/include/lldb/Symbol/Type.h Sat May 17 14:14:17 2014
@@ -368,6 +368,16 @@ public:
         return ConstString ();
     }
     
+    ConstString
+    GetDisplayTypeName () const
+    {
+        if (type_sp)
+            return type_sp->GetClangForwardType().GetDisplayTypeName();
+        if (clang_type)
+            return clang_type.GetDisplayTypeName();
+        return ConstString();
+    }
+    
     void
     SetType (ClangASTType type)
     {
@@ -511,6 +521,9 @@ public:
     ConstString
     GetName ()  const;
     
+    ConstString
+    GetDisplayTypeName ()  const;
+    
     TypeImpl
     GetPointerType () const;
     

Modified: lldb/trunk/scripts/Python/interface/SBType.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBType.i?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBType.i (original)
+++ lldb/trunk/scripts/Python/interface/SBType.i Sat May 17 14:14:17 2014
@@ -27,7 +27,7 @@ public:
 
     const char *
     GetName ();
-
+    
     lldb::SBType
     GetType ();
 
@@ -216,6 +216,9 @@ public:
     const char*
     GetName();
     
+    const char *
+    GetDisplayTypeName ();
+    
     lldb::TypeClass
     GetTypeClass ();
     

Modified: lldb/trunk/scripts/Python/interface/SBValue.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValue.i (original)
+++ lldb/trunk/scripts/Python/interface/SBValue.i Sat May 17 14:14:17 2014
@@ -81,6 +81,9 @@ public:
 
     const char *
     GetTypeName ();
+    
+    const char *
+    GetDisplayTypeName ();
 
     size_t
     GetByteSize ();

Modified: lldb/trunk/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Sat May 17 14:14:17 2014
@@ -414,6 +414,14 @@ SBType::GetName()
     return m_opaque_sp->GetName().GetCString();
 }
 
+const char *
+SBType::GetDisplayTypeName ()
+{
+    if (!IsValid())
+        return "";
+    return m_opaque_sp->GetDisplayTypeName().GetCString();
+}
+
 lldb::TypeClass
 SBType::GetTypeClass ()
 {

Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Sat May 17 14:14:17 2014
@@ -378,6 +378,31 @@ SBValue::GetTypeName ()
     return name;
 }
 
+const char *
+SBValue::GetDisplayTypeName ()
+{
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    const char *name = NULL;
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
+    if (value_sp)
+    {
+        name = value_sp->GetDisplayTypeName().GetCString();
+    }
+    
+    if (log)
+    {
+        if (name)
+            log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"",
+                         static_cast<void*>(value_sp.get()), name);
+        else
+            log->Printf ("SBValue(%p)::GetTypeName () => NULL",
+                         static_cast<void*>(value_sp.get()));
+    }
+    
+    return name;
+}
+
 size_t
 SBValue::GetByteSize ()
 {

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Sat May 17 14:14:17 2014
@@ -1953,6 +1953,12 @@ ValueObject::GetTypeName()
 }
 
 ConstString
+ValueObject::GetDisplayTypeName()
+{
+    return GetTypeName();
+}
+
+ConstString
 ValueObject::GetQualifiedTypeName()
 {
     return GetClangType().GetConstQualifiedTypeName();

Modified: lldb/trunk/source/Core/ValueObjectChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectChild.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectChild.cpp Sat May 17 14:14:17 2014
@@ -66,25 +66,29 @@ ValueObjectChild::CalculateNumChildren()
     return GetClangType().GetNumChildren (true);
 }
 
+static void
+AdjustForBitfieldness(ConstString& name,
+                      uint8_t bitfield_bit_size)
+{
+    if (name && bitfield_bit_size)
+    {
+        const char *clang_type_name = name.AsCString();
+        if (clang_type_name)
+        {
+            std::vector<char> bitfield_type_name (strlen(clang_type_name) + 32, 0);
+            ::snprintf (&bitfield_type_name.front(), bitfield_type_name.size(), "%s:%u", clang_type_name, bitfield_bit_size);
+            name.SetCString(&bitfield_type_name.front());
+        }
+    }
+}
+
 ConstString
 ValueObjectChild::GetTypeName()
 {
     if (m_type_name.IsEmpty())
     {
         m_type_name = GetClangType().GetConstTypeName ();
-        if (m_type_name)
-        {
-            if (m_bitfield_bit_size > 0)
-            {
-                const char *clang_type_name = m_type_name.AsCString();
-                if (clang_type_name)
-                {
-                    std::vector<char> bitfield_type_name (strlen(clang_type_name) + 32, 0);
-                    ::snprintf (&bitfield_type_name.front(), bitfield_type_name.size(), "%s:%u", clang_type_name, m_bitfield_bit_size);
-                    m_type_name.SetCString(&bitfield_type_name.front());
-                }
-            }
-        }
+        AdjustForBitfieldness(m_type_name, m_bitfield_bit_size);
     }
     return m_type_name;
 }
@@ -93,22 +97,18 @@ ConstString
 ValueObjectChild::GetQualifiedTypeName()
 {
     ConstString qualified_name = GetClangType().GetConstTypeName();
-    if (qualified_name)
-    {
-        if (m_bitfield_bit_size > 0)
-        {
-            const char *clang_type_name = qualified_name.AsCString();
-            if (clang_type_name)
-            {
-                std::vector<char> bitfield_type_name (strlen(clang_type_name) + 32, 0);
-                ::snprintf (&bitfield_type_name.front(), bitfield_type_name.size(), "%s:%u", clang_type_name, m_bitfield_bit_size);
-                qualified_name.SetCString(&bitfield_type_name.front());
-            }
-        }
-    }
+    AdjustForBitfieldness(qualified_name, m_bitfield_bit_size);
     return qualified_name;
 }
 
+ConstString
+ValueObjectChild::GetDisplayTypeName()
+{
+    ConstString display_name = GetClangType().GetDisplayTypeName();
+    AdjustForBitfieldness(display_name, m_bitfield_bit_size);
+    return display_name;
+}
+
 bool
 ValueObjectChild::UpdateValue ()
 {

Modified: lldb/trunk/source/Core/ValueObjectConstResult.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectConstResult.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Sat May 17 14:14:17 2014
@@ -276,6 +276,12 @@ ValueObjectConstResult::GetTypeName()
     return m_type_name;
 }
 
+ConstString
+ValueObjectConstResult::GetDisplayTypeName()
+{
+    return GetClangType().GetDisplayTypeName();
+}
+
 bool
 ValueObjectConstResult::UpdateValue ()
 {

Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Sat May 17 14:14:17 2014
@@ -71,8 +71,6 @@ ValueObjectDynamicValue::GetTypeName()
     {
         if (m_dynamic_type_info.HasName())
             return m_dynamic_type_info.GetName();
-        if (m_dynamic_type_info.HasType())
-            return GetClangType().GetConstTypeName();
     }
     return m_parent->GetTypeName();
 }
@@ -96,10 +94,22 @@ ValueObjectDynamicValue::GetQualifiedTyp
     {
         if (m_dynamic_type_info.HasName())
             return m_dynamic_type_info.GetName();
+    }
+    return m_parent->GetQualifiedTypeName();
+}
+
+ConstString
+ValueObjectDynamicValue::GetDisplayTypeName()
+{
+    const bool success = UpdateValueIfNeeded(false);
+    if (success)
+    {
         if (m_dynamic_type_info.HasType())
-            return GetClangType().GetConstQualifiedTypeName ();
+            return GetClangType().GetDisplayTypeName();
+        if (m_dynamic_type_info.HasName())
+            return m_dynamic_type_info.GetName();
     }
-    return m_parent->GetTypeName();
+    return m_parent->GetDisplayTypeName();
 }
 
 size_t

Modified: lldb/trunk/source/Core/ValueObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectMemory.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectMemory.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectMemory.cpp Sat May 17 14:14:17 2014
@@ -147,6 +147,14 @@ ValueObjectMemory::GetTypeName()
     return m_clang_type.GetConstTypeName();
 }
 
+ConstString
+ValueObjectMemory::GetDisplayTypeName()
+{
+    if (m_type_sp)
+        return m_type_sp->GetClangForwardType().GetDisplayTypeName();
+    return m_clang_type.GetDisplayTypeName();
+}
+
 size_t
 ValueObjectMemory::CalculateNumChildren()
 {

Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectRegister.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectRegister.cpp Sat May 17 14:14:17 2014
@@ -55,6 +55,12 @@ ValueObjectRegisterContext::GetTypeName(
 }
 
 ConstString
+ValueObjectRegisterContext::GetDisplayTypeName()
+{
+    return ConstString();
+}
+
+ConstString
 ValueObjectRegisterContext::GetQualifiedTypeName()
 {
     return ConstString();

Modified: lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp Sat May 17 14:14:17 2014
@@ -101,6 +101,12 @@ ValueObjectSynthetic::GetQualifiedTypeNa
     return m_parent->GetQualifiedTypeName();
 }
 
+ConstString
+ValueObjectSynthetic::GetDisplayTypeName()
+{
+    return m_parent->GetDisplayTypeName();
+}
+
 size_t
 ValueObjectSynthetic::CalculateNumChildren()
 {

Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Sat May 17 14:14:17 2014
@@ -73,6 +73,15 @@ ValueObjectVariable::GetTypeName()
 }
 
 ConstString
+ValueObjectVariable::GetDisplayTypeName()
+{
+    Type * var_type = m_variable_sp->GetType();
+    if (var_type)
+        return var_type->GetClangForwardType().GetDisplayTypeName();
+    return ConstString();
+}
+
+ConstString
 ValueObjectVariable::GetQualifiedTypeName()
 {
     Type * var_type = m_variable_sp->GetType();

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Sat May 17 14:14:17 2014
@@ -185,7 +185,11 @@ FormatManager::GetPossibleMatches (Value
         reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField;
     }
     entries.push_back({type_name,reason,did_strip_ptr,did_strip_ref,did_strip_typedef});
-    
+
+    ConstString display_type_name(clang_type.GetDisplayTypeName());
+    if (display_type_name != type_name)
+        entries.push_back({display_type_name,reason,did_strip_ptr,did_strip_ref,did_strip_typedef});
+
     for (bool is_rvalue_ref = true, j = true; j && clang_type.IsReferenceType(nullptr, &is_rvalue_ref); j = false)
     {
         ClangASTType non_ref_type = clang_type.GetNonReferenceType();

Modified: lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp (original)
+++ lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp Sat May 17 14:14:17 2014
@@ -222,7 +222,11 @@ ValueObjectPrinter::PrintTypeIfNeeded ()
     {
         // Some ValueObjects don't have types (like registers sets). Only print
         // the type if there is one to print
-        ConstString qualified_type_name(m_valobj->GetQualifiedTypeName());
+        ConstString qualified_type_name;
+        if (options.m_be_raw)
+            qualified_type_name = m_valobj->GetQualifiedTypeName();
+        else
+            qualified_type_name = m_valobj->GetDisplayTypeName();
         if (qualified_type_name)
             m_stream->Printf("(%s) ", qualified_type_name.GetCString());
         else

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Sat May 17 14:14:17 2014
@@ -1243,6 +1243,11 @@ ClangASTType::GetTypeName () const
     return ConstString(type_name);
 }
 
+ConstString
+ClangASTType::GetDisplayTypeName () const
+{
+    return GetTypeName();
+}
 
 uint32_t
 ClangASTType::GetTypeInfo (ClangASTType *pointee_or_element_clang_type) const

Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=209072&r1=209071&r2=209072&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Sat May 17 14:14:17 2014
@@ -1053,6 +1053,14 @@ TypeImpl::GetName ()  const
     return m_static_type.GetName ();
 }
 
+ConstString
+TypeImpl::GetDisplayTypeName ()  const
+{
+    if (m_dynamic_type)
+        return m_dynamic_type.GetDisplayTypeName();
+    return m_static_type.GetDisplayTypeName();
+}
+
 TypeImpl
 TypeImpl::GetPointerType () const
 {





More information about the lldb-commits mailing list