diff --git a/lldb/include/lldb/DataFormatters/FormatClasses.h b/lldb/include/lldb/DataFormatters/FormatClasses.h --- a/lldb/include/lldb/DataFormatters/FormatClasses.h +++ b/lldb/include/lldb/DataFormatters/FormatClasses.h @@ -43,17 +43,15 @@ class FormattersMatchCandidate { public: - FormattersMatchCandidate(ConstString name, uint32_t reason, bool strip_ptr, + FormattersMatchCandidate(ConstString name, bool strip_ptr, bool strip_ref, bool strip_tydef) - : m_type_name(name), m_reason(reason), m_stripped_pointer(strip_ptr), + : m_type_name(name), m_stripped_pointer(strip_ptr), m_stripped_reference(strip_ref), m_stripped_typedef(strip_tydef) {} ~FormattersMatchCandidate() = default; ConstString GetTypeName() const { return m_type_name; } - uint32_t GetReason() const { return m_reason; } - bool DidStripPointer() const { return m_stripped_pointer; } bool DidStripReference() const { return m_stripped_reference; } @@ -75,7 +73,6 @@ private: ConstString m_type_name; - uint32_t m_reason; bool m_stripped_pointer; bool m_stripped_reference; bool m_stripped_typedef; diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h b/lldb/include/lldb/DataFormatters/FormatManager.h --- a/lldb/include/lldb/DataFormatters/FormatManager.h +++ b/lldb/include/lldb/DataFormatters/FormatManager.h @@ -170,7 +170,6 @@ GetPossibleMatches(ValueObject &valobj, lldb::DynamicValueType use_dynamic) { FormattersMatchVector matches; GetPossibleMatches(valobj, valobj.GetCompilerType(), - lldb_private::eFormatterChoiceCriterionDirectChoice, use_dynamic, matches, false, false, false, true); return matches; } @@ -184,7 +183,7 @@ private: static void GetPossibleMatches(ValueObject &valobj, - CompilerType compiler_type, uint32_t reason, + CompilerType compiler_type, lldb::DynamicValueType use_dynamic, FormattersMatchVector &entries, bool did_strip_ptr, bool did_strip_ref, diff --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h b/lldb/include/lldb/DataFormatters/FormattersContainer.h --- a/lldb/include/lldb/DataFormatters/FormattersContainer.h +++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h @@ -181,16 +181,13 @@ } bool Get(ValueObject &valobj, MapValueType &entry, - lldb::DynamicValueType use_dynamic, uint32_t *why = nullptr) { - uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice; + lldb::DynamicValueType use_dynamic) { CompilerType ast_type(valobj.GetCompilerType()); - bool ret = Get(valobj, ast_type, entry, use_dynamic, value); + bool ret = Get(valobj, ast_type, entry, use_dynamic); if (ret) entry = MapValueType(entry); else entry = MapValueType(); - if (why) - *why = value; return ret; } @@ -308,16 +305,13 @@ return false; } - bool Get(const FormattersMatchVector &candidates, MapValueType &entry, - uint32_t *reason) { + bool Get(const FormattersMatchVector &candidates, MapValueType &entry) { for (const FormattersMatchCandidate &candidate : candidates) { if (Get(candidate.GetTypeName(), entry)) { if (candidate.IsMatch(entry) == false) { entry.reset(); continue; } else { - if (reason) - *reason = candidate.GetReason(); return true; } } diff --git a/lldb/include/lldb/DataFormatters/TypeCategory.h b/lldb/include/lldb/DataFormatters/TypeCategory.h --- a/lldb/include/lldb/DataFormatters/TypeCategory.h +++ b/lldb/include/lldb/DataFormatters/TypeCategory.h @@ -285,13 +285,13 @@ } bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates, - lldb::TypeFormatImplSP &entry, uint32_t *reason = nullptr); + lldb::TypeFormatImplSP &entry); bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates, - lldb::TypeSummaryImplSP &entry, uint32_t *reason = nullptr); + lldb::TypeSummaryImplSP &entry); bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates, - lldb::SyntheticChildrenSP &entry, uint32_t *reason = nullptr); + lldb::SyntheticChildrenSP &entry); void Clear(FormatCategoryItems items = ALL_ITEM_TYPES); diff --git a/lldb/include/lldb/lldb-private-enumerations.h b/lldb/include/lldb/lldb-private-enumerations.h --- a/lldb/include/lldb/lldb-private-enumerations.h +++ b/lldb/include/lldb/lldb-private-enumerations.h @@ -148,18 +148,6 @@ eExecutionPolicyTopLevel // used for top-level code }; -// Ways that the FormatManager picks a particular format for a type -enum FormatterChoiceCriterion { - eFormatterChoiceCriterionDirectChoice = 0x00000000, - eFormatterChoiceCriterionStrippedPointerReference = 0x00000001, - eFormatterChoiceCriterionNavigatedTypedefs = 0x00000002, - eFormatterChoiceCriterionRegularExpressionSummary = 0x00000004, - eFormatterChoiceCriterionRegularExpressionFilter = 0x00000004, - eFormatterChoiceCriterionLanguagePlugin = 0x00000008, - eFormatterChoiceCriterionStrippedBitField = 0x00000010, - eFormatterChoiceCriterionWentToStaticValue = 0x00000020 -}; - // Synchronicity behavior of scripted commands enum ScriptedCommandSynchronicity { eScriptedCommandSynchronicitySynchronous, diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -174,7 +174,7 @@ } void FormatManager::GetPossibleMatches( - ValueObject &valobj, CompilerType compiler_type, uint32_t reason, + ValueObject &valobj, CompilerType compiler_type, lldb::DynamicValueType use_dynamic, FormattersMatchVector &entries, bool did_strip_ptr, bool did_strip_ref, bool did_strip_typedef, bool root_level) { @@ -185,17 +185,16 @@ sstring.Printf("%s:%d", type_name.AsCString(), valobj.GetBitfieldBitSize()); ConstString bitfieldname(sstring.GetString()); entries.push_back( - {bitfieldname, 0, did_strip_ptr, did_strip_ref, did_strip_typedef}); - reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField; + {bitfieldname, did_strip_ptr, did_strip_ref, did_strip_typedef}); } if (!compiler_type.IsMeaninglessWithoutDynamicResolution()) { entries.push_back( - {type_name, reason, did_strip_ptr, did_strip_ref, did_strip_typedef}); + {type_name, did_strip_ptr, did_strip_ref, did_strip_typedef}); ConstString display_type_name(compiler_type.GetTypeName()); if (display_type_name != type_name) - entries.push_back({display_type_name, reason, did_strip_ptr, + entries.push_back({display_type_name, did_strip_ptr, did_strip_ref, did_strip_typedef}); } @@ -204,8 +203,6 @@ CompilerType non_ref_type = compiler_type.GetNonReferenceType(); GetPossibleMatches( valobj, non_ref_type, - reason | - lldb_private::eFormatterChoiceCriterionStrippedPointerReference, use_dynamic, entries, did_strip_ptr, true, did_strip_typedef); if (non_ref_type.IsTypedefType()) { CompilerType deffed_referenced_type = non_ref_type.GetTypedefedType(); @@ -214,7 +211,6 @@ : deffed_referenced_type.GetLValueReferenceType(); GetPossibleMatches( valobj, deffed_referenced_type, - reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs, use_dynamic, entries, did_strip_ptr, did_strip_ref, true); // this is not exactly the usual meaning of stripping typedefs } @@ -224,8 +220,6 @@ CompilerType non_ptr_type = compiler_type.GetPointeeType(); GetPossibleMatches( valobj, non_ptr_type, - reason | - lldb_private::eFormatterChoiceCriterionStrippedPointerReference, use_dynamic, entries, true, did_strip_ref, did_strip_typedef); if (non_ptr_type.IsTypedefType()) { CompilerType deffed_pointed_type = @@ -233,7 +227,6 @@ const bool stripped_typedef = true; GetPossibleMatches( valobj, deffed_pointed_type, - reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs, use_dynamic, entries, did_strip_ptr, did_strip_ref, stripped_typedef); // this is not exactly the usual meaning of // stripping typedefs @@ -253,7 +246,6 @@ const bool stripped_typedef = true; GetPossibleMatches( valobj, deffed_array_type, - reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs, use_dynamic, entries, did_strip_ptr, did_strip_ref, stripped_typedef); // this is not exactly the usual meaning of // stripping typedefs @@ -267,7 +259,6 @@ language->GetPossibleFormattersMatches(valobj, use_dynamic)) { entries.push_back( {candidate, - reason | lldb_private::eFormatterChoiceCriterionLanguagePlugin, did_strip_ptr, did_strip_ref, did_strip_typedef}); } } @@ -278,7 +269,6 @@ CompilerType deffed_type = compiler_type.GetTypedefedType(); GetPossibleMatches( valobj, deffed_type, - reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs, use_dynamic, entries, did_strip_ptr, did_strip_ref, true); } @@ -293,7 +283,7 @@ break; if (unqual_compiler_ast_type.GetOpaqueQualType() != compiler_type.GetOpaqueQualType()) - GetPossibleMatches(valobj, unqual_compiler_ast_type, reason, + GetPossibleMatches(valobj, unqual_compiler_ast_type, use_dynamic, entries, did_strip_ptr, did_strip_ref, did_strip_typedef); } while (false); @@ -304,7 +294,6 @@ if (static_value_sp) GetPossibleMatches( *static_value_sp.get(), static_value_sp->GetCompilerType(), - reason | lldb_private::eFormatterChoiceCriterionWentToStaticValue, use_dynamic, entries, did_strip_ptr, did_strip_ref, did_strip_typedef, true); } diff --git a/lldb/source/DataFormatters/TypeCategory.cpp b/lldb/source/DataFormatters/TypeCategory.cpp --- a/lldb/source/DataFormatters/TypeCategory.cpp +++ b/lldb/source/DataFormatters/TypeCategory.cpp @@ -86,51 +86,43 @@ bool TypeCategoryImpl::Get(lldb::LanguageType lang, const FormattersMatchVector &candidates, - lldb::TypeFormatImplSP &entry, uint32_t *reason) { + lldb::TypeFormatImplSP &entry) { if (!IsEnabled() || !IsApplicable(lang)) return false; - if (GetTypeFormatsContainer()->Get(candidates, entry, reason)) + if (GetTypeFormatsContainer()->Get(candidates, entry)) return true; - bool regex = GetRegexTypeFormatsContainer()->Get(candidates, entry, reason); - if (regex && reason) - *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary; + bool regex = GetRegexTypeFormatsContainer()->Get(candidates, entry); return regex; } bool TypeCategoryImpl::Get(lldb::LanguageType lang, const FormattersMatchVector &candidates, - lldb::TypeSummaryImplSP &entry, uint32_t *reason) { + lldb::TypeSummaryImplSP &entry) { if (!IsEnabled() || !IsApplicable(lang)) return false; - if (GetTypeSummariesContainer()->Get(candidates, entry, reason)) + if (GetTypeSummariesContainer()->Get(candidates, entry)) return true; - bool regex = GetRegexTypeSummariesContainer()->Get(candidates, entry, reason); - if (regex && reason) - *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary; + bool regex = GetRegexTypeSummariesContainer()->Get(candidates, entry); return regex; } bool TypeCategoryImpl::Get(lldb::LanguageType lang, const FormattersMatchVector &candidates, - lldb::SyntheticChildrenSP &entry, uint32_t *reason) { + lldb::SyntheticChildrenSP &entry) { if (!IsEnabled() || !IsApplicable(lang)) return false; TypeFilterImpl::SharedPointer filter_sp; - uint32_t reason_filter = 0; bool regex_filter = false; // first find both Filter and Synth, and then check which is most recent - if (!GetTypeFiltersContainer()->Get(candidates, filter_sp, &reason_filter)) - regex_filter = GetRegexTypeFiltersContainer()->Get(candidates, filter_sp, - &reason_filter); + if (!GetTypeFiltersContainer()->Get(candidates, filter_sp)) + regex_filter = GetRegexTypeFiltersContainer()->Get(candidates, filter_sp); bool regex_synth = false; - uint32_t reason_synth = 0; bool pick_synth = false; ScriptedSyntheticChildren::SharedPointer synth; - if (!GetTypeSyntheticsContainer()->Get(candidates, synth, &reason_synth)) - regex_synth = GetRegexTypeSyntheticsContainer()->Get(candidates, synth, - &reason_synth); + if (!GetTypeSyntheticsContainer()->Get(candidates, synth)) + regex_synth = GetRegexTypeSyntheticsContainer()->Get(candidates, synth); if (!filter_sp.get() && !synth.get()) return false; else if (!filter_sp.get() && synth.get()) @@ -144,13 +136,9 @@ pick_synth = filter_sp->GetRevision() <= synth->GetRevision(); } if (pick_synth) { - if (regex_synth && reason) - *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter; entry = synth; return true; } else { - if (regex_filter && reason) - *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter; entry = filter_sp; return true; } diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp --- a/lldb/source/DataFormatters/TypeCategoryMap.cpp +++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp @@ -172,7 +172,6 @@ void TypeCategoryMap::Get(FormattersMatchData &match_data, ImplSP &retval) { std::lock_guard guard(m_map_mutex); - uint32_t reason_why; ActiveCategoriesIterator begin, end = m_active_categories.end(); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS)); @@ -181,13 +180,12 @@ for (auto match : match_data.GetMatchesVector()) { LLDB_LOGF( log, - "[%s] candidate match = %s %s %s %s reason = %" PRIu32, + "[%s] candidate match = %s %s %s %s", __FUNCTION__, match.GetTypeName().GetCString(), match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers", match.DidStripReference() ? "strip-reference" : "no-strip-reference", - match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef", - match.GetReason()); + match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef"); } } @@ -198,7 +196,7 @@ category_sp->GetName()); if (!category_sp->Get( match_data.GetValueObject().GetObjectRuntimeLanguage(), - match_data.GetMatchesVector(), current_format, &reason_why)) + match_data.GetMatchesVector(), current_format)) continue; retval = std::move(current_format);