This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] smart pointer support
- From: Tom Tromey <tromey at redhat dot com>
- To: sami wagiaalla <swagiaal at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 23 Jul 2010 17:37:25 -0600
- Subject: Re: [patch] smart pointer support
- References: <4C45C78A.9080904@redhat.com>
>>>>> "Sami" == sami wagiaalla <swagiaal@redhat.com> writes:
Sami> The '->' operator can be overloaded in C++ and when overloaded it
Sami> forwards the function call or member reference to the return
Sami> type.
Thanks for working on this.
Sami> + /* For C++ check to see if the operator '->' has been overloaded.
Sami> + If the operator has been overloaded replace arg2 with the value
Sami> + returned by the custom operator and continue evaluation. */
Sami> + if (exp->language_defn->la_language == language_cplus)
Sami> + {
Sami> + struct type *arg_type = value_type (arg2);
Sami> + if (arg_type && TYPE_CODE (arg_type) == TYPE_CODE_STRUCT)
I think if you are going to use value_x_unop, you ought to use
unop_user_defined_p as well. Maybe that means changes to
unop_user_defined_p.
Also, I think you will need a while loop here. operator-> might itself
return an object that has an operator->. There should be a test case
for this as well.
I was wondering if the STRUCTOP_PTR / STRUCTOP_STRUCT conflation in the
method case could cause problems. Maybe a new test would be good, just
to make that clear. The "." case should not cause the operator to be
used -- or at least, "." on a struct, gdb supports "." on a pointer as
an extension, I'm not sure what we should do there.
Otherwise, looking good.
Tom