public inbox for archer-commits@sourceware.org help / color / mirror / Atom feed
From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] tromey/operator-new-delete: add CONSTRUCTOR style for find_overload_match Date: Mon, 22 Apr 2013 20:46:00 -0000 [thread overview] Message-ID: <20130422204646.9651.qmail@sourceware.org> (raw) 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 <tromey@redhat.com> 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.
next reply other threads:[~2013-04-22 20:46 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-04-22 20:46 tromey [this message] 2013-05-17 19:12 tromey
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20130422204646.9651.qmail@sourceware.org \ --to=tromey@sourceware.org \ --cc=archer-commits@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).