aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbtypes.c
diff options
context:
space:
mode:
authorArtemiy Volkov <artemiyv@acm.org>2017-03-20 13:47:39 -0700
committerKeith Seitz <keiths@redhat.com>2017-03-20 13:47:39 -0700
commit3b22433085e4cfee83f5c52f3baa8fb9bc67f8dd (patch)
tree13cf13318a14f0d8981705445f9f21cf40c0324a /gdb/gdbtypes.c
parentf9aeb8d499fa12610610dc19618230304c698f6c (diff)
downloadfsf-binutils-gdb-3b22433085e4cfee83f5c52f3baa8fb9bc67f8dd.zip
fsf-binutils-gdb-3b22433085e4cfee83f5c52f3baa8fb9bc67f8dd.tar.gz
fsf-binutils-gdb-3b22433085e4cfee83f5c52f3baa8fb9bc67f8dd.tar.bz2
Change {lookup,make}_reference_type API
Parameterize lookup_reference_type() and make_reference_type() by the kind of reference type we want to look up. Create two wrapper functions lookup_{lvalue,rvalue}_reference_type() for lookup_reference_type() to simplify the API. Change all callers to use the new API. gdb/Changelog PR gdb/14441 * dwarf2read.c (read_tag_reference_type): Use lookup_lvalue_reference_type() instead of lookup_reference_type(). * eval.c (evaluate_subexp_standard): Likewise. * f-exp.y: Likewise. * gdbtypes.c (make_reference_type, lookup_reference_type): Generalize with rvalue reference types. (lookup_lvalue_reference_type, lookup_rvalue_reference_type): New convenience wrappers for lookup_reference_type(). * gdbtypes.h (make_reference_type, lookup_reference_type): Add a reference kind parameter. (lookup_lvalue_reference_type, lookup_rvalue_reference_type): Add wrappers for lookup_reference_type(). * guile/scm-type.c (gdbscm_type_reference): Use lookup_lvalue_reference_type() instead of lookup_reference_type(). * guile/scm-value.c (gdbscm_value_dynamic_type): Likewise. * parse.c (follow_types): Likewise. * python/py-type.c (typy_reference, typy_lookup_type): Likewise. * python/py-value.c (valpy_get_dynamic_type, valpy_getitem): Likewise. * python/py-xmethods.c (gdbpy_get_xmethod_result_type) (gdbpy_invoke_xmethod): Likewise. * stabsread.c: Provide extra argument to make_reference_type() call. * valops.c (value_ref, value_rtti_indirect_type): Use lookup_lvalue_reference_type() instead of lookup_reference_type().
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r--gdb/gdbtypes.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 5e5db27..60cef68 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -384,15 +384,21 @@ lookup_pointer_type (struct type *type)
/* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero,
points to a pointer to memory where the reference type should be
stored. If *TYPEPTR is zero, update it to point to the reference
- type we return. We allocate new memory if needed. */
+ type we return. We allocate new memory if needed. REFCODE denotes
+ the kind of reference type to lookup (lvalue or rvalue reference). */
struct type *
-make_reference_type (struct type *type, struct type **typeptr)
+make_reference_type (struct type *type, struct type **typeptr,
+ enum type_code refcode)
{
struct type *ntype; /* New type */
+ struct type **reftype;
struct type *chain;
- ntype = TYPE_REFERENCE_TYPE (type);
+ gdb_assert (refcode == TYPE_CODE_REF || refcode == TYPE_CODE_RVALUE_REF);
+
+ ntype = (refcode == TYPE_CODE_REF ? TYPE_REFERENCE_TYPE (type)
+ : TYPE_RVALUE_REFERENCE_TYPE (type));
if (ntype)
{
@@ -421,7 +427,10 @@ make_reference_type (struct type *type, struct type **typeptr)
}
TYPE_TARGET_TYPE (ntype) = type;
- TYPE_REFERENCE_TYPE (type) = ntype;
+ reftype = (refcode == TYPE_CODE_REF ? &TYPE_REFERENCE_TYPE (type)
+ : &TYPE_RVALUE_REFERENCE_TYPE (type));
+
+ *reftype = ntype;
/* FIXME! Assume the machine has only one representation for
references, and that it matches the (only) representation for
@@ -429,10 +438,9 @@ make_reference_type (struct type *type, struct type **typeptr)
TYPE_LENGTH (ntype) =
gdbarch_ptr_bit (get_type_arch (type)) / TARGET_CHAR_BIT;
- TYPE_CODE (ntype) = TYPE_CODE_REF;
+ TYPE_CODE (ntype) = refcode;
- if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */
- TYPE_REFERENCE_TYPE (type) = ntype;
+ *reftype = ntype;
/* Update the length of all the other variants of this type. */
chain = TYPE_CHAIN (ntype);
@@ -449,9 +457,25 @@ make_reference_type (struct type *type, struct type **typeptr)
details. */
struct type *
-lookup_reference_type (struct type *type)
+lookup_reference_type (struct type *type, enum type_code refcode)
+{
+ return make_reference_type (type, (struct type **) 0, refcode);
+}
+
+/* Lookup the lvalue reference type for the type TYPE. */
+
+struct type *
+lookup_lvalue_reference_type (struct type *type)
+{
+ return lookup_reference_type (type, TYPE_CODE_REF);
+}
+
+/* Lookup the rvalue reference type for the type TYPE. */
+
+struct type *
+lookup_rvalue_reference_type (struct type *type)
{
- return make_reference_type (type, (struct type **) 0);
+ return lookup_reference_type (type, TYPE_CODE_RVALUE_REF);
}
/* Lookup a function type that returns type TYPE. TYPEPTR, if