[Lldb-commits] [lldb] r247831 - Move hardcoded formatters from the FormatManager to the Language plugins

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 16 11:28:12 PDT 2015


Author: enrico
Date: Wed Sep 16 13:28:11 2015
New Revision: 247831

URL: http://llvm.org/viewvc/llvm-project?rev=247831&view=rev
Log:
Move hardcoded formatters from the FormatManager to the Language plugins


Modified:
    lldb/trunk/include/lldb/DataFormatters/FormatClasses.h
    lldb/trunk/include/lldb/DataFormatters/FormatManager.h
    lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h
    lldb/trunk/include/lldb/Target/Language.h
    lldb/trunk/source/DataFormatters/FormatManager.cpp
    lldb/trunk/source/DataFormatters/LanguageCategory.cpp
    lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
    lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
    lldb/trunk/source/Target/Language.cpp

Modified: lldb/trunk/include/lldb/DataFormatters/FormatClasses.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatClasses.h?rev=247831&r1=247830&r2=247831&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatClasses.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatClasses.h Wed Sep 16 13:28:11 2015
@@ -19,12 +19,31 @@
 // Project includes
 #include "lldb/lldb-public.h"
 #include "lldb/lldb-enumerations.h"
-
+#include "lldb/DataFormatters/TypeFormat.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/DataFormatters/TypeValidator.h"
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Symbol/Type.h"
 
 namespace lldb_private {
 
+class HardcodedFormatters {
+public:
+    template <typename FormatterType>
+    using HardcodedFormatterFinder = std::function<typename FormatterType::SharedPointer (lldb_private::ValueObject&,
+                                                                                          lldb::DynamicValueType,
+                                                                                          FormatManager&)>;
+
+    template <typename FormatterType>
+    using HardcodedFormatterFinders = std::vector<HardcodedFormatterFinder<FormatterType>>;
+
+    typedef HardcodedFormatterFinders<TypeFormatImpl> HardcodedFormatFinder;
+    typedef HardcodedFormatterFinders<TypeSummaryImpl> HardcodedSummaryFinder;
+    typedef HardcodedFormatterFinders<SyntheticChildren> HardcodedSyntheticFinder;
+    typedef HardcodedFormatterFinders<TypeValidatorImpl> HardcodedValidatorFinder;
+};
+
 class FormattersMatchCandidate
 {
 public:

Modified: lldb/trunk/include/lldb/DataFormatters/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=247831&r1=247830&r2=247831&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatManager.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Wed Sep 16 13:28:11 2015
@@ -44,14 +44,6 @@ class FormatManager : public IFormatChan
     typedef TypeCategoryMap::MapType::iterator CategoryMapIterator;
 public:
     
-    template <typename FormatterType>
-    using HardcodedFormatterFinder = std::function<typename FormatterType::SharedPointer (lldb_private::ValueObject&,
-                                                                                          lldb::DynamicValueType,
-                                                                                          FormatManager&)>;
-    
-    template <typename FormatterType>
-    using HardcodedFormatterFinders = std::vector<HardcodedFormatterFinder<FormatterType>>;
-    
     typedef std::map<lldb::LanguageType, LanguageCategory::UniquePointer> LanguageCategories;
     
     typedef TypeCategoryMap::CallbackType CategoryCallback;
@@ -292,11 +284,6 @@ private:
     ConstString m_system_category_name;
     ConstString m_vectortypes_category_name;
     
-    HardcodedFormatterFinders<TypeFormatImpl> m_hardcoded_formats;
-    HardcodedFormatterFinders<TypeSummaryImpl> m_hardcoded_summaries;
-    HardcodedFormatterFinders<SyntheticChildren> m_hardcoded_synthetics;
-    HardcodedFormatterFinders<TypeValidatorImpl> m_hardcoded_validators;
-    
     lldb::TypeFormatImplSP
     GetHardcodedFormat (ValueObject&,lldb::DynamicValueType);
     
@@ -325,9 +312,6 @@ private:
     
     void
     LoadVectorFormatters ();
-
-    void
-    LoadHardcodedFormatters ();
 };
     
 } // namespace lldb_private

Modified: lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h?rev=247831&r1=247830&r2=247831&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h Wed Sep 16 13:28:11 2015
@@ -53,6 +53,30 @@ public:
          lldb::DynamicValueType dynamic,
          FormattersMatchVector matches,
          lldb::TypeValidatorImplSP& format_sp);
