[NFCI] More TypeCategoryImpl refactoring.

The main aim of this patch is to delete the remaining instances of code
reaching into the internals of `TypeCategoryImpl`. I made the following
changes:

- Add some more methods to `TieredFormatterContainer` and
  `TypeCategoryImpl` to expose functionality that is implemented in
  `FormattersContainer`.

- Add new overloads of `TypeCategoryImpl::AddTypeXXX` to make it easier
  to add formatters to categories without reaching into the internal
  `FormattersContainer` objects.

- Remove the `GetTypeXXXContainer` and `GetRegexTypeXXXContainer`
  accessors from `TypeCategoryImpl` and update all call sites to use the
  new methods instead.

Differential Revision: https://reviews.llvm.org/D135399
This commit is contained in:
Jorge Gorbe Moya 2022-09-22 11:00:22 -07:00
parent 7a3c9a85c5
commit e5fd507f9b
7 changed files with 258 additions and 317 deletions

View File

@ -45,14 +45,10 @@ public:
sc = std::make_shared<Subcontainer>(change_listener);
}
/// Returns the subcontainer containing formatters for exact matching.
std::shared_ptr<Subcontainer> GetExactMatch() const {
return m_subcontainers[lldb::eFormatterMatchExact];
}
/// Returns the subcontainer containing formatters for regex matching.
std::shared_ptr<Subcontainer> GetRegexMatch() const {
return m_subcontainers[lldb::eFormatterMatchRegex];
/// Clears all subcontainers.
void Clear() {
for (auto sc : m_subcontainers)
sc->Clear();
}
/// Adds a formatter to the right subcontainer depending on the matching type
@ -69,6 +65,15 @@ public:
TypeMatcher(type_sp));
}
/// Deletes all formatters registered with the string `name`, in all
/// subcontainers.
bool Delete(ConstString name) {
bool success = false;
for (auto sc : m_subcontainers)
success = sc->Delete(name) || success;
return success;
}
/// Returns the total count of elements across all subcontainers.
uint32_t GetCount() {
uint32_t result = 0;
@ -100,6 +105,15 @@ public:
return false;
}
bool AnyMatches(ConstString type_name) {
std::shared_ptr<FormatterImpl> entry;
for (auto sc : m_subcontainers) {
if (sc->Get(type_name, entry))
return true;
}
return false;
}
/// Returns a formatter that is an exact match for `type_specifier_sp`. It
/// looks for a formatter with the same matching type that was created from
/// the same string. This is useful so we can refer to a formatter using the
@ -140,6 +154,11 @@ public:
}
}
void AutoComplete(CompletionRequest &request) {
for (auto sc: m_subcontainers)
sc->AutoComplete(request);
}
private:
std::array<std::shared_ptr<Subcontainer>, lldb::eLastFormatterMatchType + 1>
m_subcontainers;
@ -188,36 +207,6 @@ public:
m_synth_cont.ForEach(callback.callback);
}
FormatContainer::SubcontainerSP GetTypeFormatsContainer() {
return m_format_cont.GetExactMatch();
}
FormatContainer::SubcontainerSP GetRegexTypeFormatsContainer() {
return m_format_cont.GetRegexMatch();
}
FormatContainer &GetFormatContainer() { return m_format_cont; }
SummaryContainer::SubcontainerSP GetTypeSummariesContainer() {
return m_summary_cont.GetExactMatch();
}
SummaryContainer::SubcontainerSP GetRegexTypeSummariesContainer() {
return m_summary_cont.GetRegexMatch();
}
SummaryContainer &GetSummaryContainer() { return m_summary_cont; }
FilterContainer::SubcontainerSP GetTypeFiltersContainer() {
return m_filter_cont.GetExactMatch();
}
FilterContainer::SubcontainerSP GetRegexTypeFiltersContainer() {
return m_filter_cont.GetRegexMatch();
}
FilterContainer &GetFilterContainer() { return m_filter_cont; }
FormatContainer::MapValueType
GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp);
@ -235,21 +224,50 @@ public:
m_format_cont.Add(type_sp, format_sp);
}
void AddTypeFormat(llvm::StringRef name, lldb::FormatterMatchType match_type,
lldb::TypeFormatImplSP format_sp) {
AddTypeFormat(
std::make_shared<lldb_private::TypeNameSpecifierImpl>(name, match_type),
format_sp);
}
void AddTypeSummary(lldb::TypeNameSpecifierImplSP type_sp,
lldb::TypeSummaryImplSP summary_sp) {
m_summary_cont.Add(type_sp, summary_sp);
}
void AddTypeSummary(llvm::StringRef name, lldb::FormatterMatchType match_type,
lldb::TypeSummaryImplSP summary_sp) {
AddTypeSummary(
std::make_shared<lldb_private::TypeNameSpecifierImpl>(name, match_type),
summary_sp);
}
void AddTypeFilter(lldb::TypeNameSpecifierImplSP type_sp,
lldb::TypeFilterImplSP filter_sp) {
m_filter_cont.Add(type_sp, filter_sp);
}
void AddTypeFilter(llvm::StringRef name, lldb::FormatterMatchType match_type,
lldb::TypeFilterImplSP filter_sp) {
AddTypeFilter(
std::make_shared<lldb_private::TypeNameSpecifierImpl>(name, match_type),
filter_sp);
}
void AddTypeSynthetic(lldb::TypeNameSpecifierImplSP type_sp,
lldb::SyntheticChildrenSP synth_sp) {
m_synth_cont.Add(type_sp, synth_sp);
}
void AddTypeSynthetic(llvm::StringRef name,
lldb::FormatterMatchType match_type,
lldb::SyntheticChildrenSP synth_sp) {
AddTypeSynthetic(
std::make_shared<lldb_private::TypeNameSpecifierImpl>(name, match_type),
synth_sp);
}
bool DeleteTypeFormat(lldb::TypeNameSpecifierImplSP type_sp) {
return m_format_cont.Delete(type_sp);
}
@ -294,17 +312,6 @@ public:
SynthContainer::MapValueType GetSyntheticAtIndex(size_t index);
SynthContainer::SubcontainerSP GetTypeSyntheticsContainer() {
return m_synth_cont.GetExactMatch();
}
SynthContainer::SubcontainerSP GetRegexTypeSyntheticsContainer() {
return m_synth_cont.GetRegexMatch();
}
SynthContainer &GetSyntheticsContainer() { return m_synth_cont; }
bool IsEnabled() const { return m_enabled; }
uint32_t GetEnabledPosition() {
@ -345,6 +352,8 @@ public:
const char **matching_category = nullptr,
FormatCategoryItems *matching_type = nullptr);
void AutoComplete(CompletionRequest &request, FormatCategoryItems items);
typedef std::shared_ptr<TypeCategoryImpl> SharedPointer;
private:

View File

@ -681,19 +681,17 @@ protected:
return false;
}
ConstString typeCS(arg_entry.ref());
FormatterMatchType match_type = eFormatterMatchExact;
if (m_command_options.m_regex) {
match_type = eFormatterMatchRegex;
RegularExpression typeRX(arg_entry.ref());
if (!typeRX.IsValid()) {
result.AppendError(
"regex format error (maybe this is not really a regex?)");
return false;
}
category_sp->GetRegexTypeSummariesContainer()->Delete(typeCS);
category_sp->GetRegexTypeFormatsContainer()->Add(std::move(typeRX),
entry);
} else
category_sp->GetTypeFormatsContainer()->Add(std::move(typeCS), entry);
}
category_sp->AddTypeFormat(arg_entry.ref(), match_type, entry);
}
result.SetStatus(eReturnStatusSuccessFinishNoResult);
@ -783,27 +781,7 @@ public:
DataVisualization::Categories::ForEach(
[this, &request](const lldb::TypeCategoryImplSP &category_sp) {
if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemFormat)) {
category_sp->GetTypeFormatsContainer()->AutoComplete(request);
category_sp->GetRegexTypeFormatsContainer()->AutoComplete(request);
}
if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemSummary)) {
category_sp->GetTypeSummariesContainer()->AutoComplete(request);
category_sp->GetRegexTypeSummariesContainer()->AutoComplete(
request);
}
if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemFilter)) {
category_sp->GetTypeFiltersContainer()->AutoComplete(request);
category_sp->GetRegexTypeFiltersContainer()->AutoComplete(request);
}
if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemSynth)) {
category_sp->GetTypeSyntheticsContainer()->AutoComplete(request);
category_sp->GetRegexTypeSyntheticsContainer()->AutoComplete(
request);
}
category_sp->AutoComplete(request, m_formatter_kind_mask);
return true;
});
}
@ -1572,6 +1550,15 @@ bool CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name,
SummaryFormatType type,
std::string category_name,
Status *error) {
// Named summaries are a special case, they exist in their own map in the
// FormatManager, outside of any categories.
if (type == eNamedSummary) {
// system named summaries do not exist (yet?)
DataVisualization::NamedSummaryFormats::Add(type_name, entry);
return true;
}
lldb::TypeCategoryImplSP category;
DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()),
category);
@ -1581,7 +1568,9 @@ bool CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name,
type = eRegexSummary;
}
FormatterMatchType match_type = eFormatterMatchExact;
if (type == eRegexSummary) {
match_type = eFormatterMatchRegex;
RegularExpression typeRX(type_name.GetStringRef());
if (!typeRX.IsValid()) {
if (error)
@ -1589,19 +1578,9 @@ bool CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name,
"regex format error (maybe this is not really a regex?)");
return false;
}
category->GetRegexTypeSummariesContainer()->Delete(type_name);
category->GetRegexTypeSummariesContainer()->Add(std::move(typeRX), entry);
return true;
} else if (type == eNamedSummary) {
// system named summaries do not exist (yet?)
DataVisualization::NamedSummaryFormats::Add(type_name, entry);
return true;
} else {
category->GetTypeSummariesContainer()->Add(std::move(type_name), entry);
return true;
}
category->AddTypeSummary(type_name.GetStringRef(), match_type, entry);
return true;
}
// CommandObjectTypeSummaryDelete
@ -2332,7 +2311,9 @@ bool CommandObjectTypeSynthAdd::AddSynth(ConstString type_name,
}
}
FormatterMatchType match_type = eFormatterMatchExact;
if (type == eRegexSynth) {
match_type = eFormatterMatchRegex;
RegularExpression typeRX(type_name.GetStringRef());
if (!typeRX.IsValid()) {
if (error)
@ -2340,15 +2321,10 @@ bool CommandObjectTypeSynthAdd::AddSynth(ConstString type_name,
"regex format error (maybe this is not really a regex?)");
return false;
}
category->GetRegexTypeSyntheticsContainer()->Delete(type_name);
category->GetRegexTypeSyntheticsContainer()->Add(std::move(typeRX), entry);
return true;
} else {
category->GetTypeSyntheticsContainer()->Add(std::move(type_name), entry);
return true;
}
category->AddTypeSynthetic(type_name.GetStringRef(), match_type, entry);
return true;
}
#endif
@ -2461,7 +2437,9 @@ private:
}
}
FormatterMatchType match_type = eFormatterMatchExact;
if (type == eRegexFilter) {
match_type = eFormatterMatchRegex;
RegularExpression typeRX(type_name.GetStringRef());
if (!typeRX.IsValid()) {
if (error)
@ -2469,15 +2447,9 @@ private:
"regex format error (maybe this is not really a regex?)");
return false;
}
category->GetRegexTypeFiltersContainer()->Delete(type_name);
category->GetRegexTypeFiltersContainer()->Add(std::move(typeRX), entry);
return true;
} else {
category->GetTypeFiltersContainer()->Add(std::move(type_name), entry);
return true;
}
category->AddTypeFilter(type_name.GetStringRef(), match_type, entry);
return true;
}
public:

