This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc][12/37] Eliminate builtin_type_ macros: Remove redundant coerce_enum/coerce_number
- From: uweigand at de dot ibm dot com
- To: gdb-patches at sourceware dot org
- Date: Sun, 31 Aug 2008 19:50:57 +0200
- Subject: [rfc][12/37] Eliminate builtin_type_ macros: Remove redundant coerce_enum/coerce_number
- References: <20080831175045.128504000@de.ibm.com>
Hello,
this patch removes the coerce_enum and coerce_number routines.
coerce_number is used solely in value_logical_not; but the rest
of this routine already handles enum types correctly, so the
call to coerce_enum implicit in coerce_number is not required.
Similarly, the sole two remaining call sites of coerce_enum,
value_x_binop and value_x_unop pass their arguments to
call_function_by_hand, which likewise handles enums correctly.
Bye,
Ulrich
ChangeLog:
* value.h (coerce_enum, coerce_number): Remove prototypes.
* value.c (coerce_enum, coerce_number): Remove.
* valarith.c (value_x_binop): Do not call coerce_enum.
(value_x_unop): Likewise.
(value_logical_not): Call coerce_array instead of coerce_number.
Index: gdb-head/gdb/valarith.c
===================================================================
--- gdb-head.orig/gdb/valarith.c
+++ gdb-head/gdb/valarith.c
@@ -354,8 +354,6 @@ value_x_binop (struct value *arg1, struc
arg1 = coerce_ref (arg1);
arg2 = coerce_ref (arg2);
- arg1 = coerce_enum (arg1);
- arg2 = coerce_enum (arg2);
/* now we know that what we have to do is construct our
arg vector and find the right function to call it with. */
@@ -515,7 +513,6 @@ value_x_unop (struct value *arg1, enum e
int static_memfuncp, nargs;
arg1 = coerce_ref (arg1);
- arg1 = coerce_enum (arg1);
/* now we know that what we have to do is construct our
arg vector and find the right function to call it with. */
@@ -1282,7 +1279,7 @@ value_logical_not (struct value *arg1)
const gdb_byte *p;
struct type *type1;
- arg1 = coerce_number (arg1);
+ arg1 = coerce_array (arg1);
type1 = check_typedef (value_type (arg1));
if (TYPE_CODE (type1) == TYPE_CODE_FLT)
Index: gdb-head/gdb/value.c
===================================================================
--- gdb-head.orig/gdb/value.c
+++ gdb-head/gdb/value.c
@@ -1700,22 +1700,6 @@ coerce_array (struct value *arg)
arg = value_coerce_function (arg);
return arg;
}
-
-struct value *
-coerce_number (struct value *arg)
-{
- arg = coerce_array (arg);
- arg = coerce_enum (arg);
- return arg;
-}
-
-struct value *
-coerce_enum (struct value *arg)
-{
- if (TYPE_CODE (check_typedef (value_type (arg))) == TYPE_CODE_ENUM)
- arg = value_cast (builtin_type_unsigned_int, arg);
- return arg;
-}
/* Return true if the function returning the specified type is using
Index: gdb-head/gdb/value.h
===================================================================
--- gdb-head.orig/gdb/value.h
+++ gdb-head/gdb/value.h
@@ -230,17 +230,11 @@ extern short *deprecated_value_regnum_ha
extern struct value *coerce_ref (struct value *value);
/* If ARG is an array, convert it to a pointer.
- If ARG is an enum, convert it to an integer.
If ARG is a function, convert it to a function pointer.
References are dereferenced. */
extern struct value *coerce_array (struct value *value);
-extern struct value *coerce_number (struct value *value);
-
-/* If ARG is an enum, convert it to an integer. */
-
-extern struct value *coerce_enum (struct value *value);
/* Internal variables (variables for convenience of use of debugger)
are recorded as a chain of these structures. */
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com