+
+    bool
+    GetHardcoded (ValueObject& valobj,
+                  lldb::DynamicValueType use_dynamic,
+                  FormatManager& fmt_mgr,
+                  lldb::TypeFormatImplSP& format_sp);
+
+    bool
+    GetHardcoded (ValueObject& valobj,
+                  lldb::DynamicValueType use_dynamic,
+                  FormatManager& fmt_mgr,
+                  lldb::TypeSummaryImplSP& format_sp);
+    
+    bool
+    GetHardcoded (ValueObject& valobj,
+                  lldb::DynamicValueType use_dynamic,
+                  FormatManager& fmt_mgr,
+                  lldb::SyntheticChildrenSP& format_sp);
+    
+    bool
+    GetHardcoded (ValueObject& valobj,
+                  lldb::DynamicValueType use_dynamic,
+                  FormatManager& fmt_mgr,
+                  lldb::TypeValidatorImplSP& format_sp);
     
     lldb::TypeCategoryImplSP
     GetCategory () const;
@@ -63,9 +87,20 @@ public:
     void
     Disable ();
     
+    bool
+    IsEnabled ();
+    
 private:
     lldb::TypeCategoryImplSP m_category_sp;
+    
+    HardcodedFormatters::HardcodedFormatFinder m_hardcoded_formats;
+    HardcodedFormatters::HardcodedSummaryFinder m_hardcoded_summaries;
+    HardcodedFormatters::HardcodedSyntheticFinder m_hardcoded_synthetics;
+    HardcodedFormatters::HardcodedValidatorFinder m_hardcoded_validators;
+    
     lldb_private::FormatCache m_format_cache;
+    
+    bool m_enabled;
 };
     
 } // namespace lldb_private

Modified: lldb/trunk/include/lldb/Target/Language.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Language.h?rev=247831&r1=247830&r2=247831&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Language.h (original)
+++ lldb/trunk/include/lldb/Target/Language.h Wed Sep 16 13:28:11 2015
@@ -20,6 +20,7 @@
 #include "lldb/lldb-public.h"
 #include "lldb/lldb-private.h"
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/DataFormatters/FormatClasses.h"
 #include "lldb/DataFormatters/StringPrinter.h"
 
 namespace lldb_private {
@@ -42,6 +43,18 @@ public:
     
     virtual lldb::TypeCategoryImplSP
     GetFormatters ();
+    
+    virtual HardcodedFormatters::HardcodedFormatFinder
+    GetHardcodedFormats ();
+    
+    virtual HardcodedFormatters::HardcodedSummaryFinder
+    GetHardcodedSummaries ();
+
+    virtual HardcodedFormatters::HardcodedSyntheticFinder
+    GetHardcodedSynthetics ();
+    
+    virtual HardcodedFormatters::HardcodedValidatorFinder
+    GetHardcodedValidators ();
 
     virtual std::vector<ConstString>
     GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic);

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=247831&r1=247830&r2=247831&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Wed Sep 16 13:28:11 2015
@@ -15,8 +15,6 @@
 // Project includes
 
 #include "lldb/Core/Debugger.h"
-#include "lldb/DataFormatters/CXXFunctionPointer.h"
-#include "lldb/DataFormatters/VectorType.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/LanguageCategory.h"
 #include "lldb/Target/ExecutionContext.h"
@@ -686,13 +684,18 @@ lldb::TypeFormatImplSP
 FormatManager::GetHardcodedFormat (ValueObject& valobj,
                                    lldb::DynamicValueType use_dynamic)
 {
-    for (const auto& candidate: m_hardcoded_formats)
+    TypeFormatImplSP retval_sp;
+    
+    for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj))
     {
-        auto result = candidate(valobj,use_dynamic,*this);
-        if (result)
-            return result;
+        if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+        {
+            if (lang_category->GetHardcoded(valobj, use_dynamic, *this, retval_sp))
+                break;
+        }
     }
-    return nullptr;
+
+    return retval_sp;
 }
 
 lldb::TypeFormatImplSP
@@ -766,13 +769,18 @@ lldb::TypeSummaryImplSP
 FormatManager::GetHardcodedSummaryFormat (ValueObject& valobj,
                                           lldb::DynamicValueType use_dynamic)
 {
-    for (const auto& candidate: m_hardcoded_summaries)
+    TypeSummaryImplSP retval_sp;
+    
+    for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj))
     {
-        auto result = candidate(valobj,use_dynamic,*this);
-        if (result)
-            return result;
+        if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+        {
+            if (lang_category->GetHardcoded(valobj, use_dynamic, *this, retval_sp))
+                break;
+        }
     }
-    return nullptr;
+    
+    return retval_sp;
 }
 
 lldb::TypeSummaryImplSP
@@ -847,13 +855,18 @@ lldb::SyntheticChildrenSP
 FormatManager::GetHardcodedSyntheticChildren (ValueObject& valobj,
                                               lldb::DynamicValueType use_dynamic)
 {
-    for (const auto& candidate: m_hardcoded_synthetics)
+    SyntheticChildrenSP retval_sp;
+    
+    for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj))
     {
-        auto result = candidate(valobj,use_dynamic,*this);
-        if (result)
-            return result;
+        if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+        {
+            if (lang_category->GetHardcoded(valobj, use_dynamic, *this, retval_sp))
+                break;
+        }
     }
-    return nullptr;
+    
+    return retval_sp;
 }
 
 lldb::SyntheticChildrenSP
@@ -995,13 +1008,18 @@ lldb::TypeValidatorImplSP
 FormatManager::GetHardcodedValidator (ValueObject& valobj,
                                       lldb::DynamicValueType use_dynamic)
 {
-    for (const auto& candidate: m_hardcoded_validators)
+    TypeValidatorImplSP retval_sp;
+    
+    for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj))
     {
-        auto result = candidate(valobj,use_dynamic,*this);
-        if (result)
-            return result;
+        if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type))
+        {
+            if (lang_category->GetHardcoded(valobj, use_dynamic, *this, retval_sp))
+                break;
+        }
     }
-    return nullptr;
+    
+    return retval_sp;
 }
 
 FormatManager::FormatManager() :
@@ -1013,16 +1031,10 @@ FormatManager::FormatManager() :
     m_language_categories_mutex(Mutex::eMutexTypeRecursive),
     m_default_category_name(ConstString("default")),
     m_system_category_name(ConstString("system")), 
-    m_vectortypes_category_name(ConstString("VectorTypes")),
-    m_hardcoded_formats(),
-    m_hardcoded_summaries(),
-    m_hardcoded_synthetics(),
-    m_hardcoded_validators()
-    
+    m_vectortypes_category_name(ConstString("VectorTypes"))
 {
     LoadSystemFormatters();
     LoadVectorFormatters();
-    LoadHardcodedFormatters();
     
     EnableCategory(m_vectortypes_category_name,TypeCategoryMap::Last);
     EnableCategory(m_system_category_name,TypeCategoryMap::Last);
@@ -1156,65 +1168,3 @@ FormatManager::LoadVectorFormatters()
                      ConstString("vBool32"),
                      vector_flags);
 }