View File

@ -707,16 +707,14 @@ void FormatManager::LoadSystemFormatters() {
lldb::TypeSummaryImplSP string_array_format(
new StringSummaryFormat(string_array_flags, "${var%char[]}"));
RegularExpression any_size_char_arr(R"(^((un)?signed )?char ?\[[0-9]+\]$)");
TypeCategoryImpl::SharedPointer sys_category_sp =
GetCategory(m_system_category_name);
sys_category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression(R"(^(unsigned )?char ?(\*|\[\])$)"), string_format);
sys_category_sp->AddTypeSummary(R"(^(unsigned )?char ?(\*|\[\])$)",
eFormatterMatchRegex, string_format);
sys_category_sp->GetRegexTypeSummariesContainer()->Add(
std::move(any_size_char_arr), string_array_format);
sys_category_sp->AddTypeSummary(R"(^((un)?signed )?char ?\[[0-9]+\]$)",
eFormatterMatchRegex, string_array_format);
lldb::TypeSummaryImplSP ostype_summary(
new StringSummaryFormat(TypeSummaryImpl::Flags()
@ -729,8 +727,8 @@ void FormatManager::LoadSystemFormatters() {
.SetHideItemNames(false),
"${var%O}"));
sys_category_sp->GetTypeSummariesContainer()->Add(ConstString("OSType"),
ostype_summary);
sys_category_sp->AddTypeSummary("OSType", eFormatterMatchExact,
ostype_summary);
TypeFormatImpl::Flags fourchar_flags;
fourchar_flags.SetCascades(true).SetSkipPointers(true).SetSkipReferences(

View File

@ -26,23 +26,17 @@ void lldb_private::formatters::AddFormat(
ConstString type_name, TypeFormatImpl::Flags flags, bool regex) {
lldb::TypeFormatImplSP format_sp(new TypeFormatImpl_Format(format, flags));
if (regex)
category_sp->GetRegexTypeFormatsContainer()->Add(
RegularExpression(type_name.GetStringRef()), format_sp);
else
category_sp->GetTypeFormatsContainer()->Add(std::move(type_name),
format_sp);
FormatterMatchType match_type =
regex ? eFormatterMatchRegex : eFormatterMatchExact;
category_sp->AddTypeFormat(type_name.GetStringRef(), match_type, format_sp);
}
void lldb_private::formatters::AddSummary(
TypeCategoryImpl::SharedPointer category_sp, TypeSummaryImplSP summary_sp,
ConstString type_name, bool regex) {
if (regex)
category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression(type_name.GetStringRef()), summary_sp);
else
category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
summary_sp);
FormatterMatchType match_type =
regex ? eFormatterMatchRegex : eFormatterMatchExact;
category_sp->AddTypeSummary(type_name.GetStringRef(), match_type, summary_sp);
}
void lldb_private::formatters::AddStringSummary(
@ -50,12 +44,9 @@ void lldb_private::formatters::AddStringSummary(
ConstString type_name, TypeSummaryImpl::Flags flags, bool regex) {
lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags, string));
if (regex)
category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression(type_name.GetStringRef()), summary_sp);
else
category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
summary_sp);
FormatterMatchType match_type =
regex ? eFormatterMatchRegex : eFormatterMatchExact;
category_sp->AddTypeSummary(type_name.GetStringRef(), match_type, summary_sp);
}
void lldb_private::formatters::AddOneLineSummary(
@ -64,12 +55,9 @@ void lldb_private::formatters::AddOneLineSummary(
flags.SetShowMembersOneLiner(true);
lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags, ""));
if (regex)
category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression(type_name.GetStringRef()), summary_sp);
else
category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
summary_sp);
FormatterMatchType match_type =
regex ? eFormatterMatchRegex : eFormatterMatchExact;
category_sp->AddTypeSummary(type_name.GetStringRef(), match_type, summary_sp);
}
void lldb_private::formatters::AddCXXSummary(
@ -78,12 +66,10 @@ void lldb_private::formatters::AddCXXSummary(
ConstString type_name, TypeSummaryImpl::Flags flags, bool regex) {
lldb::TypeSummaryImplSP summary_sp(
new CXXFunctionSummaryFormat(flags, funct, description));
if (regex)
category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression(type_name.GetStringRef()), summary_sp);
else
category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
summary_sp);
FormatterMatchType match_type =
regex ? eFormatterMatchRegex : eFormatterMatchExact;
category_sp->AddTypeSummary(type_name.GetStringRef(), match_type, summary_sp);
}
void lldb_private::formatters::AddCXXSynthetic(
@ -93,12 +79,9 @@ void lldb_private::formatters::AddCXXSynthetic(
ScriptedSyntheticChildren::Flags flags, bool regex) {
lldb::SyntheticChildrenSP synth_sp(
new CXXSyntheticChildren(flags, description, generator));
if (regex)
category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpression(type_name.GetStringRef()), synth_sp);
else
category_sp->GetTypeSyntheticsContainer()->Add(std::move(type_name),
synth_sp);
FormatterMatchType match_type =
regex ? eFormatterMatchRegex : eFormatterMatchExact;
category_sp->AddTypeSynthetic(type_name.GetStringRef(), match_type, synth_sp);
}
void lldb_private::formatters::AddFilter(
@ -108,12 +91,9 @@ void lldb_private::formatters::AddFilter(
TypeFilterImplSP filter_sp(new TypeFilterImpl(flags));
for (auto child : children)
filter_sp->AddExpressionPath(child);
if (regex)
category_sp->GetRegexTypeFiltersContainer()->Add(
RegularExpression(type_name.GetStringRef()), filter_sp);
else
category_sp->GetTypeFiltersContainer()->Add(std::move(type_name),
filter_sp);
FormatterMatchType match_type =
regex ? eFormatterMatchRegex : eFormatterMatchExact;
category_sp->AddTypeFilter(type_name.GetStringRef(), match_type, filter_sp);
}
size_t lldb_private::formatters::ExtractIndexFromString(const char *item_name) {

View File

@ -135,49 +135,33 @@ bool TypeCategoryImpl::Get(lldb::LanguageType lang,
}
void TypeCategoryImpl::Clear(FormatCategoryItems items) {
if (items & eFormatCategoryItemFormat) {
GetTypeFormatsContainer()->Clear();
GetRegexTypeFormatsContainer()->Clear();
}
if (items & eFormatCategoryItemFormat)
m_format_cont.Clear();
if (items & eFormatCategoryItemSummary) {
GetTypeSummariesContainer()->Clear();
GetRegexTypeSummariesContainer()->Clear();
}
if (items & eFormatCategoryItemSummary)
m_summary_cont.Clear();
if (items & eFormatCategoryItemFilter) {
GetTypeFiltersContainer()->Clear();
GetRegexTypeFiltersContainer()->Clear();
}
if (items & eFormatCategoryItemFilter)
m_filter_cont.Clear();
if (items & eFormatCategoryItemSynth) {
GetTypeSyntheticsContainer()->Clear();
GetRegexTypeSyntheticsContainer()->Clear();
}
if (items & eFormatCategoryItemSynth)
m_synth_cont.Clear();
}
bool TypeCategoryImpl::Delete(ConstString name, FormatCategoryItems items) {
bool success = false;
if (items & eFormatCategoryItemFormat) {
success = GetTypeFormatsContainer()->Delete(name) || success;
success = GetRegexTypeFormatsContainer()->Delete(name) || success;
}
if (items & eFormatCategoryItemFormat)
success = m_format_cont.Delete(name) || success;
if (items & eFormatCategoryItemSummary) {
success = GetTypeSummariesContainer()->Delete(name) || success;
success = GetRegexTypeSummariesContainer()->Delete(name) || success;
}
if (items & eFormatCategoryItemSummary)
success = m_summary_cont.Delete(name) || success;
if (items & eFormatCategoryItemFilter) {
success = GetTypeFiltersContainer()->Delete(name) || success;
success = GetRegexTypeFiltersContainer()->Delete(name) || success;
}
if (items & eFormatCategoryItemFilter)
success = m_filter_cont.Delete(name) || success;
if (items & eFormatCategoryItemSynth) {
success = GetTypeSyntheticsContainer()->Delete(name) || success;
success = GetRegexTypeSyntheticsContainer()->Delete(name) || success;
}
if (items & eFormatCategoryItemSynth)
success = m_synth_cont.Delete(name) || success;
return success;
}
@ -185,25 +169,17 @@ bool TypeCategoryImpl::Delete(ConstString name, FormatCategoryItems items) {
uint32_t TypeCategoryImpl::GetCount(FormatCategoryItems items) {
uint32_t count = 0;
if (items & eFormatCategoryItemFormat) {
count += GetTypeFormatsContainer()->GetCount();
count += GetRegexTypeFormatsContainer()->GetCount();
}
if (items & eFormatCategoryItemFormat)
count += m_format_cont.GetCount();
if (items & eFormatCategoryItemSummary) {
count += GetTypeSummariesContainer()->GetCount();
count += GetRegexTypeSummariesContainer()->GetCount();
}
if (items & eFormatCategoryItemSummary)
count += m_summary_cont.GetCount();
if (items & eFormatCategoryItemFilter) {
count += GetTypeFiltersContainer()->GetCount();
count += GetRegexTypeFiltersContainer()->GetCount();
}
if (items & eFormatCategoryItemFilter)
count += m_filter_cont.GetCount();
if (items & eFormatCategoryItemSynth) {
count += GetTypeSyntheticsContainer()->GetCount();
count += GetRegexTypeSyntheticsContainer()->GetCount();
}
if (items & eFormatCategoryItemSynth)
count += m_synth_cont.GetCount();
return count;
}
@ -221,8 +197,7 @@ bool TypeCategoryImpl::AnyMatches(ConstString type_name,
ScriptedSyntheticChildren::SharedPointer synth_sp;
if (items & eFormatCategoryItemFormat) {
if (GetTypeFormatsContainer()->Get(type_name, format_sp) ||
GetRegexTypeFormatsContainer()->Get(type_name, format_sp)) {
if (m_format_cont.AnyMatches(type_name)) {
if (matching_category)
*matching_category = m_name.GetCString();
if (matching_type)
@ -232,8 +207,7 @@ bool TypeCategoryImpl::AnyMatches(ConstString type_name,
}
if (items & eFormatCategoryItemSummary) {
if (GetTypeSummariesContainer()->Get(type_name, summary_sp) ||
GetRegexTypeSummariesContainer()->Get(type_name, summary_sp)) {
if (m_summary_cont.AnyMatches(type_name)) {
if (matching_category)
*matching_category = m_name.GetCString();
if (matching_type)
@ -243,8 +217,7 @@ bool TypeCategoryImpl::AnyMatches(ConstString type_name,
}
if (items & eFormatCategoryItemFilter) {
if (GetTypeFiltersContainer()->Get(type_name, filter_sp) ||
GetRegexTypeFiltersContainer()->Get(type_name, filter_sp)) {
if (m_filter_cont.AnyMatches(type_name)) {
if (matching_category)
*matching_category = m_name.GetCString();
if (matching_type)
@ -254,8 +227,7 @@ bool TypeCategoryImpl::AnyMatches(ConstString type_name,
}
if (items & eFormatCategoryItemSynth) {
if (GetTypeSyntheticsContainer()->Get(type_name, synth_sp) ||
GetRegexTypeSyntheticsContainer()->Get(type_name, synth_sp)) {
if (m_synth_cont.AnyMatches(type_name)) {
if (matching_category)
*matching_category = m_name.GetCString();
if (matching_type)
@ -267,6 +239,18 @@ bool TypeCategoryImpl::AnyMatches(ConstString type_name,
return false;
}
void TypeCategoryImpl::AutoComplete(CompletionRequest &request,
FormatCategoryItems items) {
if (items & eFormatCategoryItemFormat)
m_format_cont.AutoComplete(request);
if (items & eFormatCategoryItemSummary)
m_summary_cont.AutoComplete(request);
if (items & eFormatCategoryItemFilter)
m_filter_cont.AutoComplete(request);
if (items & eFormatCategoryItemSynth)
m_synth_cont.AutoComplete(request);
}
TypeCategoryImpl::FormatContainer::MapValueType
TypeCategoryImpl::GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp) {
return m_format_cont.GetForTypeNameSpecifier(type_sp);

View File

@ -764,8 +764,8 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
ConstString("^std::__[[:alnum:]]+::span<.+>(( )?&)?$"), stl_deref_flags,
true);
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpression("^(std::__[[:alnum:]]+::)deque<.+>(( )?&)?$"),
cpp_category_sp->AddTypeSynthetic(
"^(std::__[[:alnum:]]+::)deque<.+>(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_synth_flags,
"lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
@ -958,55 +958,52 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
stl_summary_flags, LibStdcppWStringSummaryProvider,
"libstdc++ c++11 std::wstring summary provider"));
cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::string"),
std_string_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::basic_string<char>"), std_string_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::basic_string<char,std::char_traits<char>,std::"
"allocator<char> >"),
std_string_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::basic_string<char, std::char_traits<char>, "
"std::allocator<char> >"),
std_string_summary_sp);
cpp_category_sp->AddTypeSummary("std::string", eFormatterMatchExact,
std_string_summary_sp);
cpp_category_sp->AddTypeSummary("std::basic_string<char>",
eFormatterMatchRegex, std_string_summary_sp);
cpp_category_sp->AddTypeSummary(
"std::basic_string<char,std::char_traits<char>,std::allocator<char> >",
eFormatterMatchExact, std_string_summary_sp);
cpp_category_sp->AddTypeSummary(
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >",
eFormatterMatchExact, std_string_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::__cxx11::string"), cxx11_string_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::__cxx11::basic_string<char, std::char_traits<char>, "
"std::allocator<char> >"),
cxx11_string_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::__cxx11::basic_string<unsigned char, "
"std::char_traits<unsigned char>, "
"std::allocator<unsigned char> >"),
cxx11_string_summary_sp);
cpp_category_sp->AddTypeSummary("std::__cxx11::string", eFormatterMatchExact,
cxx11_string_summary_sp);
cpp_category_sp->AddTypeSummary(
"std::__cxx11::basic_string<char, std::char_traits<char>, "
"std::allocator<char> >",
eFormatterMatchExact, cxx11_string_summary_sp);
cpp_category_sp->AddTypeSummary("std::__cxx11::basic_string<unsigned char, "
"std::char_traits<unsigned char>, "
"std::allocator<unsigned char> >",
eFormatterMatchExact,
cxx11_string_summary_sp);
// making sure we force-pick the summary for printing wstring (_M_p is a
// wchar_t*)
lldb::TypeSummaryImplSP std_wstring_summary_sp(
new StringSummaryFormat(stl_summary_flags, "${var._M_dataplus._M_p%S}"));
cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::wstring"),
std_wstring_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::basic_string<wchar_t>"), std_wstring_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::basic_string<wchar_t,std::char_traits<wchar_t>,std::"
"allocator<wchar_t> >"),
std_wstring_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::basic_string<wchar_t, std::char_traits<wchar_t>, "
"std::allocator<wchar_t> >"),
std_wstring_summary_sp);
cpp_category_sp->AddTypeSummary("std::wstring", eFormatterMatchExact,
std_wstring_summary_sp);
cpp_category_sp->AddTypeSummary("std::basic_string<wchar_t>",
eFormatterMatchExact, std_wstring_summary_sp);
cpp_category_sp->AddTypeSummary("std::basic_string<wchar_t,std::char_traits<"
"wchar_t>,std::allocator<wchar_t> >",
eFormatterMatchExact, std_wstring_summary_sp);
cpp_category_sp->AddTypeSummary(
"std::basic_string<wchar_t, std::char_traits<wchar_t>, "
"std::allocator<wchar_t> >",
eFormatterMatchExact, std_wstring_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::__cxx11::wstring"), cxx11_wstring_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::__cxx11::basic_string<wchar_t, "
"std::char_traits<wchar_t>, std::allocator<wchar_t> >"),
cxx11_wstring_summary_sp);
cpp_category_sp->AddTypeSummary("std::__cxx11::wstring", eFormatterMatchExact,
cxx11_wstring_summary_sp);
cpp_category_sp->AddTypeSummary(
"std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, "
"std::allocator<wchar_t> >",
eFormatterMatchExact, cxx11_wstring_summary_sp);
SyntheticChildren::Flags stl_synth_flags;
stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
@ -1014,94 +1011,95 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
SyntheticChildren::Flags stl_deref_flags = stl_synth_flags;
stl_deref_flags.SetFrontEndWantsDereference();
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpression("^std::vector<.+>(( )?&)?$"),
cpp_category_sp->AddTypeSynthetic(
"^std::vector<.+>(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_synth_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpression("^std::map<.+> >(( )?&)?$"),
cpp_category_sp->AddTypeSynthetic(
"^std::map<.+> >(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_synth_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpression("^std::deque<.+>(( )?&)?$"),
cpp_category_sp->AddTypeSynthetic(
"^std::deque<.+>(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider")));
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpression("^std::set<.+> >(( )?&)?$"),
cpp_category_sp->AddTypeSynthetic(
"^std::set<.+> >(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpression("^std::multimap<.+> >(( )?&)?$"),
cpp_category_sp->AddTypeSynthetic(
"^std::multimap<.+> >(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpression("^std::multiset<.+> >(( )?&)?$"),
cpp_category_sp->AddTypeSynthetic(
"^std::multiset<.+> >(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpression("^std::unordered_(multi)?(map|set)<.+> >$"),
cpp_category_sp->AddTypeSynthetic(
"^std::unordered_(multi)?(map|set)<.+> >$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider")));
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"),
cpp_category_sp->AddTypeSynthetic(
"^std::(__cxx11::)?list<.+>(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"),
cpp_category_sp->AddTypeSynthetic(
"^std::(__cxx11::)?forward_list<.+>(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_synth_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider")));
stl_summary_flags.SetDontShowChildren(false);
stl_summary_flags.SetSkipPointers(false);
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression("^std::bitset<.+>(( )?&)?$"),
TypeSummaryImplSP(
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression("^std::vector<.+>(( )?&)?$"),
TypeSummaryImplSP(
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression("^std::map<.+> >(( )?&)?$"),
TypeSummaryImplSP(
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression("^std::set<.+> >(( )?&)?$"),
TypeSummaryImplSP(
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression("^std::deque<.+>(( )?&)?$"),
TypeSummaryImplSP(
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression("^std::multimap<.+> >(( )?&)?$"),
TypeSummaryImplSP(
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression("^std::multiset<.+> >(( )?&)?$"),
TypeSummaryImplSP(
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression("^std::unordered_(multi)?(map|set)<.+> >$"),
TypeSummaryImplSP(
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"),
TypeSummaryImplSP(
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"),
TypeSummaryImplSP(
new ScriptSummaryFormat(stl_summary_flags, "lldb.formatters.cpp.gnu_libstdcpp.ForwardListSummaryProvider")));
cpp_category_sp->AddTypeSummary("^std::bitset<.+>(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->AddTypeSummary("^std::vector<.+>(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->AddTypeSummary("^std::map<.+> >(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->AddTypeSummary("^std::set<.+> >(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->AddTypeSummary("^std::deque<.+>(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->AddTypeSummary("^std::multimap<.+> >(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->AddTypeSummary("^std::multiset<.+> >(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->AddTypeSummary("^std::unordered_(multi)?(map|set)<.+> >$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->AddTypeSummary("^std::(__cxx11::)?list<.+>(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->AddTypeSummary(
"^std::(__cxx11::)?forward_list<.+>(( )?&)?$", eFormatterMatchRegex,
TypeSummaryImplSP(new ScriptSummaryFormat(
stl_summary_flags,
"lldb.formatters.cpp.gnu_libstdcpp.ForwardListSummaryProvider")));
AddCXXSynthetic(
cpp_category_sp,

View File

@ -284,12 +284,12 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
lldb::TypeSummaryImplSP ObjC_BOOL_summary(new CXXFunctionSummaryFormat(
objc_flags, lldb_private::formatters::ObjCBOOLSummaryProvider, ""));
objc_category_sp->GetTypeSummariesContainer()->Add(ConstString("BOOL"),
ObjC_BOOL_summary);
objc_category_sp->GetTypeSummariesContainer()->Add(ConstString("BOOL &"),
ObjC_BOOL_summary);
objc_category_sp->GetTypeSummariesContainer()->Add(ConstString("BOOL *"),
ObjC_BOOL_summary);
objc_category_sp->AddTypeSummary("BOOL", eFormatterMatchExact,
ObjC_BOOL_summary);
objc_category_sp->AddTypeSummary("BOOL &", eFormatterMatchExact,
ObjC_BOOL_summary);
objc_category_sp->AddTypeSummary("BOOL *", eFormatterMatchExact,
ObjC_BOOL_summary);
// we need to skip pointers here since we are special casing a SEL* when
// retrieving its value