Skip to content

Commit 997f0ad

Browse files
committed
Revert "Replace nondet_count by a functor"
This reverts commit 8fb2902. Nondet symbol names need to be unique across goto_symext instantiations.
1 parent 85d61b5 commit 997f0ad

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

src/goto-symex/goto_symex.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <util/simplify_expr.h>
1515

16+
unsigned goto_symext::nondet_count=0;
1617
unsigned goto_symext::dynamic_counter=0;
1718

1819
void goto_symext::do_simplify(exprt &expr)
@@ -21,7 +22,7 @@ void goto_symext::do_simplify(exprt &expr)
2122
simplify(expr, ns);
2223
}
2324

24-
nondet_symbol_exprt symex_nondet_generatort::operator()(typet &type)
25+
nondet_symbol_exprt build_symex_nondet(typet &type, unsigned &nondet_count)
2526
{
2627
irep_idt identifier = "symex::nondet" + std::to_string(nondet_count++);
2728
nondet_symbol_exprt new_expr(identifier, type);

src/goto-symex/goto_symex.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ class namespacet;
3838
class side_effect_exprt;
3939
class typecast_exprt;
4040

41-
/// Functor generating fresh nondet symbols
42-
class symex_nondet_generatort
43-
{
44-
public:
45-
nondet_symbol_exprt operator()(typet &type);
46-
47-
private:
48-
unsigned nondet_count = 0;
49-
};
50-
5141
/// Configuration of the symbolic execution
5242
struct symex_configt final
5343
{
@@ -418,7 +408,7 @@ class goto_symext
418408
virtual void symex_input(statet &, const codet &);
419409
virtual void symex_output(statet &, const codet &);
420410

421-
symex_nondet_generatort build_symex_nondet;
411+
static unsigned nondet_count;
422412
static unsigned dynamic_counter;
423413

424414
void rewrite_quantifiers(exprt &, statet &);
@@ -473,6 +463,8 @@ class goto_symext
473463
}
474464
};
475465

466+
nondet_symbol_exprt build_symex_nondet(typet &type, unsigned &nondet_count);
467+
476468
void symex_transition(goto_symext::statet &state);
477469

478470
void symex_transition(

src/goto-symex/symex_builtin_functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void goto_symext::symex_allocate(
178178
}
179179
else
180180
{
181-
const exprt nondet = build_symex_nondet(*object_type);
181+
const exprt nondet = build_symex_nondet(*object_type, nondet_count);
182182
const code_assignt assignment(value_symbol.symbol_expr(), nondet);
183183
symex_assign(state, assignment);
184184
}

src/goto-symex/symex_clean_expr.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,19 @@ static void adjust_byte_extract_rec(exprt &expr, const namespacet &ns)
135135
}
136136
}
137137

138-
static void
139-
replace_nondet(exprt &expr, symex_nondet_generatort &build_symex_nondet)
138+
static void replace_nondet(exprt &expr, unsigned &nondet_count)
140139
{
141140
if(expr.id() == ID_side_effect && expr.get(ID_statement) == ID_nondet)
142141
{
143-
nondet_symbol_exprt new_expr = build_symex_nondet(expr.type());
142+
nondet_symbol_exprt new_expr =
143+
build_symex_nondet(expr.type(), nondet_count);
144144
new_expr.add_source_location() = expr.source_location();
145145
expr.swap(new_expr);
146146
}
147147
else
148148
{
149149
Forall_operands(it, expr)
150-
replace_nondet(*it, build_symex_nondet);
150+
replace_nondet(*it, nondet_count);
151151
}
152152
}
153153

@@ -156,7 +156,7 @@ void goto_symext::clean_expr(
156156
statet &state,
157157
const bool write)
158158
{
159-
replace_nondet(expr, build_symex_nondet);
159+
replace_nondet(expr, nondet_count);
160160
dereference(expr, state, write);
161161

162162
// make sure all remaining byte extract operations use the root

0 commit comments

Comments
 (0)