Reputation: 95
I'm currently developing data formatters for my own types. However, I encounter some problems to print references.
#include <iostream>
class Circle
{
protected:
double R;
double a;
double b;
public:
Circle():R(1), a(0), b(0)
{
}
};
int main()
{
Circle A;
Circle & B = A;
return 0;
}
And I use type summary add
to customize my own data formatters
(lldb) type summary add -s "The circle is (R = ${var.R}, a = ${var.a}, b = ${var.b})" Circle
Now it goes very well for non-references, for example
(lldb) frame variable A
(Circle) A = The circle is (R = 1, a = 0, b = 0)
However, for references,
(lldb) frame variable B
(Circle &const) B = 0x00007fffffffd200 The circle is (R = 1, a = 0, b = 0): {
R = 1
a = 0
b = 0
}
for which the contents after ":" is not wanted.
What should I do to deal with the references? I know it is possible to use --skip-references
to disable the output for references, but I do hope I can format references just as usual types.
Upvotes: 2
Views: 212
Reputation: 27110
That's a bug. There's an option to the summary formatters: --expand that's supposed to control whether we only show the summary, or show the summary and the children of the value being printed. If you add --expand when you add your summary, you'll see that the struct version now also prints the child elements. It looks like that setting is ignored for references.
Please file a bug with bugs.llvm.org
Upvotes: 3