Move value_true to value.h
I noticed that value_true is declared in language.h and defined in language.c. However, as part of the value API, I think it would be better in one of those files. And, because it is very short, I changed it to be an inline function in value.h. I've also removed a comment from the implementation, on the basis that it seems obsolete -- if the change it suggests was needed, it probably would have been done by now; and if it is needed in the future, odds are it would be done differently anyway. Finally, this patch also changes value_true and value_logical_not to return a bool, and updates some uses.
This commit is contained in:
parent
604386598d
commit
7ebaa5f782
8 changed files with 20 additions and 34 deletions
|
@ -11765,13 +11765,13 @@ re_set_exception (struct breakpoint *b)
|
||||||
user specified a specific exception, we only want to cause a stop
|
user specified a specific exception, we only want to cause a stop
|
||||||
if the program thrown that exception. */
|
if the program thrown that exception. */
|
||||||
|
|
||||||
static int
|
static bool
|
||||||
should_stop_exception (const struct bp_location *bl)
|
should_stop_exception (const struct bp_location *bl)
|
||||||
{
|
{
|
||||||
struct ada_catchpoint *c = (struct ada_catchpoint *) bl->owner;
|
struct ada_catchpoint *c = (struct ada_catchpoint *) bl->owner;
|
||||||
const struct ada_catchpoint_location *ada_loc
|
const struct ada_catchpoint_location *ada_loc
|
||||||
= (const struct ada_catchpoint_location *) bl;
|
= (const struct ada_catchpoint_location *) bl;
|
||||||
int stop;
|
bool stop;
|
||||||
|
|
||||||
struct internalvar *var = lookup_internalvar ("_ada_exception");
|
struct internalvar *var = lookup_internalvar ("_ada_exception");
|
||||||
if (c->m_kind == ada_catch_assert)
|
if (c->m_kind == ada_catch_assert)
|
||||||
|
@ -11799,16 +11799,16 @@ should_stop_exception (const struct bp_location *bl)
|
||||||
|
|
||||||
/* With no specific exception, should always stop. */
|
/* With no specific exception, should always stop. */
|
||||||
if (c->excep_string.empty ())
|
if (c->excep_string.empty ())
|
||||||
return 1;
|
return true;
|
||||||
|
|
||||||
if (ada_loc->excep_cond_expr == NULL)
|
if (ada_loc->excep_cond_expr == NULL)
|
||||||
{
|
{
|
||||||
/* We will have a NULL expression if back when we were creating
|
/* We will have a NULL expression if back when we were creating
|
||||||
the expressions, this location's had failed to parse. */
|
the expressions, this location's had failed to parse. */
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
stop = 1;
|
stop = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
struct value *mark;
|
struct value *mark;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
#include "language.h" /* For value_true */
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "ui-out.h"
|
#include "ui-out.h"
|
||||||
|
@ -579,7 +578,7 @@ execute_control_command_1 (struct command_line *cmd, int from_tty)
|
||||||
/* Keep iterating so long as the expression is true. */
|
/* Keep iterating so long as the expression is true. */
|
||||||
while (loop == 1)
|
while (loop == 1)
|
||||||
{
|
{
|
||||||
int cond_result;
|
bool cond_result;
|
||||||
|
|
||||||
QUIT;
|
QUIT;
|
||||||
|
|
||||||
|
|
|
@ -2204,7 +2204,7 @@ logical_and_operation::evaluate (struct type *expect_type,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int tem = value_logical_not (arg1);
|
bool tem = value_logical_not (arg1);
|
||||||
if (!tem)
|
if (!tem)
|
||||||
{
|
{
|
||||||
arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
|
arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
|
||||||
|
@ -2233,7 +2233,7 @@ logical_or_operation::evaluate (struct type *expect_type,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int tem = value_logical_not (arg1);
|
bool tem = value_logical_not (arg1);
|
||||||
if (tem)
|
if (tem)
|
||||||
{
|
{
|
||||||
arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
|
arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
|
||||||
|
|
|
@ -387,23 +387,6 @@ language_info ()
|
||||||
show_language_command (NULL, 1, NULL, NULL);
|
show_language_command (NULL, 1, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This page contains functions that return info about
|
|
||||||
(struct value) values used in GDB. */
|
|
||||||
|
|
||||||
/* Returns non-zero if the value VAL represents a true value. */
|
|
||||||
int
|
|
||||||
value_true (struct value *val)
|
|
||||||
{
|
|
||||||
/* It is possible that we should have some sort of error if a non-boolean
|
|
||||||
value is used in this context. Possibly dependent on some kind of
|
|
||||||
"boolean-checking" option like range checking. But it should probably
|
|
||||||
not depend on the language except insofar as is necessary to identify
|
|
||||||
a "boolean" value (i.e. in C using a float, pointer, etc., as a boolean
|
|
||||||
should be an error, probably). */
|
|
||||||
return !value_logical_not (val);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This page contains functions for the printing out of
|
/* This page contains functions for the printing out of
|
||||||
error messages that occur during type- and range-
|
error messages that occur during type- and range-
|
||||||
checking. */
|
checking. */
|
||||||
|
|
|
@ -778,10 +778,6 @@ extern enum language set_language (enum language);
|
||||||
|
|
||||||
extern void range_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
|
extern void range_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
|
||||||
|
|
||||||
/* Data: Does this value represent "truth" to the current language? */
|
|
||||||
|
|
||||||
extern int value_true (struct value *);
|
|
||||||
|
|
||||||
/* Misc: The string representing a particular enum language. */
|
/* Misc: The string representing a particular enum language. */
|
||||||
|
|
||||||
extern enum language language_enum (const char *str);
|
extern enum language language_enum (const char *str);
|
||||||
|
|
|
@ -748,7 +748,7 @@ opencl_logical_binop_operation::evaluate (struct type *expect_type,
|
||||||
/* For scalar built-in types, only evaluate the right
|
/* For scalar built-in types, only evaluate the right
|
||||||
hand operand if the left hand operand compares
|
hand operand if the left hand operand compares
|
||||||
unequal(&&)/equal(||) to 0. */
|
unequal(&&)/equal(||) to 0. */
|
||||||
int tmp = value_logical_not (arg1);
|
bool tmp = value_logical_not (arg1);
|
||||||
|
|
||||||
if (op == BINOP_LOGICAL_OR)
|
if (op == BINOP_LOGICAL_OR)
|
||||||
tmp = !tmp;
|
tmp = !tmp;
|
||||||
|
|
|
@ -1653,9 +1653,9 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Simulate the C operator ! -- return 1 if ARG1 contains zero. */
|
/* See value.h. */
|
||||||
|
|
||||||
int
|
bool
|
||||||
value_logical_not (struct value *arg1)
|
value_logical_not (struct value *arg1)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
10
gdb/value.h
10
gdb/value.h
|
@ -1022,7 +1022,15 @@ extern int value_equal_contents (struct value *arg1, struct value *arg2);
|
||||||
|
|
||||||
extern int value_less (struct value *arg1, struct value *arg2);
|
extern int value_less (struct value *arg1, struct value *arg2);
|
||||||
|
|
||||||
extern int value_logical_not (struct value *arg1);
|
/* Simulate the C operator ! -- return true if ARG1 contains zero. */
|
||||||
|
extern bool value_logical_not (struct value *arg1);
|
||||||
|
|
||||||
|
/* Returns true if the value VAL represents a true value. */
|
||||||
|
static inline bool
|
||||||
|
value_true (struct value *val)
|
||||||
|
{
|
||||||
|
return !value_logical_not (val);
|
||||||
|
}
|
||||||
|
|
||||||
/* C++ */
|
/* C++ */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue