From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9696 invoked by alias); 22 Apr 2013 20:46:47 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 9678 invoked by uid 306); 22 Apr 2013 20:46:47 -0000 Date: Mon, 22 Apr 2013 20:46:00 -0000 Message-ID: <20130422204646.9651.qmail@sourceware.org> From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] tromey/operator-new-delete: add CONSTRUCTOR style for find_overload_match X-Git-Refname: refs/heads/tromey/operator-new-delete X-Git-Reftype: branch X-Git-Oldrev: aceae9a365ee619f3df2234fc8056ba75f32d1d5 X-Git-Newrev: 6d1a331afe1b5a76f04bdc845e331c4481e8bf69 X-SW-Source: 2013-q2/txt/msg00045.txt.bz2 List-Id: The branch, tromey/operator-new-delete has been updated via 6d1a331afe1b5a76f04bdc845e331c4481e8bf69 (commit) from aceae9a365ee619f3df2234fc8056ba75f32d1d5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 6d1a331afe1b5a76f04bdc845e331c4481e8bf69 Author: Tom Tromey Date: Mon Apr 22 14:31:16 2013 -0600 add CONSTRUCTOR style for find_overload_match add a CONSTRUCTOR style for find_overload_match this disables recursion in search_struct_field, which is a problem for finding a constructor -- first it isn't needed, and second it tries to examine the object in memory, but the object hasn't been fully initialized yet ----------------------------------------------------------------------- Summary of changes: gdb/valarith.c | 2 +- gdb/valops.c | 42 +++++++++++++++++++++++++++++++++++------- gdb/value.h | 2 +- 3 files changed, 37 insertions(+), 9 deletions(-) First 500 lines of diff: diff --git a/gdb/valarith.c b/gdb/valarith.c index 8cd4de4..40080a2 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -747,7 +747,7 @@ value_construct (struct type *type, int argc, struct value **argv) { struct value *obj = value_ind (argv[0]); - find_overload_match (argv, argc, constr_name, METHOD, + find_overload_match (argv, argc, constr_name, CONSTRUCTOR, &obj, NULL, &function, &sym, NULL, 1); } diff --git a/gdb/valops.c b/gdb/valops.c index 93c09d8..42ea8f2 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1998,7 +1998,8 @@ do_search_struct_field (const char *name, struct value *arg1, int offset, struct type *type, int looking_for_baseclass, struct value **result_ptr, int *last_boffset, - struct type *outermost_type) + struct type *outermost_type, + int can_recurse) { int i; int nbases; @@ -2069,7 +2070,7 @@ do_search_struct_field (const char *name, struct value *arg1, int offset, field_type, looking_for_baseclass, &v, last_boffset, - outermost_type); + outermost_type, can_recurse); if (v) { *result_ptr = v; @@ -2079,6 +2080,9 @@ do_search_struct_field (const char *name, struct value *arg1, int offset, } } + if (!can_recurse) + return; + for (i = 0; i < nbases; i++) { struct value *v = NULL; @@ -2137,7 +2141,7 @@ do_search_struct_field (const char *name, struct value *arg1, int offset, TYPE_BASECLASS (type, i), looking_for_baseclass, result_ptr, last_boffset, - outermost_type); + outermost_type, can_recurse); } } else if (found_baseclass) @@ -2149,7 +2153,7 @@ do_search_struct_field (const char *name, struct value *arg1, int offset, i) / 8, basetype, looking_for_baseclass, result_ptr, last_boffset, - outermost_type); + outermost_type, can_recurse); } update_search_result (result_ptr, v, last_boffset, @@ -2173,7 +2177,23 @@ search_struct_field (const char *name, struct value *arg1, int offset, int boffset = 0; do_search_struct_field (name, arg1, offset, type, looking_for_baseclass, - &result, &boffset, type); + &result, &boffset, type, 1); + return result; +} + +/* Like search_struct_field, but has an additional parameter to + control whether or not superclasses are searched. */ + +static struct value * +search_struct_field_full (const char *name, struct value *arg1, int offset, + struct type *type, int looking_for_baseclass, + int can_search_superclass) +{ + struct value *result = NULL; + int boffset = 0; + + do_search_struct_field (name, arg1, offset, type, looking_for_baseclass, + &result, &boffset, type, can_search_superclass); return result; } @@ -2581,6 +2601,7 @@ find_overload_match (struct value **args, int nargs, /* Index of best overloaded function. */ int func_oload_champ = -1; int method_oload_champ = -1; + int is_constructor; /* The measure for the current best match. */ struct badness_vector *method_badness = NULL; @@ -2604,6 +2625,12 @@ find_overload_match (struct value **args, int nargs, enum oload_classification method_match_quality = INCOMPATIBLE; enum oload_classification func_match_quality = INCOMPATIBLE; + if (method == CONSTRUCTOR) + { + method = METHOD; + is_constructor = 1; + } + /* Get the list of overloaded methods or functions. */ if (method == METHOD || method == BOTH) { @@ -2619,8 +2646,9 @@ find_overload_match (struct value **args, int nargs, a function. */ if (TYPE_CODE (check_typedef (value_type (obj))) == TYPE_CODE_STRUCT) { - *valp = search_struct_field (name, obj, 0, - check_typedef (value_type (obj)), 0); + *valp = search_struct_field_full (name, obj, 0, + check_typedef (value_type (obj)), + 0, !is_constructor); if (*valp) { *staticp = 1; diff --git a/gdb/value.h b/gdb/value.h index eeba84c..93c73df 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -645,7 +645,7 @@ extern struct value *value_aggregate_elt (struct type *curtype, extern struct value *value_static_field (struct type *type, int fieldno); -enum oload_search_type { NON_METHOD, METHOD, BOTH }; +enum oload_search_type { NON_METHOD, METHOD, CONSTRUCTOR, BOTH }; extern int find_overload_match (struct value **args, int nargs, const char *name, hooks/post-receive -- Repository for Project Archer.