-
-void
-FormatManager::LoadHardcodedFormatters()
-{
-    {
-        // insert code to load formats here
-    }
-    {
-        // insert code to load summaries here
-        m_hardcoded_summaries.push_back(
-                                        [](lldb_private::ValueObject& valobj,
-                                            lldb::DynamicValueType,
-                                            FormatManager&) -> TypeSummaryImpl::SharedPointer {
-                                            static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags(), lldb_private::formatters::CXXFunctionPointerSummaryProvider, "Function pointer summary provider"));
-                                            if (valobj.GetCompilerType().IsFunctionPointerType())
-                                            {
-                                                return formatter_sp;
-                                            }
-                                            return nullptr;
-                                        });
-        m_hardcoded_summaries.push_back(
-                                         [](lldb_private::ValueObject& valobj,
-                                            lldb::DynamicValueType,
-                                            FormatManager& fmt_mgr) -> TypeSummaryImpl::SharedPointer {
-                                             static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags()
-                                                                                                                                      .SetCascades(true)
-                                                                                                                                      .SetDontShowChildren(true)
-                                                                                                                                      .SetHideItemNames(true)
-                                                                                                                                      .SetShowMembersOneLiner(true)
-                                                                                                                                      .SetSkipPointers(true)
-                                                                                                                                      .SetSkipReferences(false),
-                                                                                                                                      lldb_private::formatters::VectorTypeSummaryProvider,
-                                                                                                                                      "vector_type pointer summary provider"));
-                                             if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr))
-                                             {
-                                                 if (fmt_mgr.GetCategory(fmt_mgr.m_vectortypes_category_name)->IsEnabled())
-                                                     return formatter_sp;
-                                             }
-                                             return nullptr;
-                                         });
-    }
-    {
-        // insert code to load synthetics here
-        m_hardcoded_synthetics.push_back(
-                                         [](lldb_private::ValueObject& valobj,
-                                            lldb::DynamicValueType,
-                                            FormatManager& fmt_mgr) -> SyntheticChildren::SharedPointer {
-                                             static CXXSyntheticChildren::SharedPointer formatter_sp(new CXXSyntheticChildren(SyntheticChildren::Flags().SetCascades(true).SetSkipPointers(true).SetSkipReferences(true).SetNonCacheable(true),
-                                                                                                                              "vector_type synthetic children",
-                                                                                                                              lldb_private::formatters::VectorTypeSyntheticFrontEndCreator));
-                                             if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr))
-                                             {
-                                                 if (fmt_mgr.GetCategory(fmt_mgr.m_vectortypes_category_name)->IsEnabled())
-                                                     return formatter_sp;
-                                             }
-                                             return nullptr;
-                                         });
-    }
-    {
-        // insert code to load validators here
-    }
-}

Modified: lldb/trunk/source/DataFormatters/LanguageCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LanguageCategory.cpp?rev=247831&r1=247830&r2=247831&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LanguageCategory.cpp (original)
+++ lldb/trunk/source/DataFormatters/LanguageCategory.cpp Wed Sep 16 13:28:11 2015
@@ -26,12 +26,22 @@ using namespace lldb_private;
 
 LanguageCategory::LanguageCategory (lldb::LanguageType lang_type) :
     m_category_sp(),
-    m_format_cache()
+    m_hardcoded_formats(),
+    m_hardcoded_summaries(),
+    m_hardcoded_synthetics(),
+    m_hardcoded_validators(),
+    m_format_cache(),
+    m_enabled(false)
 {
     if (Language* language_plugin = Language::FindPlugin(lang_type))
+    {
         m_category_sp = language_plugin->GetFormatters();
-    if (m_category_sp)
-        m_category_sp->Enable(true, 1);
+        m_hardcoded_formats = language_plugin->GetHardcodedFormats();
+        m_hardcoded_summaries = language_plugin->GetHardcodedSummaries();
+        m_hardcoded_synthetics = language_plugin->GetHardcodedSynthetics();
+        m_hardcoded_validators = language_plugin->GetHardcodedValidators();
+    }
+    Enable();
 }
 
 bool
@@ -43,7 +53,7 @@ LanguageCategory::Get (ValueObject& valo
     if (!m_category_sp)
         return false;
     
-    if (!m_category_sp->IsEnabled())
+    if (!IsEnabled())
         return false;
 
     ConstString type_name = FormatManager::GetTypeForCache(valobj, dynamic);
@@ -69,7 +79,7 @@ LanguageCategory::Get (ValueObject& valo
     if (!m_category_sp)
         return false;
     
-    if (!m_category_sp->IsEnabled())
+    if (!IsEnabled())
         return false;
 
     ConstString type_name = FormatManager::GetTypeForCache(valobj, dynamic);
@@ -95,7 +105,7 @@ LanguageCategory::Get (ValueObject& valo
     if (!m_category_sp)
         return false;
     
-    if (!m_category_sp->IsEnabled())
+    if (!IsEnabled())
         return false;
 
     ConstString type_name = FormatManager::GetTypeForCache(valobj, dynamic);
@@ -121,7 +131,7 @@ LanguageCategory::Get (ValueObject& valo
     if (!m_category_sp)
         return false;
 
-    if (!m_category_sp->IsEnabled())
+    if (!IsEnabled())
         return false;
 
     ConstString type_name = FormatManager::GetTypeForCache(valobj, dynamic);
@@ -138,6 +148,98 @@ LanguageCategory::Get (ValueObject& valo
     return result;
 }
 
+bool
+LanguageCategory::GetHardcoded (ValueObject& valobj,
+                                lldb::DynamicValueType use_dynamic,
+                                FormatManager& fmt_mgr,
+                                lldb::TypeFormatImplSP& format_sp)
+{
+    if (!IsEnabled())
+        return false;
+
+    ConstString type_name = FormatManager::GetTypeForCache(valobj, use_dynamic);
+
+    for (auto& candidate : m_hardcoded_formats)
+    {
+        if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr)))
+            break;
+    }
+    if (type_name && (!format_sp || !format_sp->NonCacheable()))
+    {
+        m_format_cache.SetFormat(type_name, format_sp);
+    }
+    return format_sp.get() != nullptr;
+}
+
+bool
+LanguageCategory::GetHardcoded (ValueObject& valobj,
+                                lldb::DynamicValueType use_dynamic,
+                                FormatManager& fmt_mgr,
+                                lldb::TypeSummaryImplSP& format_sp)
+{
+    if (!IsEnabled())
+        return false;
+
+    ConstString type_name = FormatManager::GetTypeForCache(valobj, use_dynamic);
+    
+    for (auto& candidate : m_hardcoded_summaries)
+    {
+        if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr)))
+            break;
+    }
+    if (type_name && (!format_sp || !format_sp->NonCacheable()))
+    {
+        m_format_cache.SetSummary(type_name, format_sp);
+    }
+    return format_sp.get() != nullptr;
+}
+
+bool
+LanguageCategory::GetHardcoded (ValueObject& valobj,
+                                lldb::DynamicValueType use_dynamic,
+                                FormatManager& fmt_mgr,
+                                lldb::SyntheticChildrenSP& format_sp)
+{
+    if (!IsEnabled())
+        return false;
+
+    ConstString type_name = FormatManager::GetTypeForCache(valobj, use_dynamic);
+    
+    for (auto& candidate : m_hardcoded_synthetics)
+    {
+        if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr)))
+            break;
+    }
+    if (type_name && (!format_sp || !format_sp->NonCacheable()))
+    {
+        m_format_cache.SetSynthetic(type_name, format_sp);
+    }
+    return format_sp.get() != nullptr;
+}
+
+bool
+LanguageCategory::GetHardcoded (ValueObject& valobj,
+                                lldb::DynamicValueType use_dynamic,
+                                FormatManager& fmt_mgr,
+                                lldb::TypeValidatorImplSP& format_sp)
+{
+    if (!IsEnabled())
+        return false;
+
+    ConstString type_name = FormatManager::GetTypeForCache(valobj, use_dynamic);
+    
+    for (auto& candidate : m_hardcoded_validators)
+    {
+        if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr)))
+            break;
+    }
+    if (type_name && (!format_sp || !format_sp->NonCacheable()))
+    {
+        m_format_cache.SetValidator(type_name, format_sp);
+    }
+    return format_sp.get() != nullptr;
+}
+
 lldb::TypeCategoryImplSP
 LanguageCategory::GetCategory () const
 {
@@ -149,6 +251,7 @@ LanguageCategory::Enable ()
 {
     if (m_category_sp)
         m_category_sp->Enable(true, TypeCategoryMap::Default);
+    m_enabled = true;
 }
 
 void
@@ -156,4 +259,11 @@ LanguageCategory::Disable ()
 {
     if (m_category_sp)
         m_category_sp->Disable();
+    m_enabled = false;
+}
+
+bool
+LanguageCategory::IsEnabled ()
+{
+    return m_enabled;
 }

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp?rev=247831&r1=247830&r2=247831&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Wed Sep 16 13:28:11 2015
@@ -17,8 +17,10 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/RegularExpression.h"
 #include "lldb/Core/UniqueCStringMap.h"
+#include "lldb/DataFormatters/CXXFunctionPointer.h"
 #include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/VectorType.h"
 
 #include "CxxStringTypes.h"
 #include "LibCxx.h"
@@ -669,3 +671,74 @@ CPlusPlusLanguage::GetFormatters ()
     return g_category;
 }
 
