@@ -146,15 +146,65 @@ std::string graphml_witnesst::convert_assign_rec(
146
146
exprt clean_rhs=assign.rhs ();
147
147
remove_l0_l1 (clean_rhs);
148
148
149
- result=from_expr (ns, identifier, assign.lhs ())+" = " +
150
- from_expr (ns, identifier, clean_rhs)+" ;" ;
149
+ std::string lhs=from_expr (ns, identifier, assign.lhs ());
150
+ if (lhs.find (' $' )!=std::string::npos)
151
+ lhs=" \\ result" ;
152
+
153
+ result=lhs+" = " +from_expr (ns, identifier, clean_rhs)+" ;" ;
151
154
}
152
155
153
156
return result;
154
157
}
155
158
156
159
/* ******************************************************************\
157
160
161
+ Function: filter_out
162
+
163
+ Inputs:
164
+
165
+ Outputs:
166
+
167
+ Purpose:
168
+
169
+ \*******************************************************************/
170
+
171
+ static bool filter_out (
172
+ const goto_tracet &goto_trace,
173
+ const goto_tracet::stepst::const_iterator &prev_it,
174
+ goto_tracet::stepst::const_iterator &it)
175
+ {
176
+ if (it->hidden &&
177
+ (!it->is_assignment () ||
178
+ to_code_assign (it->pc ->code ).rhs ().id ()!=ID_side_effect ||
179
+ to_code_assign (it->pc ->code ).rhs ().get (ID_statement)!=ID_nondet))
180
+ return true ;
181
+
182
+ if (!it->is_assignment () && !it->is_goto () && !it->is_assert ())
183
+ return true ;
184
+
185
+ // we filter out steps with the same source location
186
+ // TODO: if these are assignments we should accumulate them into
187
+ // a single edge
188
+ if (prev_it!=goto_trace.steps .end () &&
189
+ prev_it->pc ->source_location ==it->pc ->source_location )
190
+ return true ;
191
+
192
+ if (it->is_goto () && it->pc ->guard .is_true ())
193
+ return true ;
194
+
195
+ const source_locationt &source_location=it->pc ->source_location ;
196
+
197
+ if (source_location.is_nil () ||
198
+ source_location.get_file ().empty () ||
199
+ source_location.is_built_in () ||
200
+ source_location.get_line ().empty ())
201
+ return true ;
202
+
203
+ return false ;
204
+ }
205
+
206
+ /* ******************************************************************\
207
+
158
208
Function: graphml_witnesst::operator()
159
209
160
210
Inputs:
@@ -184,20 +234,7 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
184
234
it!=goto_trace.steps .end ();
185
235
it++) // we cannot replace this by a ranged for
186
236
{
187
- const source_locationt &source_location=it->pc ->source_location ;
188
-
189
- if (it->hidden ||
190
- (!it->is_assignment () && !it->is_goto () && !it->is_assert ()) ||
191
- // we filter out steps with the same source location
192
- // TODO: if these are assignments we should accumulate them into
193
- // a single edge
194
- (prev_it!=goto_trace.steps .end () &&
195
- prev_it->pc ->source_location ==it->pc ->source_location ) ||
196
- (it->is_goto () && it->pc ->guard .is_true ()) ||
197
- source_location.is_nil () ||
198
- source_location.get_file ().empty () ||
199
- source_location.is_built_in () ||
200
- source_location.get_line ().empty ())
237
+ if (filter_out (goto_trace, prev_it, it))
201
238
{
202
239
step_to_node[it->step_nr ]=sink;
203
240
@@ -219,6 +256,8 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
219
256
220
257
prev_it=it;
221
258
259
+ const source_locationt &source_location=it->pc ->source_location ;
260
+
222
261
const graphmlt::node_indext node=graphml.add_node ();
223
262
graphml[node].node_name =
224
263
std::to_string (it->pc ->location_number )+" ." +std::to_string (it->step_nr );
@@ -278,23 +317,19 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
278
317
data_l.data =id2string (graphml[from].line );
279
318
}
280
319
281
- if ((it->type ==goto_trace_stept::ASSIGNMENT ||
282
- it->type ==goto_trace_stept::DECL) &&
320
+ if (it->type ==goto_trace_stept::ASSIGNMENT &&
283
321
it->lhs_object_value .is_not_nil () &&
284
322
it->full_lhs .is_not_nil ())
285
323
{
286
- irep_idt identifier=it->lhs_object .get_identifier ();
287
-
288
- if (id2string (it->lhs_object .get_identifier ()).find (' $' )==
289
- std::string::npos &&
290
- (!it->lhs_object_value .is_constant () ||
291
- !it->lhs_object_value .has_operands () ||
292
- !has_prefix (id2string (it->lhs_object_value .op0 ().get (ID_value)),
293
- " INVALID-" )))
324
+ if (!it->lhs_object_value .is_constant () ||
325
+ !it->lhs_object_value .has_operands () ||
326
+ !has_prefix (id2string (it->lhs_object_value .op0 ().get (ID_value)),
327
+ " INVALID-" ))
294
328
{
295
329
xmlt &val=edge.new_element (" data" );
296
330
val.set_attribute (" key" , " assumption" );
297
331
code_assignt assign (it->lhs_object , it->lhs_object_value );
332
+ irep_idt identifier=it->lhs_object .get_identifier ();
298
333
val.data =convert_assign_rec (identifier, assign);
299
334
300
335
xmlt &val_s=edge.new_element (" data" );
0 commit comments