[Lldb-commits] [lldb] r252516 - Extend the TypeSystem's ShouldPrintAsOneLiner implementation so that the ValueObject itself also gets a say in the process; NFC

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Mon Nov 9 13:28:56 PST 2015


Author: enrico
Date: Mon Nov  9 15:28:55 2015
New Revision: 252516

URL: http://llvm.org/viewvc/llvm-project?rev=252516&view=rev
Log:
Extend the TypeSystem's ShouldPrintAsOneLiner implementation so that the ValueObject itself also gets a say in the process; NFC

Modified:
    lldb/trunk/include/lldb/Symbol/CompilerType.h
    lldb/trunk/include/lldb/Symbol/TypeSystem.h
    lldb/trunk/source/DataFormatters/FormatManager.cpp
    lldb/trunk/source/Symbol/CompilerType.cpp
    lldb/trunk/source/Symbol/TypeSystem.cpp

Modified: lldb/trunk/include/lldb/Symbol/CompilerType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompilerType.h?rev=252516&r1=252515&r2=252516&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/CompilerType.h (original)
+++ lldb/trunk/include/lldb/Symbol/CompilerType.h Mon Nov  9 15:28:55 2015
@@ -470,7 +470,7 @@ public:
     GetTypeForFormatters () const;
     
     LazyBool
-    ShouldPrintAsOneLiner () const;
+    ShouldPrintAsOneLiner (ValueObject* valobj) const;
     
     bool
     IsMeaninglessWithoutDynamicResolution () const;

Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=252516&r1=252515&r2=252516&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Mon Nov  9 15:28:55 2015
@@ -531,7 +531,7 @@ public:
     GetTypeForFormatters (void* type);
     
     virtual LazyBool
-    ShouldPrintAsOneLiner (void* type);
+    ShouldPrintAsOneLiner (void* type, ValueObject* valobj);
     
     // Type systems can have types that are placeholder types, which are meant to indicate
     // the presence of a type, but offer no actual information about said types, and leave

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=252516&r1=252515&r2=252516&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Mon Nov  9 15:28:55 2015
@@ -568,7 +568,7 @@ FormatManager::ShouldPrintAsOneLiner (Va
     CompilerType compiler_type(valobj.GetCompilerType());
     if (compiler_type.IsValid())
     {
-        switch (compiler_type.ShouldPrintAsOneLiner())
+        switch (compiler_type.ShouldPrintAsOneLiner(&valobj))
         {
             case eLazyBoolNo:
                 return false;
@@ -590,6 +590,23 @@ FormatManager::ShouldPrintAsOneLiner (Va
         // something is wrong here - bail out
         if (!child_sp)
             return false;
+        
+        // also ask the child's type if it has any opinion
+        CompilerType child_compiler_type(child_sp->GetCompilerType());
+        if (child_compiler_type.IsValid())
+        {
+            switch (child_compiler_type.ShouldPrintAsOneLiner(child_sp.get()))
+            {
+                case eLazyBoolYes:
+                    // an opinion of yes is only binding for the child, so keep going
+                case eLazyBoolCalculate:
+                    break;
+                case eLazyBoolNo:
+                    // but if the child says no, then it's a veto on the whole thing
+                    return false;
+            }
+        }
+        
         // if we decided to define synthetic children for a type, we probably care enough
         // to show them, but avoid nesting children in children
         if (child_sp->GetSyntheticChildren().get() != nullptr)

Modified: lldb/trunk/source/Symbol/CompilerType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompilerType.cpp?rev=252516&r1=252515&r2=252516&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/CompilerType.cpp (original)
+++ lldb/trunk/source/Symbol/CompilerType.cpp Mon Nov  9 15:28:55 2015
@@ -870,10 +870,10 @@ CompilerType::GetTypeForFormatters () co
 }
 
 LazyBool
-CompilerType::ShouldPrintAsOneLiner () const
+CompilerType::ShouldPrintAsOneLiner (ValueObject* valobj) const
 {
     if (IsValid())
-        return m_type_system->ShouldPrintAsOneLiner(m_type);
+        return m_type_system->ShouldPrintAsOneLiner(m_type, valobj);
     return eLazyBoolCalculate;
 }
 

Modified: lldb/trunk/source/Symbol/TypeSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeSystem.cpp?rev=252516&r1=252515&r2=252516&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/TypeSystem.cpp (original)
+++ lldb/trunk/source/Symbol/TypeSystem.cpp Mon Nov  9 15:28:55 2015
@@ -110,7 +110,7 @@ TypeSystem::GetTypeForFormatters (void*
 }
 
 LazyBool
-TypeSystem::ShouldPrintAsOneLiner (void* type)
+TypeSystem::ShouldPrintAsOneLiner (void* type, ValueObject* valobj)
 {
     return eLazyBoolCalculate;
 }




More information about the lldb-commits mailing list