Skip to content

Commit 4713383

Browse files
committed
Use get_nondet_bool() in the c nondet symbol factory
1 parent f0a7f1f commit 4713383

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

src/ansi-c/c_nondet_symbol_factory.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Diffblue Ltd.
1515
#include <util/c_types.h>
1616
#include <util/fresh_symbol.h>
1717
#include <util/namespace.h>
18+
#include <util/nondet_bool.h>
1819
#include <util/std_expr.h>
1920
#include <util/std_types.h>
2021
#include <util/string_constant.h>
@@ -42,15 +43,6 @@ static const symbolt &c_new_tmp_symbol(
4243
return tmp_symbol;
4344
}
4445

45-
/// \param type: Desired type (C_bool or plain bool)
46-
/// \param loc: source location
47-
/// \return nondet expr of that type
48-
static exprt c_get_nondet_bool(const typet &type, const source_locationt &loc)
49-
{
50-
// We force this to 0 and 1 and won't consider other values
51-
return typecast_exprt(side_effect_expr_nondett(bool_typet(), loc), type);
52-
}
53-
5446
class symbol_factoryt
5547
{
5648
std::vector<const symbolt *> &symbols_created;
@@ -188,7 +180,7 @@ void symbol_factoryt::gen_nondet_init(
188180
// <expr> = NONDET(_BOOL);
189181
// Else add the following code to assignments:
190182
// <expr> = NONDET(type);
191-
exprt rhs = type.id() == ID_c_bool ? c_get_nondet_bool(type, loc)
183+
exprt rhs = type.id() == ID_c_bool ? get_nondet_bool(type, loc)
192184
: side_effect_expr_nondett(type, loc);
193185
code_assignt assign(expr, rhs);
194186
assign.add_source_location()=loc;

src/util/nondet_bool.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ Author: Chris Smowton, [email protected]
1818
/// \param type desired type (C_bool or plain bool)
1919
/// \param source_location source location
2020
/// \return nondet expr of that type
21-
inline exprt get_nondet_bool(
22-
const typet &type,
23-
const source_locationt &source_location)
21+
inline exprt
22+
get_nondet_bool(const typet &type,const source_locationt &source_location)
2423
{
2524
// We force this to 0 and 1 and won't consider
2625
// other values.

0 commit comments

Comments
 (0)