Skip to content

Commit 321402d

Browse files
committed
Maintain nondet counters across symex instances
Use the path storage, which maintains state across different symex instantiations. While at it, also make the counters std::size_t as using limited bitwidth is not a meaningful optimisation here.
1 parent c09c50d commit 321402d

File tree

8 files changed

+30
-20
lines changed

8 files changed

+30
-20
lines changed

regression/cbmc/Bitfields3/paths.desc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--pointer-check --bounds-check --paths lifo
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

scripts/delete_failing_smt2_solver_tests

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ cd regression/cbmc
44
rm Anonymous_Struct3/test.desc
55
rm Array_operations1/test.desc
66
rm Bitfields3/test.desc
7+
rm Bitfields3/paths.desc
78
rm Empty_struct1/test.desc
89
rm Endianness4/test.desc
910
rm Endianness6/test.desc

src/goto-symex/goto_symex.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,3 @@ void goto_symext::do_simplify(exprt &expr)
2020
if(symex_config.simplify_opt)
2121
simplify(expr, ns);
2222
}
23-
24-
nondet_symbol_exprt symex_nondet_generatort::operator()(typet &type)
25-
{
26-
irep_idt identifier = "symex::nondet" + std::to_string(nondet_count++);
27-
nondet_symbol_exprt new_expr(identifier, type);
28-
return new_expr;
29-
}

src/goto-symex/goto_symex.h

Lines changed: 0 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,6 @@ 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;
422411
static unsigned dynamic_counter;
423412

424413
void rewrite_quantifiers(exprt &, statet &);

src/goto-symex/path_storage.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Author: Kareem Khazem <[email protected]>
1313
#include <util/exit_codes.h>
1414
#include <util/make_unique.h>
1515

16+
nondet_symbol_exprt symex_nondet_generatort::operator()(const typet &type)
17+
{
18+
irep_idt identifier = "symex::nondet" + std::to_string(nondet_count++);
19+
return nondet_symbol_exprt(identifier, type);
20+
}
21+
1622
// _____________________________________________________________________________
1723
// path_lifot
1824

src/goto-symex/path_storage.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515

1616
#include <memory>
1717

18+
/// Functor generating fresh nondet symbols
19+
class symex_nondet_generatort
20+
{
21+
public:
22+
nondet_symbol_exprt operator()(const typet &type);
23+
24+
private:
25+
std::size_t nondet_count = 0;
26+
};
27+
1828
/// \brief Storage for symbolic execution paths to be resumed later
1929
///
2030
/// This data structure supports saving partially-executed symbolic
@@ -85,6 +95,9 @@ class path_storaget
8595
return size() == 0;
8696
};
8797

98+
/// Counter for nondet objects, which require unique names
99+
symex_nondet_generatort build_symex_nondet;
100+
88101
private:
89102
// Derived classes should override these methods, allowing the base class to
90103
// enforce preconditions.

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 = path_storage.build_symex_nondet(*object_type);
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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, path_storage.build_symex_nondet);
185185
dereference(expr, state, write);
186186

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

0 commit comments

Comments
 (0)