You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CommandObjectTypeSynthAdd::AddSynth has some code to check for conflicting filters in the same category (there's a symmetric check for conflicting synth providers when adding a new filter, but let's focus on only one case). The check looks like this:
if (category->AnyMatches(type_name, eFormatCategoryItemFilter, false)) {
if (error)
error->SetErrorStringWithFormat("cannot add synthetic for type %s when ""filter is defined in same category!",
type_name.AsCString());
returnfalse;
}
The important detail here is that type_name can actually be either a type name or a regex (if using type synthetic add -x). However, category->AnyMatches always treats type_name as a type name, and will try to match a regex string against other regex strings, which is not correct.
For example, this is lldb working correctly and rejecting a conflicting formatter.
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> class my_child_provider:
... pass
...
>>> ^D
now exiting InteractiveConsole...
(lldb) type synthetic add -l my_child_provider whatever
(lldb) type filter add --child a whatever
error: cannot add filter for type whatever when synthetic is defined in same category!
However, if we use regex it will happily accept conflicting formatters:
(lldb) type synthetic add -l my_child_provider -x "^whatever$"
(lldb) type filter add --child a -x "^whatever$"
(lldb)
because the string "^whatever$" is not matched by the regex "^whatever$".
We can also make it fail the other way around, and make it incorrectly reject non-conflicting formatters. For example:
(lldb) type synthetic add -l my_child_provider -x "^MyType\[[0-9]+]$"
(lldb) type filter add --child a -x "MyType[12]"
error: cannot add filter for type MyType[12] when synthetic is defined in same category!
In this case, "^MyType\[[0-9]+]$" would accept types that look like an array of MyType, and "MyType[12]"looks like an array, but it would actually match MyType1 and MyType2 so there's no conflict.
I think the right thing to do is to just skip this check when adding a regex-based filter. I'll prepare a patch.
The text was updated successfully, but these errors were encountered:
When adding a new synthetic child provider, we check for an existing
conflicting filter in the same category (and vice versa). This is done
by trying to match the new type name against registered formatters.
However, the new type name we're registered can also be a regex
(`type synth add -x`), and in this case the conflict check is just
wrong: it will try to match the new regex as if it was a type name,
against previously registered regexes.
See #57947 for a longer
explanation with concrete examples of incorrect behavior.
Differential Revision: https://reviews.llvm.org/D134570
CommandObjectTypeSynthAdd::AddSynth
has some code to check for conflicting filters in the same category (there's a symmetric check for conflicting synth providers when adding a new filter, but let's focus on only one case). The check looks like this:The important detail here is that
type_name
can actually be either a type name or a regex (if usingtype synthetic add -x
). However,category->AnyMatches
always treatstype_name
as a type name, and will try to match a regex string against other regex strings, which is not correct.For example, this is lldb working correctly and rejecting a conflicting formatter.
However, if we use regex it will happily accept conflicting formatters:
because the string "^whatever$" is not matched by the regex "^whatever$".
We can also make it fail the other way around, and make it incorrectly reject non-conflicting formatters. For example:
In this case,
"^MyType\[[0-9]+]$"
would accept types that look like an array ofMyType
, and"MyType[12]"
looks like an array, but it would actually matchMyType1
andMyType2
so there's no conflict.I think the right thing to do is to just skip this check when adding a regex-based filter. I'll prepare a patch.
The text was updated successfully, but these errors were encountered: