This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] smart pointer support


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]