Skip to content

Commit 879a47b

Browse files
committed
Symex support for lhs-typecasts and side effects
1 parent 8e70eaa commit 879a47b

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/path-symex/path_symex.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,14 @@ void path_symext::assign_rec(
422422
var_state.value=propagate(ssa_rhs)?ssa_rhs:nil_exprt();
423423
}
424424
}
425+
else if(ssa_lhs.id()==ID_typecast)
426+
{
427+
// dereferencing might yield a typecast
428+
const exprt &new_lhs=to_typecast_expr(ssa_lhs).op();
429+
typecast_exprt new_rhs(ssa_rhs, new_lhs.type());
430+
431+
assign_rec(state, guard, new_lhs, new_rhs);
432+
}
425433
else if(ssa_lhs.id()==ID_member)
426434
{
427435
#ifdef DEBUG

src/path-symex/path_symex_state_read.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,14 @@ exprt path_symex_statet::instantiate_rec(
247247
{
248248
irep_idt id="symex::nondet"+std::to_string(var_map.nondet_count);
249249
var_map.nondet_count++;
250-
return symbol_exprt(id, src.type());
250+
251+
auxiliary_symbolt nondet_symbol;
252+
nondet_symbol.name=id;
253+
nondet_symbol.base_name=id;
254+
nondet_symbol.type=src.type();
255+
var_map.new_symbols.add(nondet_symbol);
256+
257+
return nondet_symbol.symbol_expr();
251258
}
252259
else
253260
throw "instantiate_rec: unexpected side effect "+id2string(statement);

src/path-symex/var_map.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@ Author: Daniel Kroening, kroening@kroening.com
1818
#include <util/namespace.h>
1919
#include <util/type.h>
2020
#include <util/std_expr.h>
21+
#include <util/symbol_table.h>
2122

2223
class var_mapt
2324
{
2425
public:
2526
explicit var_mapt(const namespacet &_ns):
26-
ns(_ns), shared_count(0), local_count(0), nondet_count(0), dynamic_count(0)
27+
ns(_ns.get_symbol_table(), new_symbols),
28+
shared_count(0),
29+
local_count(0),
30+
nondet_count(0),
31+
dynamic_count(0)
2732
{
2833
}
2934

@@ -93,7 +98,8 @@ class var_mapt
9398

9499
void init(var_infot &var_info);
95100

96-
const namespacet &ns;
101+
const namespacet ns;
102+
symbol_tablet new_symbols;
97103

98104
void output(std::ostream &) const;
99105

0 commit comments

Comments
 (0)