aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:41 -0700
commitf2a98603a807101722f12b8d7a1aca9651deb133 (patch)
tree0355abc24a75d4fc1920415690cebe7e48cc2712
parentd3c54a1ce8b250acf83dda2653393f29b70d3390 (diff)
downloadbinutils-f2a98603a807101722f12b8d7a1aca9651deb133.zip
binutils-f2a98603a807101722f12b8d7a1aca9651deb133.tar.gz
binutils-f2a98603a807101722f12b8d7a1aca9651deb133.tar.bz2
Remove now-unused C evaluator code
Now that the C parser has switched to the new style, there is no need for the old C evaluation code. This affects some other languages that were relying on the C code. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * go-lang.c (go_language::expression_ops): Don't declare. * go-lang.h (class go_language) <expression_ops>: Remove. * opencl-lang.c (evaluate_subexp_opencl, exp_descriptor_opencl): Remove. (class opencl_language) <expression_ops>: Remove. * d-lang.c (class d_language) <expression_ops>: Remove. * c-lang.h (evaluate_subexp_c, exp_descriptor_c): Don't declare. * c-lang.c (evaluate_subexp_c, exp_descriptor_c): Remove. (class c_language, class cplus_language, class asm_language) (class minimal_language) <expression_ops>: Remove.
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/c-lang.c180
-rw-r--r--gdb/c-lang.h7
-rw-r--r--gdb/d-lang.c5
-rw-r--r--gdb/go-lang.c8
-rw-r--r--gdb/go-lang.h4
-rw-r--r--gdb/opencl-lang.c280
7 files changed, 14 insertions, 483 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0853471..630679a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * go-lang.c (go_language::expression_ops): Don't declare.
+ * go-lang.h (class go_language) <expression_ops>: Remove.
+ * opencl-lang.c (evaluate_subexp_opencl, exp_descriptor_opencl):
+ Remove.
+ (class opencl_language) <expression_ops>: Remove.
+ * d-lang.c (class d_language) <expression_ops>: Remove.
+ * c-lang.h (evaluate_subexp_c, exp_descriptor_c): Don't declare.
+ * c-lang.c (evaluate_subexp_c, exp_descriptor_c): Remove.
+ (class c_language, class cplus_language, class asm_language)
+ (class minimal_language) <expression_ops>: Remove.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* ada-lang.c (resolve_subexp, replace_operator_with_call)
(evaluate_subexp_type, assign_aggregate)
(aggregate_assign_positional, aggregate_assign_from_choices)
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index d191d07..00ab941 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -579,157 +579,6 @@ parse_one_string (struct obstack *output, const char *data, int len,
}
}
-/* Expression evaluator for the C language family. Most operations
- are delegated to evaluate_subexp_standard; see that function for a
- description of the arguments. */
-
-struct value *
-evaluate_subexp_c (struct type *expect_type, struct expression *exp,
- int *pos, enum noside noside)
-{
- enum exp_opcode op = exp->elts[*pos].opcode;
-
- switch (op)
- {
- case OP_STRING:
- {
- int oplen, limit;
- struct type *type;
- struct value *result;
- c_string_type dest_type;
- const char *dest_charset;
- int satisfy_expected = 0;
-
- auto_obstack output;
-
- ++*pos;
- oplen = longest_to_int (exp->elts[*pos].longconst);
-
- ++*pos;
- limit = *pos + BYTES_TO_EXP_ELEM (oplen + 1);
- dest_type = ((enum c_string_type_values)
- longest_to_int (exp->elts[*pos].longconst));
- switch (dest_type & ~C_CHAR)
- {
- case C_STRING:
- type = language_string_char_type (exp->language_defn,
- exp->gdbarch);
- break;
- case C_WIDE_STRING:
- type = lookup_typename (exp->language_defn, "wchar_t", NULL, 0);
- break;
- case C_STRING_16:
- type = lookup_typename (exp->language_defn, "char16_t", NULL, 0);
- break;
- case C_STRING_32:
- type = lookup_typename (exp->language_defn, "char32_t", NULL, 0);
- break;
- default:
- internal_error (__FILE__, __LINE__, _("unhandled c_string_type"));
- }
-
- /* Ensure TYPE_LENGTH is valid for TYPE. */
- check_typedef (type);
-
- /* If the caller expects an array of some integral type,
- satisfy them. If something odder is expected, rely on the
- caller to cast. */
- if (expect_type && expect_type->code () == TYPE_CODE_ARRAY)
- {
- struct type *element_type
- = check_typedef (TYPE_TARGET_TYPE (expect_type));
-
- if (element_type->code () == TYPE_CODE_INT
- || element_type->code () == TYPE_CODE_CHAR)
- {
- type = element_type;
- satisfy_expected = 1;
- }
- }
-
- dest_charset = charset_for_string_type (dest_type, exp->gdbarch);
-
- ++*pos;
- while (*pos < limit)
- {
- int len;
-
- len = longest_to_int (exp->elts[*pos].longconst);
-
- ++*pos;
- if (noside != EVAL_SKIP)
- parse_one_string (&output, &exp->elts[*pos].string, len,
- dest_charset, type);
- *pos += BYTES_TO_EXP_ELEM (len);
- }
-
- /* Skip the trailing length and opcode. */
- *pos += 2;
-
- if (noside == EVAL_SKIP)
- {
- /* Return a dummy value of the appropriate type. */
- if (expect_type != NULL)
- result = allocate_value (expect_type);
- else if ((dest_type & C_CHAR) != 0)
- result = allocate_value (type);
- else
- result = value_cstring ("", 0, type);
- return result;
- }
-
- if ((dest_type & C_CHAR) != 0)
- {
- LONGEST value;
-
- if (obstack_object_size (&output) != TYPE_LENGTH (type))
- error (_("Could not convert character "
- "constant to target character set"));
- value = unpack_long (type, (gdb_byte *) obstack_base (&output));
- result = value_from_longest (type, value);
- }
- else
- {
- int i;
-
- /* Write the terminating character. */
- for (i = 0; i < TYPE_LENGTH (type); ++i)
- obstack_1grow (&output, 0);
-
- if (satisfy_expected)
- {
- LONGEST low_bound, high_bound;
- int element_size = TYPE_LENGTH (type);
-
- if (!get_discrete_bounds (expect_type->index_type (),
- &low_bound, &high_bound))
- {
- low_bound = 0;
- high_bound = (TYPE_LENGTH (expect_type) / element_size) - 1;
- }
- if (obstack_object_size (&output) / element_size
- > (high_bound - low_bound + 1))
- error (_("Too many array elements"));
-
- result = allocate_value (expect_type);
- memcpy (value_contents_raw (result), obstack_base (&output),
- obstack_object_size (&output));
- }
- else
- result = value_cstring ((const char *) obstack_base (&output),
- obstack_object_size (&output),
- type);
- }
- return result;
- }
- break;
-
- default:
- break;
- }
- return evaluate_subexp_standard (expect_type, exp, pos, noside);
-}
-
namespace expr
{
@@ -969,15 +818,6 @@ c_language_arch_info (struct gdbarch *gdbarch,
lai->set_bool_type (builtin->builtin_int);
}
-const struct exp_descriptor exp_descriptor_c =
-{
- print_subexp_standard,
- operator_length_standard,
- operator_check_standard,
- dump_subexp_body_standard,
- evaluate_subexp_c
-};
-
/* Class representing the C language. */
class c_language : public language_defn
@@ -1049,11 +889,6 @@ public:
/* See language.h. */
- const struct exp_descriptor *expression_ops () const override
- { return &exp_descriptor_c; }
-
- /* See language.h. */
-
const struct op_print *opcode_print_table () const override
{ return c_op_print_tab; }
};
@@ -1232,11 +1067,6 @@ public:
/* See language.h. */
- const struct exp_descriptor *expression_ops () const override
- { return &exp_descriptor_c; }
-
- /* See language.h. */
-
const struct op_print *opcode_print_table () const override
{ return c_op_print_tab; }
@@ -1313,11 +1143,6 @@ public:
/* See language.h. */
- const struct exp_descriptor *expression_ops () const override
- { return &exp_descriptor_c; }
-
- /* See language.h. */
-
const struct op_print *opcode_print_table () const override
{ return c_op_print_tab; }
};
@@ -1375,11 +1200,6 @@ public:
/* See language.h. */
- const struct exp_descriptor *expression_ops () const override
- { return &exp_descriptor_c; }
-
- /* See language.h. */
-
const struct op_print *opcode_print_table () const override
{ return c_op_print_tab; }
};
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index a488c04..543a626 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -90,10 +90,7 @@ extern void c_value_print (struct value *, struct ui_file *,
/* These are in c-lang.c: */
-extern struct value *evaluate_subexp_c (struct type *expect_type,
- struct expression *exp,
- int *pos,
- enum noside noside);
+extern void c_printchar (int, struct type *, struct ui_file *);
extern void c_printstr (struct ui_file * stream,
struct type *elttype,
@@ -106,8 +103,6 @@ extern void c_printstr (struct ui_file * stream,
extern void c_language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai);
-extern const struct exp_descriptor exp_descriptor_c;
-
extern void c_emit_char (int c, struct type *type,
struct ui_file *stream, int quoter);
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 65ee740..4488c10 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -219,11 +219,6 @@ public:
/* See language.h. */
- const struct exp_descriptor *expression_ops () const override
- { return &exp_descriptor_c; }
-
- /* See language.h. */
-
const struct op_print *opcode_print_table () const override
{ return d_op_print_tab; }
};
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index eafd868..3af89b3 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -386,14 +386,6 @@ go_language::demangle_symbol (const char *mangled_name, int options) const
return result;
}
-/* See language.h. */
-
-const struct exp_descriptor *
-go_language::expression_ops () const
-{
- return &exp_descriptor_c;
-}
-
/* Given a Go symbol, return its package or NULL if unknown.
Space for the result is malloc'd, caller must free. */
diff --git a/gdb/go-lang.h b/gdb/go-lang.h
index 71f9180..5d45c14 100644
--- a/gdb/go-lang.h
+++ b/gdb/go-lang.h
@@ -137,10 +137,6 @@ public:
/* See language.h. */
- const struct exp_descriptor *expression_ops () const override;
-
- /* See language.h. */
-
const struct op_print *opcode_print_table () const override
{ return op_print_tab; }
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index c515095..b283be1 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -692,272 +692,6 @@ eval_opencl_assign (struct type *expect_type, struct expression *exp,
return value_assign (arg1, arg2);
}
-/* Expression evaluator for the OpenCL. Most operations are delegated to
- evaluate_subexp_standard; see that function for a description of the
- arguments. */
-
-static struct value *
-evaluate_subexp_opencl (struct type *expect_type, struct expression *exp,
- int *pos, enum noside noside)
-{
- enum exp_opcode op = exp->elts[*pos].opcode;
- struct value *arg1 = NULL;
- struct value *arg2 = NULL;
- struct type *type1, *type2;
-
- switch (op)
- {
- /* Handle assignment and cast operators to support OpenCL-style
- scalar-to-vector widening. */
- case BINOP_ASSIGN:
- (*pos)++;
- arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- type1 = value_type (arg1);
- arg2 = evaluate_subexp (type1, exp, pos, noside);
-
- return eval_opencl_assign (expect_type, exp, noside, op, arg1, arg2);
-
- case UNOP_CAST:
- type1 = exp->elts[*pos + 1].type;
- (*pos) += 2;
- arg1 = evaluate_subexp (type1, exp, pos, noside);
-
- if (noside == EVAL_SKIP)
- return value_from_longest (builtin_type (exp->gdbarch)->
- builtin_int, 1);
-
- return opencl_value_cast (type1, arg1);
-
- case UNOP_CAST_TYPE:
- (*pos)++;
- arg1 = evaluate_subexp (NULL, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
- type1 = value_type (arg1);
- arg1 = evaluate_subexp (type1, exp, pos, noside);
-
- if (noside == EVAL_SKIP)
- return value_from_longest (builtin_type (exp->gdbarch)->
- builtin_int, 1);
-
- return opencl_value_cast (type1, arg1);
-
- /* Handle binary relational and equality operators that are either not
- or differently defined for GNU vectors. */
- case BINOP_EQUAL:
- case BINOP_NOTEQUAL:
- case BINOP_LESS:
- case BINOP_GTR:
- case BINOP_GEQ:
- case BINOP_LEQ:
- (*pos)++;
- arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
-
- if (noside == EVAL_SKIP)
- return value_from_longest (builtin_type (exp->gdbarch)->
- builtin_int, 1);
-
- return opencl_relop (expect_type, exp, noside, op, arg1, arg2);
-
- /* Handle the logical unary operator not(!). */
- case UNOP_LOGICAL_NOT:
- (*pos)++;
- arg1 = evaluate_subexp (nullptr, exp, pos, noside);
-
- if (noside == EVAL_SKIP)
- return value_from_longest (builtin_type (exp->gdbarch)->
- builtin_int, 1);
-
- return opencl_logical_not (expect_type, exp, noside, op, arg1);
-
- /* Handle the logical operator and(&&) and or(||). */
- case BINOP_LOGICAL_AND:
- case BINOP_LOGICAL_OR:
- (*pos)++;
- arg1 = evaluate_subexp (nullptr, exp, pos, noside);
-
- if (noside == EVAL_SKIP)
- {
- evaluate_subexp (nullptr, exp, pos, noside);
-
- return value_from_longest (builtin_type (exp->gdbarch)->
- builtin_int, 1);
- }
- else
- {
- /* For scalar operations we need to avoid evaluating operands
- unnecessarily. However, for vector operations we always need to
- evaluate both operands. Unfortunately we only know which of the
- two cases apply after we know the type of the second operand.
- Therefore we evaluate it once using EVAL_AVOID_SIDE_EFFECTS. */
- int oldpos = *pos;
-
- arg2 = evaluate_subexp (nullptr, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
- *pos = oldpos;
- type1 = check_typedef (value_type (arg1));
- type2 = check_typedef (value_type (arg2));
-
- if ((type1->code () == TYPE_CODE_ARRAY && type1->is_vector ())
- || (type2->code () == TYPE_CODE_ARRAY && type2->is_vector ()))
- {
- arg2 = evaluate_subexp (nullptr, exp, pos, noside);
-
- return opencl_relop (nullptr, exp, noside, op, arg1, arg2);
- }
- else
- {
- /* For scalar built-in types, only evaluate the right
- hand operand if the left hand operand compares
- unequal(&&)/equal(||) to 0. */
- int res;
- int tmp = value_logical_not (arg1);
-
- if (op == BINOP_LOGICAL_OR)
- tmp = !tmp;
-
- arg2
- = evaluate_subexp (nullptr, exp, pos, tmp ? EVAL_SKIP : noside);
- type1 = language_bool_type (exp->language_defn, exp->gdbarch);
-
- if (op == BINOP_LOGICAL_AND)
- res = !tmp && !value_logical_not (arg2);
- else /* BINOP_LOGICAL_OR */
- res = tmp || !value_logical_not (arg2);
-
- return value_from_longest (type1, res);
- }
- }
-
- /* Handle the ternary selection operator. */
- case TERNOP_COND:
- (*pos)++;
- arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- type1 = check_typedef (value_type (arg1));
- if (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ())
- {
- struct value *arg3, *tmp, *ret;
- struct type *eltype2, *type3, *eltype3;
- int t2_is_vec, t3_is_vec, i;
- LONGEST lowb1, lowb2, lowb3, highb1, highb2, highb3;
-
- arg2 = evaluate_subexp (nullptr, exp, pos, noside);
- arg3 = evaluate_subexp (nullptr, exp, pos, noside);
- type2 = check_typedef (value_type (arg2));
- type3 = check_typedef (value_type (arg3));
- t2_is_vec
- = type2->code () == TYPE_CODE_ARRAY && type2->is_vector ();
- t3_is_vec
- = type3->code () == TYPE_CODE_ARRAY && type3->is_vector ();
-
- /* Widen the scalar operand to a vector if necessary. */
- if (t2_is_vec || !t3_is_vec)
- {
- arg3 = opencl_value_cast (type2, arg3);
- type3 = value_type (arg3);
- }
- else if (!t2_is_vec || t3_is_vec)
- {
- arg2 = opencl_value_cast (type3, arg2);
- type2 = value_type (arg2);
- }
- else if (!t2_is_vec || !t3_is_vec)
- {
- /* Throw an error if arg2 or arg3 aren't vectors. */
- error (_("\
-Cannot perform conditional operation on incompatible types"));
- }
-
- eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
- eltype3 = check_typedef (TYPE_TARGET_TYPE (type3));
-
- if (!get_array_bounds (type1, &lowb1, &highb1)
- || !get_array_bounds (type2, &lowb2, &highb2)
- || !get_array_bounds (type3, &lowb3, &highb3))
- error (_("Could not determine the vector bounds"));
-
- /* Throw an error if the types of arg2 or arg3 are incompatible. */
- if (eltype2->code () != eltype3->code ()
- || TYPE_LENGTH (eltype2) != TYPE_LENGTH (eltype3)
- || eltype2->is_unsigned () != eltype3->is_unsigned ()
- || lowb2 != lowb3 || highb2 != highb3)
- error (_("\
-Cannot perform operation on vectors with different types"));
-
- /* Throw an error if the sizes of arg1 and arg2/arg3 differ. */
- if (lowb1 != lowb2 || lowb1 != lowb3
- || highb1 != highb2 || highb1 != highb3)
- error (_("\
-Cannot perform conditional operation on vectors with different sizes"));
-
- ret = allocate_value (type2);
-
- for (i = 0; i < highb1 - lowb1 + 1; i++)
- {
- tmp = value_logical_not (value_subscript (arg1, i)) ?
- value_subscript (arg3, i) : value_subscript (arg2, i);
- memcpy (value_contents_writeable (ret) +
- i * TYPE_LENGTH (eltype2), value_contents_all (tmp),
- TYPE_LENGTH (eltype2));
- }
-
- return ret;
- }
- else
- {
- if (value_logical_not (arg1))
- {
- /* Skip the second operand. */
- evaluate_subexp (nullptr, exp, pos, EVAL_SKIP);
-
- return evaluate_subexp (nullptr, exp, pos, noside);
- }
- else
- {
- /* Skip the third operand. */
- arg2 = evaluate_subexp (nullptr, exp, pos, noside);
- evaluate_subexp (nullptr, exp, pos, EVAL_SKIP);
-
- return arg2;
- }
- }
-
- /* Handle STRUCTOP_STRUCT to allow component access on OpenCL vectors. */
- case STRUCTOP_STRUCT:
- {
- int pc = (*pos)++;
- int tem = longest_to_int (exp->elts[pc + 1].longconst);
-
- (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
- arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- type1 = check_typedef (value_type (arg1));
-
- if (noside == EVAL_SKIP)
- {
- return value_from_longest (builtin_type (exp->gdbarch)->
- builtin_int, 1);
- }
- else if (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ())
- {
- return opencl_component_ref (exp, arg1, &exp->elts[pc + 2].string,
- noside);
- }
- else
- {
- struct value *v = value_struct_elt (&arg1, NULL,
- &exp->elts[pc + 2].string, NULL,
- "structure");
-
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- v = value_zero (value_type (v), VALUE_LVAL (v));
- return v;
- }
- }
- default:
- break;
- }
-
- return evaluate_subexp_c (expect_type, exp, pos, noside);
-}
-
namespace expr
{
@@ -1119,15 +853,6 @@ Cannot perform conditional operation on vectors with different sizes"));
} /* namespace expr */
-const struct exp_descriptor exp_descriptor_opencl =
-{
- print_subexp_standard,
- operator_length_standard,
- operator_check_standard,
- dump_subexp_body_standard,
- evaluate_subexp_opencl
-};
-
/* Class representing the OpenCL language. */
class opencl_language : public language_defn
@@ -1251,11 +976,6 @@ public:
/* See language.h. */
- const struct exp_descriptor *expression_ops () const override
- { return &exp_descriptor_opencl; }
-
- /* See language.h. */
-
const struct op_print *opcode_print_table () const override
{ return c_op_print_tab; }
};