Skip to content

Maintain nondet and dynamic counters across symex instances [blocks: #3976] #3959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions regression/cbmc/Bitfields3/paths.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--pointer-check --bounds-check --paths lifo
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
1 change: 1 addition & 0 deletions scripts/delete_failing_smt2_solver_tests
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cd regression/cbmc
rm Anonymous_Struct3/test.desc
rm Array_operations1/test.desc
rm Bitfields3/test.desc
rm Bitfields3/paths.desc
rm Empty_struct1/test.desc
rm Endianness4/test.desc
rm Endianness6/test.desc
Expand Down
7 changes: 0 additions & 7 deletions src/goto-symex/goto_symex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,3 @@ void goto_symext::do_simplify(exprt &expr)
if(symex_config.simplify_opt)
simplify(expr, ns);
}

nondet_symbol_exprt symex_nondet_generatort::operator()(typet &type)
{
irep_idt identifier = "symex::nondet" + std::to_string(nondet_count++);
nondet_symbol_exprt new_expr(identifier, type);
return new_expr;
}
11 changes: 0 additions & 11 deletions src/goto-symex/goto_symex.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ class namespacet;
class side_effect_exprt;
class typecast_exprt;

/// Functor generating fresh nondet symbols
class symex_nondet_generatort
{
public:
nondet_symbol_exprt operator()(typet &type);

private:
unsigned nondet_count = 0;
};

/// Configuration of the symbolic execution
struct symex_configt final
{
Expand Down Expand Up @@ -418,7 +408,6 @@ class goto_symext
virtual void symex_input(statet &, const codet &);
virtual void symex_output(statet &, const codet &);

symex_nondet_generatort build_symex_nondet;
static unsigned dynamic_counter;

void rewrite_quantifiers(exprt &, statet &);
Expand Down
6 changes: 6 additions & 0 deletions src/goto-symex/path_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Author: Kareem Khazem <[email protected]>
#include <util/exit_codes.h>
#include <util/make_unique.h>

nondet_symbol_exprt symex_nondet_generatort::operator()(const typet &type)
{
irep_idt identifier = "symex::nondet" + std::to_string(nondet_count++);
return nondet_symbol_exprt(identifier, type);
}

// _____________________________________________________________________________
// path_lifot

Expand Down
13 changes: 13 additions & 0 deletions src/goto-symex/path_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@

#include <memory>

/// Functor generating fresh nondet symbols
class symex_nondet_generatort
{
public:
nondet_symbol_exprt operator()(const typet &type);

private:
std::size_t nondet_count = 0;
};

/// \brief Storage for symbolic execution paths to be resumed later
///
/// This data structure supports saving partially-executed symbolic
Expand Down Expand Up @@ -85,6 +95,9 @@ class path_storaget
return size() == 0;
};

/// Counter for nondet objects, which require unique names
symex_nondet_generatort build_symex_nondet;

private:
// Derived classes should override these methods, allowing the base class to
// enforce preconditions.
Expand Down
2 changes: 1 addition & 1 deletion src/goto-symex/symex_builtin_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void goto_symext::symex_allocate(
}
else
{
const exprt nondet = build_symex_nondet(*object_type);
const exprt nondet = path_storage.build_symex_nondet(*object_type);
const code_assignt assignment(value_symbol.symbol_expr(), nondet);
symex_assign(state, assignment);
}
Expand Down
2 changes: 1 addition & 1 deletion src/goto-symex/symex_clean_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void goto_symext::clean_expr(
statet &state,
const bool write)
{
replace_nondet(expr, build_symex_nondet);
replace_nondet(expr, path_storage.build_symex_nondet);
dereference(expr, state, write);

// make sure all remaining byte extract operations use the root
Expand Down