+HardcodedFormatters::HardcodedSummaryFinder
+CPlusPlusLanguage::GetHardcodedSummaries ()
+{
+    static std::once_flag g_initialize;
+    static ConstString g_vectortypes("VectorTypes");
+    static HardcodedFormatters::HardcodedSummaryFinder g_formatters;
+    
+    std::call_once(g_initialize, [] () -> void {
+        g_formatters.push_back(
+                                        [](lldb_private::ValueObject& valobj,
+                                           lldb::DynamicValueType,
+                                           FormatManager&) -> TypeSummaryImpl::SharedPointer {
+                                            static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags(), lldb_private::formatters::CXXFunctionPointerSummaryProvider, "Function pointer summary provider"));
+                                            if (valobj.GetCompilerType().IsFunctionPointerType())
+                                            {
+                                                return formatter_sp;
+                                            }
+                                            return nullptr;
+                                        });
+        g_formatters.push_back(
+                                        [](lldb_private::ValueObject& valobj,
+                                           lldb::DynamicValueType,
+                                           FormatManager& fmt_mgr) -> TypeSummaryImpl::SharedPointer {
+                                            static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags()
+                                                                                                                                     .SetCascades(true)
+                                                                                                                                     .SetDontShowChildren(true)
+                                                                                                                                     .SetHideItemNames(true)
+                                                                                                                                     .SetShowMembersOneLiner(true)
+                                                                                                                                     .SetSkipPointers(true)
+                                                                                                                                     .SetSkipReferences(false),
+                                                                                                                                     lldb_private::formatters::VectorTypeSummaryProvider,
+                                                                                                                                     "vector_type pointer summary provider"));
+                                            if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr))
+                                            {
+                                                if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
+                                                    return formatter_sp;
+                                            }
+                                            return nullptr;
+                                        });
+    });
+    
+    return g_formatters;
+}
+
+HardcodedFormatters::HardcodedSyntheticFinder
+CPlusPlusLanguage::GetHardcodedSynthetics ()
+{
+    static std::once_flag g_initialize;
+    static ConstString g_vectortypes("VectorTypes");
+    static HardcodedFormatters::HardcodedSyntheticFinder g_formatters;
+    
+    std::call_once(g_initialize, [] () -> void {
+        g_formatters.push_back(
+                                         [](lldb_private::ValueObject& valobj,
+                                            lldb::DynamicValueType,
+                                            FormatManager& fmt_mgr) -> SyntheticChildren::SharedPointer {
+                                             static CXXSyntheticChildren::SharedPointer formatter_sp(new CXXSyntheticChildren(SyntheticChildren::Flags().SetCascades(true).SetSkipPointers(true).SetSkipReferences(true).SetNonCacheable(true),
+                                                                                                                              "vector_type synthetic children",
+                                                                                                                              lldb_private::formatters::VectorTypeSyntheticFrontEndCreator));
+                                             if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr))
+                                             {
+                                                 if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
+                                                     return formatter_sp;
+                                             }
+                                             return nullptr;
+                                         });
+    });
+    
+    return g_formatters;
+}
+

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h?rev=247831&r1=247830&r2=247831&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h Wed Sep 16 13:28:11 2015
@@ -129,6 +129,12 @@ public:
     lldb::TypeCategoryImplSP
     GetFormatters () override;
     
+    HardcodedFormatters::HardcodedSummaryFinder
+    GetHardcodedSummaries () override;
+    
+    HardcodedFormatters::HardcodedSyntheticFinder
+    GetHardcodedSynthetics () override;
+    
     //------------------------------------------------------------------
     // Static Functions
     //------------------------------------------------------------------

Modified: lldb/trunk/source/Target/Language.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Language.cpp?rev=247831&r1=247830&r2=247831&view=diff
==============================================================================
--- lldb/trunk/source/Target/Language.cpp (original)
+++ lldb/trunk/source/Target/Language.cpp Wed Sep 16 13:28:11 2015
@@ -95,6 +95,30 @@ Language::GetFormatters ()
     return nullptr;
 }
 
+HardcodedFormatters::HardcodedFormatFinder
+Language::GetHardcodedFormats ()
+{
+    return {};
+}
+
+HardcodedFormatters::HardcodedSummaryFinder
+Language::GetHardcodedSummaries ()
+{
+    return {};
+}
+
+HardcodedFormatters::HardcodedSyntheticFinder
+Language::GetHardcodedSynthetics ()
+{
+    return {};
+}
+
+HardcodedFormatters::HardcodedValidatorFinder
+Language::GetHardcodedValidators ()
+{
+    return {};
+}
+
 std::vector<ConstString>
 Language::GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
 {




More information about the lldb-commits mailing list