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:03 -0700
commitacee94686be0601a096c5d6e09c531c41318a429 (patch)
treec6947f4ce14aee132cca3c68442e13228f3cad44
parent786f70ee4d370b3c308ef574bdeda06c6393db06 (diff)
downloadgdb-acee94686be0601a096c5d6e09c531c41318a429.zip
gdb-acee94686be0601a096c5d6e09c531c41318a429.tar.gz
gdb-acee94686be0601a096c5d6e09c531c41318a429.tar.bz2
Split out eval_op_alignof
This splits UNOP_ALIGNOF into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_alignof): New function. (evaluate_subexp_standard): Use it.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c28
2 files changed, 23 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 794b883..1bfac7e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * eval.c (eval_op_alignof): New function.
+ (evaluate_subexp_standard): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* eval.c (eval_op_ind): New function.
(evaluate_subexp_standard): Use it.
diff --git a/gdb/eval.c b/gdb/eval.c
index e1e0e05..729933f 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1878,6 +1878,22 @@ eval_op_ind (struct type *expect_type, struct expression *exp,
return value_ind (arg1);
}
+/* A helper function for UNOP_ALIGNOF. */
+
+static struct value *
+eval_op_alignof (struct type *expect_type, struct expression *exp,
+ enum noside noside,
+ struct value *arg1)
+{
+ struct type *type = value_type (arg1);
+ /* FIXME: This should be size_t. */
+ struct type *size_type = builtin_type (exp->gdbarch)->builtin_int;
+ ULONGEST align = type_align (type);
+ if (align == 0)
+ error (_("could not determine alignment of type"));
+ return value_from_longest (size_type, align);
+}
+
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -2769,16 +2785,8 @@ evaluate_subexp_standard (struct type *expect_type,
return evaluate_subexp_for_sizeof (exp, pos, noside);
case UNOP_ALIGNOF:
- {
- type = value_type (
- evaluate_subexp (nullptr, exp, pos, EVAL_AVOID_SIDE_EFFECTS));
- /* FIXME: This should be size_t. */
- struct type *size_type = builtin_type (exp->gdbarch)->builtin_int;
- ULONGEST align = type_align (type);
- if (align == 0)
- error (_("could not determine alignment of type"));
- return value_from_longest (size_type, align);
- }
+ arg1 = evaluate_subexp (nullptr, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+ return eval_op_alignof (expect_type, exp, noside, arg1);
case UNOP_CAST:
(*pos) += 2;