Skip to content

Commit a5bc493

Browse files
author
kroening
committed
use ssa_exprt
git-svn-id: svn+ssh://svn.cprover.org/srv/svn/cbmc/trunk@6381 6afb6bc1-c8e4-404c-8f48-9ae832c5b171
1 parent 6e71d5c commit a5bc493

35 files changed

+750
-694
lines changed

regression/cbmc/Malloc18/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33

44
^EXIT=0$

regression/cbmc/Malloc21/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33

44
^EXIT=0$

src/analyses/goto_check.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,8 @@ void goto_checkt::goto_check(goto_functiont &goto_function)
15401540
goto_programt::targett t=new_code.add_instruction(ASSIGN);
15411541
exprt address_of_expr=address_of_exprt(variable);
15421542
exprt lhs=ns.lookup(CPROVER_PREFIX "dead_object").symbol_expr();
1543+
if(!base_type_eq(lhs.type(), address_of_expr.type(), ns))
1544+
address_of_expr.make_typecast(lhs.type());
15431545
exprt rhs=if_exprt(
15441546
side_effect_expr_nondett(bool_typet()), address_of_expr, lhs, lhs.type());
15451547
t->source_location=i.source_location;

src/cbmc/counterexample_beautification.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void counterexample_beautificationt::get_minimization_list(
4545
{
4646
if(!prop_conv.l_get(it->guard_literal).is_false())
4747
{
48-
const typet &type=it->original_lhs_object.type();
48+
const typet &type=it->ssa_lhs.type();
4949

5050
if(type!=bool_typet())
5151
{

src/goto-programs/goto_trace.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ void goto_trace_stept::output(
112112

113113
if(pc->is_other() || pc->is_assign())
114114
{
115-
irep_idt identifier=lhs_object.get_identifier();
116-
out << " " << identifier
115+
irep_idt identifier=lhs_object.get_object_name();
116+
out << " " << from_expr(ns, identifier, lhs_object.get_original_expr())
117117
<< " = " << from_expr(ns, identifier, lhs_object_value)
118118
<< "\n";
119119
}
@@ -221,11 +221,11 @@ Function: trace_value
221221
void trace_value(
222222
std::ostream &out,
223223
const namespacet &ns,
224-
const symbol_exprt &lhs_object,
224+
const ssa_exprt &lhs_object,
225225
const exprt &full_lhs,
226226
const exprt &value)
227227
{
228-
const irep_idt &identifier=lhs_object.get_identifier();
228+
const irep_idt &identifier=lhs_object.get_object_name();
229229
std::string value_string;
230230

231231
if(value.is_nil())

src/goto-programs/goto_trace.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Date: July 2005
2121
#include <iosfwd>
2222
#include <vector>
2323

24-
#include <util/std_expr.h>
24+
#include <util/ssa_expr.h>
2525

2626
#include <goto-programs/goto_program.h>
2727

@@ -80,7 +80,7 @@ class goto_trace_stept
8080
std::string comment;
8181

8282
// the object being assigned
83-
symbol_exprt lhs_object;
83+
ssa_exprt lhs_object;
8484

8585
// the full, original lhs expression
8686
exprt full_lhs;
@@ -173,7 +173,7 @@ void show_goto_trace(
173173
void trace_value(
174174
std::ostream &out,
175175
const namespacet &ns,
176-
const symbol_exprt &lhs_object,
176+
const ssa_exprt &lhs_object,
177177
const exprt &full_lhs,
178178
const exprt &value);
179179

src/goto-symex/auto_objects.cpp

+16-12
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void goto_symext::initialize_auto_object(
101101
address_of_expr);
102102

103103
code_assignt assignment(expr, rhs);
104-
symex_assign(state, assignment); /* TODO: needs clean */
104+
symex_assign_rec(state, assignment);
105105
}
106106
}
107107
}
@@ -122,21 +122,25 @@ void goto_symext::trigger_auto_object(
122122
const exprt &expr,
123123
statet &state)
124124
{
125-
if(expr.id()==ID_symbol)
125+
if(expr.id()==ID_symbol &&
126+
expr.get_bool(ID_C_SSA_symbol))
126127
{
127-
const symbol_exprt &symbol_expr=to_symbol_expr(expr);
128-
const irep_idt &identifier=symbol_expr.get_identifier();
128+
const ssa_exprt &ssa_expr=to_ssa_expr(expr);
129+
const irep_idt &obj_identifier=ssa_expr.get_object_name();
129130

130-
const symbolt &symbol=
131-
ns.lookup(state.get_original_name(identifier));
132-
133-
if(has_prefix(id2string(symbol.base_name), "auto_object"))
131+
if(obj_identifier!="goto_symex::\\guard")
134132
{
135-
// done already?
136-
if(state.level2.current_names.find(identifier)==
137-
state.level2.current_names.end())
133+
const symbolt &symbol=
134+
ns.lookup(obj_identifier);
135+
136+
if(has_prefix(id2string(symbol.base_name), "auto_object"))
138137
{
139-
initialize_auto_object(expr, state);
138+
// done already?
139+
if(state.level2.current_names.find(ssa_expr.get_identifier())==
140+
state.level2.current_names.end())
141+
{
142+
initialize_auto_object(expr, state);
143+
}
140144
}
141145
}
142146
}

src/goto-symex/build_goto_trace.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ void build_goto_trace(
226226
goto_trace_step.thread_nr=SSA_step.source.thread_nr;
227227
goto_trace_step.pc=SSA_step.source.pc;
228228
goto_trace_step.comment=SSA_step.comment;
229-
goto_trace_step.lhs_object=SSA_step.original_lhs_object;
229+
if(SSA_step.ssa_lhs.is_not_nil())
230+
goto_trace_step.lhs_object=ssa_exprt(SSA_step.ssa_lhs.get_original_expr());
231+
else
232+
goto_trace_step.lhs_object.make_nil();
230233
goto_trace_step.type=SSA_step.type;
231234
goto_trace_step.hidden=SSA_step.hidden;
232235
goto_trace_step.format_string=SSA_step.format_string;

src/goto-symex/goto_symex.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class goto_symext
153153
virtual void symex_atomic_begin(statet &state);
154154
virtual void symex_atomic_end(statet &state);
155155
virtual void symex_decl(statet &state);
156+
virtual void symex_decl(statet &state, const symbol_exprt &expr);
156157
virtual void symex_dead(statet &state);
157158

158159
virtual void symex_other(
@@ -239,12 +240,13 @@ class goto_symext
239240
virtual void do_simplify(exprt &expr);
240241

241242
//virtual void symex_block(statet &state, const codet &code);
243+
void symex_assign_rec(statet &state, const code_assignt &code);
242244
virtual void symex_assign(statet &state, const code_assignt &code);
243245

244246
typedef symex_targett::assignment_typet assignment_typet;
245247

246248
void symex_assign_rec(statet &state, const exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type);
247-
void symex_assign_symbol(statet &state, const symbol_exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type);
249+
void symex_assign_symbol(statet &state, const ssa_exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type);
248250
void symex_assign_typecast(statet &state, const typecast_exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type);
249251
void symex_assign_array(statet &state, const index_exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type);
250252
void symex_assign_struct_member(statet &state, const member_exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type);

0 commit comments

Comments
 (0)