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]

[RFC] Extend existing support for evaluating expressions using overloaded operators


Hello,

The attached patch extends the existing support for evaluating
expressions using overloaded operators defined in C++ source. For
example, currently we do not support evaluation of a binary operation
if the first operand is a non-struct and the second operand is a
struct. To illustrate, if in C++ source we have

<code>
class Integer
{
...
};

int
operator+ (const int a, const Interger &b)
{
...
}

int an_int;
Integer an_integer;
</code>

then, at GDB prompt, we cannot do this

(gdb) p an_int + an_integer

The attached patch adds this support.

2012-06-01  Siva Chandra Reddy  <sivachandra@google.com>

        Extend existing support for evaluating expressions using
        overloaded operators.
        * gdtypes.c (is_scalar_type): Make the function non-static.
        (is_compound_type): New function to test if a type is a compound
        type.
        * gdbtypes.h (is_scalar_type, is_compound_type): Add
        declarations for these functions.
        * valarith.c (value_binop): Extend to handle overloaded
        binary operations on compound types.
        (value_x_binop): Extend to handle binary operations which have
        atleast one compound value operand.
        * valops.c (find_overload_match): Lookup overloaded operator
        function when lookup for overloaded operator method throws an
        exception.

        testsuite/
        * gdb.cp/operator.cc: Add test cases to test overloaded
        binary operator evaluation.
        * gdb.python/py-value.cc: Likewise
        * gdb.cp/operator.exp: Add tests to test overloaded binary
        operator evaluation.
        * gdb.python/py-value-cc.exp: Likewise
        * gdb.python/py-value.exp: Fix a test case to align it with the
        new error message.

Thanks,
Siva Chandra

Attachment: oprovld_patch_v1.txt
Description: Text document


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