@@ -53,23 +53,41 @@ void FormatCache::Entry::Set(lldb::SyntheticChildrenSP synthetic_sp) {
5353
5454namespace lldb_private {
5555
56- template <> bool FormatCache::Entry::IsCached<lldb::TypeFormatImplSP>() {
57- return IsFormatCached ();
56+ template <typename ImplSP>
57+ static bool passesValidator (const ImplSP &impl_sp,
58+ FormattersMatchData &match_data) {
59+ if (!impl_sp || !impl_sp->GetTypeValidator ())
60+ return true ;
61+
62+ ValueObject &valobj = match_data.GetValueObject ();
63+ lldb::ValueObjectSP valobj_sp = valobj.GetQualifiedRepresentationIfAvailable (
64+ match_data.GetDynamicValueType (), valobj.IsSynthetic ());
65+ return valobj_sp && impl_sp->GetTypeValidator ()(valobj_sp->GetCompilerType ());
66+ }
67+
68+ template <>
69+ bool FormatCache::Entry::IsCached<lldb::TypeFormatImplSP>(
70+ FormattersMatchData &match_data) {
71+ return IsFormatCached () && passesValidator (m_format_sp, match_data);
5872}
59- template <> bool FormatCache::Entry::IsCached<lldb::TypeSummaryImplSP> () {
60- return IsSummaryCached ();
73+ template <>
74+ bool FormatCache::Entry::IsCached<lldb::TypeSummaryImplSP>(
75+ FormattersMatchData &match_data) {
76+ return IsSummaryCached () && passesValidator (m_summary_sp, match_data);
6177}
62- template <> bool FormatCache::Entry::IsCached<lldb::SyntheticChildrenSP>() {
63- return IsSyntheticCached ();
78+ template <>
79+ bool FormatCache::Entry::IsCached<lldb::SyntheticChildrenSP>(
80+ FormattersMatchData &match_data) {
81+ return IsSyntheticCached () && passesValidator (m_synthetic_sp, match_data);
6482}
6583
6684} // namespace lldb_private
6785
6886template <typename ImplSP>
69- bool FormatCache::Get (ConstString type , ImplSP &format_impl_sp) {
87+ bool FormatCache::Get (FormattersMatchData &match_data , ImplSP &format_impl_sp) {
7088 std::lock_guard<std::recursive_mutex> guard (m_mutex);
71- auto entry = m_entries[type ];
72- if (entry.IsCached <ImplSP>()) {
89+ auto entry = m_entries[match_data. GetTypeForCache () ];
90+ if (entry.IsCached <ImplSP>(match_data )) {
7391 m_cache_hits++;
7492 entry.Get (format_impl_sp);
7593 return true ;
@@ -82,12 +100,13 @@ bool FormatCache::Get(ConstString type, ImplSP &format_impl_sp) {
82100// / Explicit instantiations for the three types.
83101// / \{
84102template bool
85- FormatCache::Get<lldb::TypeFormatImplSP>(ConstString, lldb::TypeFormatImplSP &);
103+ FormatCache::Get<lldb::TypeFormatImplSP>(FormattersMatchData &,
104+ lldb::TypeFormatImplSP &);
86105template bool
87- FormatCache::Get<lldb::TypeSummaryImplSP>(ConstString ,
106+ FormatCache::Get<lldb::TypeSummaryImplSP>(FormattersMatchData & ,
88107 lldb::TypeSummaryImplSP &);
89108template bool
90- FormatCache::Get<lldb::SyntheticChildrenSP>(ConstString ,
109+ FormatCache::Get<lldb::SyntheticChildrenSP>(FormattersMatchData & ,
91110 lldb::SyntheticChildrenSP &);
92111// / \}
93112
0 commit comments