Skip to content

Commit d4cafdf

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 c09c50d commit d4cafdf

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
@@ -160,19 +160,19 @@ static void adjust_byte_extract_rec(exprt &expr, const namespacet &ns)
160160
}
161161
}
162162

163-
static void
164-
replace_nondet(exprt &expr, symex_nondet_generatort &build_symex_nondet)
163+
static void replace_nondet(exprt &expr, unsigned &nondet_count)
165164
{
166165
if(expr.id() == ID_side_effect && expr.get(ID_statement) == ID_nondet)
167166
{
168-
nondet_symbol_exprt new_expr = build_symex_nondet(expr.type());
167+
nondet_symbol_exprt new_expr =
168+
build_symex_nondet(expr.type(), nondet_count);
169169
new_expr.add_source_location() = expr.source_location();
170170
expr.swap(new_expr);
171171
}
172172
else
173173
{
174174
Forall_operands(it, expr)
175-
replace_nondet(*it, build_symex_nondet);
175+
replace_nondet(*it, nondet_count);
176176
}
177177
}
178178

@@ -181,7 +181,7 @@ void goto_symext::clean_expr(
181181
statet &state,
182182
const bool write)
183183
{
184-
replace_nondet(expr, build_symex_nondet);
184+
replace_nondet(expr, nondet_count);
185185
dereference(expr, state, write);
186186

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

0 commit comments

Comments
 (0)