aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorArtemiy Volkov <artemiyv@acm.org>2017-03-20 13:47:54 -0700
committerKeith Seitz <keiths@redhat.com>2017-03-20 13:47:54 -0700
commitaa0061181ab00081e9907447561e589d6edee9f2 (patch)
treeed4d550dc5a47158d2582c25dd51fd6658f61fcc /gdb/eval.c
parent3fcf899da106890f3948093c2424f9dff67d6fe0 (diff)
downloadgdb-aa0061181ab00081e9907447561e589d6edee9f2.zip
gdb-aa0061181ab00081e9907447561e589d6edee9f2.tar.gz
gdb-aa0061181ab00081e9907447561e589d6edee9f2.tar.bz2
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression semantics), lvalue and rvalue references are equivalent. That means that in all but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE check and, for switch statements, add a case label for a rvalue reference type next to a case label for an lvalue reference type. This patch does exactly that. gdb/ChangeLog PR gdb/14441 * aarch64-tdep.c (aarch64_type_align) (aarch64_extract_return_value, aarch64_store_return_value): Change lvalue reference type checks to general reference type checks. * amd64-tdep.c (amd64_classify): Likewise. * amd64-windows-tdep.c (amd64_windows_passed_by_integer_register): Likewise. * arm-tdep.c (arm_type_align, arm_extract_return_value) (arm_store_return_value): Likewise. * ax-gdb.c (gen_fetch, gen_cast): Likewise. * c-typeprint.c (c_print_type): Likewise. * c-varobj.c (adjust_value_for_child_access, c_value_of_variable) (cplus_number_of_children, cplus_describe_child): Likewise. * compile/compile-c-symbols.c (generate_vla_size): Likewise. * completer.c (expression_completer): Likewise. * cp-support.c (make_symbol_overload_list_adl_namespace): Likewise. * darwin-nat-info.c (info_mach_region_command): Likewise. * dwarf2loc.c (entry_data_value_coerce_ref) (value_of_dwarf_reg_entry): Likewise. * eval.c (ptrmath_type_p, evaluate_subexp_standard) (evaluate_subexp_for_address, evaluate_subexp_for_sizeof): Likewise. * findvar.c (extract_typed_address, store_typed_address): Likewise. * gdbtypes.c (rank_one_type): Likewise. * hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise. * infcall.c (value_arg_coerce): Likewise. * language.c (pointer_type): Likewise. * m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer): Likewise. * m88k-tdep.c (m88k_integral_or_pointer_p): Likewise. * mn10300-tdep.c (mn10300_type_align): Likewise. * msp430-tdep.c (msp430_push_dummy_call): Likewise. * ppc-sysv-tdep.c (do_ppc_sysv_return_value) (ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value): Likewise. * printcmd.c (print_formatted, x_command): Likewise. * python/py-type.c (typy_get_composite, typy_template_argument): Likewise. * python/py-value.c (valpy_referenced_value) (valpy_get_dynamic_type, value_has_field): Likewise. * s390-linux-tdep.c (s390_function_arg_integer): Likewise. * sparc-tdep.c (sparc_integral_or_pointer_p): Likewise. * sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise. * spu-tdep.c (spu_scalar_value_p): Likewise. * symtab.c (lookup_symbol_aux): Likewise. * typeprint.c (whatis_exp, print_type_scalar): Likewise. * valarith.c (binop_types_user_defined_p, unop_user_defined_p): Likewise. * valops.c (value_cast_pointers, value_cast) (value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp) (value_struct_elt, value_struct_elt_bitpos) (value_find_oload_method_list, find_overload_match) (value_rtti_indirect_type): Likewise. * valprint.c (val_print_scalar_type_p, generic_val_print): Likewise. * value.c (value_actual_type, value_as_address, unpack_long) (pack_long, pack_unsigned_long, coerce_ref_if_computed) (coerce_ref): Likewise. * varobj.c (varobj_get_value_type): Likewise.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 61d8d19..2a39774 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -620,7 +620,7 @@ static int
ptrmath_type_p (const struct language_defn *lang, struct type *type)
{
type = check_typedef (type);
- if (TYPE_CODE (type) == TYPE_CODE_REF)
+ if (TYPE_IS_REFERENCE (type))
type = TYPE_TARGET_TYPE (type);
switch (TYPE_CODE (type))
@@ -2491,7 +2491,7 @@ evaluate_subexp_standard (struct type *expect_type,
{
type = check_typedef (value_type (arg1));
if (TYPE_CODE (type) == TYPE_CODE_PTR
- || TYPE_CODE (type) == TYPE_CODE_REF
+ || TYPE_IS_REFERENCE (type)
/* In C you can dereference an array to get the 1st elt. */
|| TYPE_CODE (type) == TYPE_CODE_ARRAY
)
@@ -2769,7 +2769,7 @@ evaluate_subexp_standard (struct type *expect_type,
{
struct type *type = value_type (result);
- if (TYPE_CODE (check_typedef (type)) != TYPE_CODE_REF)
+ if (!TYPE_IS_REFERENCE (type))
{
type = lookup_lvalue_reference_type (type);
result = allocate_value (type);
@@ -2872,7 +2872,7 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
/* C++: The "address" of a reference should yield the address
* of the object pointed to. Let value_addr() deal with it. */
- if (TYPE_CODE (SYMBOL_TYPE (var)) == TYPE_CODE_REF)
+ if (TYPE_IS_REFERENCE (SYMBOL_TYPE (var)))
goto default_case;
(*pos) += 4;
@@ -2911,7 +2911,7 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
{
struct type *type = check_typedef (value_type (x));
- if (TYPE_CODE (type) == TYPE_CODE_REF)
+ if (TYPE_IS_REFERENCE (type))
return value_zero (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
not_lval);
else if (VALUE_LVAL (x) == lval_memory || value_must_coerce_to_target (x))
@@ -3001,7 +3001,7 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos,
val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
type = check_typedef (value_type (val));
if (TYPE_CODE (type) != TYPE_CODE_PTR
- && TYPE_CODE (type) != TYPE_CODE_REF
+ && !TYPE_IS_REFERENCE (type)
&& TYPE_CODE (type) != TYPE_CODE_ARRAY)
error (_("Attempt to take contents of a non-pointer value."));
type = TYPE_TARGET_TYPE (type);
@@ -3073,7 +3073,7 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos,
the size of the referenced type." */
type = check_typedef (type);
if (exp->language_defn->la_language == language_cplus
- && TYPE_CODE (type) == TYPE_CODE_REF)
+ && (TYPE_IS_REFERENCE (type)))
type = check_typedef (TYPE_TARGET_TYPE (type));
return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
}