Skip to content

Commit b79c8ea

Browse files
authored
Merge pull request #3841 from tautschnig/function-goto-diff
goto-diff: Explicitly pass function identifier [blocks: #3126]
2 parents 44a788c + ac924b9 commit b79c8ea

File tree

2 files changed

+77
-67
lines changed

2 files changed

+77
-67
lines changed

src/goto-diff/change_impact.cpp

Lines changed: 76 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -245,45 +245,49 @@ class change_impactt
245245

246246
goto_functions_change_impactt old_change_impact, new_change_impact;
247247

248-
void change_impact(const irep_idt &function);
248+
void change_impact(const irep_idt &function_id);
249249

250250
void change_impact(
251+
const irep_idt &function_id,
251252
const goto_programt &old_goto_program,
252253
const goto_programt &new_goto_program,
253254
const unified_difft::goto_program_difft &diff,
254255
goto_program_change_impactt &old_impact,
255256
goto_program_change_impactt &new_impact);
256257

257258
void propogate_dep_back(
259+
const irep_idt &function_id,
258260
const dependence_grapht::nodet &d_node,
259261
const dependence_grapht &dep_graph,
260262
goto_functions_change_impactt &change_impact,
261263
bool del);
262264
void propogate_dep_forward(
265+
const irep_idt &function_id,
263266
const dependence_grapht::nodet &d_node,
264267
const dependence_grapht &dep_graph,
265268
goto_functions_change_impactt &change_impact,
266269
bool del);
267270

268271
void output_change_impact(
269-
const irep_idt &function,
272+
const irep_idt &function_id,
270273
const goto_program_change_impactt &c_i,
271274
const goto_functionst &goto_functions,
272275
const namespacet &ns) const;
273276
void output_change_impact(
274-
const irep_idt &function,
277+
const irep_idt &function_id,
275278
const goto_program_change_impactt &o_c_i,
276279
const goto_functionst &o_goto_functions,
277280
const namespacet &o_ns,
278281
const goto_program_change_impactt &n_c_i,
279282
const goto_functionst &n_goto_functions,
280283
const namespacet &n_ns) const;
281284

282-
void output_instruction(char prefix,
283-
const goto_programt &goto_program,
284-
const namespacet &ns,
285-
const irep_idt &function,
286-
goto_programt::const_targett &target) const;
285+
void output_instruction(
286+
char prefix,
287+
const goto_programt &goto_program,
288+
const namespacet &ns,
289+
const irep_idt &function_id,
290+
goto_programt::const_targett &target) const;
287291
};
288292

289293
change_impactt::change_impactt(
@@ -312,17 +316,17 @@ change_impactt::change_impactt(
312316
new_dep_graph(new_goto_functions, ns_new);
313317
}
314318

315-
void change_impactt::change_impact(const irep_idt &function)
319+
void change_impactt::change_impact(const irep_idt &function_id)
316320
{
317-
unified_difft::goto_program_difft diff = unified_diff.get_diff(function);
321+
unified_difft::goto_program_difft diff = unified_diff.get_diff(function_id);
318322

319323
if(diff.empty())
320324
return;
321325

322-
goto_functionst::function_mapt::const_iterator old_fit=
323-
old_goto_functions.function_map.find(function);
324-
goto_functionst::function_mapt::const_iterator new_fit=
325-
new_goto_functions.function_map.find(function);
326+
goto_functionst::function_mapt::const_iterator old_fit =
327+
old_goto_functions.function_map.find(function_id);
328+
goto_functionst::function_mapt::const_iterator new_fit =
329+
new_goto_functions.function_map.find(function_id);
326330

327331
goto_programt empty;
328332

@@ -336,14 +340,16 @@ void change_impactt::change_impact(const irep_idt &function)
336340
new_fit->second.body;
337341

338342
change_impact(
343+
function_id,
339344
old_goto_program,
340345
new_goto_program,
341346
diff,
342-
old_change_impact[function],
343-
new_change_impact[function]);
347+
old_change_impact[function_id],
348+
new_change_impact[function_id]);
344349
}
345350

346351
void change_impactt::change_impact(
352+
const irep_idt &function_id,
347353
const goto_programt &old_goto_program,
348354
const goto_programt &new_goto_program,
349355
const unified_difft::goto_program_difft &diff,
@@ -378,17 +384,11 @@ void change_impactt::change_impact(
378384
if(impact_mode==impact_modet::BACKWARD ||
379385
impact_mode==impact_modet::BOTH)
380386
propogate_dep_back(
381-
d_node,
382-
old_dep_graph,
383-
old_change_impact,
384-
true);
387+
function_id, d_node, old_dep_graph, old_change_impact, true);
385388
if(impact_mode==impact_modet::FORWARD ||
386389
impact_mode==impact_modet::BOTH)
387390
propogate_dep_forward(
388-
d_node,
389-
old_dep_graph,
390-
old_change_impact,
391-
true);
391+
function_id, d_node, old_dep_graph, old_change_impact, true);
392392
}
393393
old_impact[o_it]|=DELETED;
394394
++o_it;
@@ -402,18 +402,16 @@ void change_impactt::change_impact(
402402

403403
if(impact_mode==impact_modet::BACKWARD ||
404404
impact_mode==impact_modet::BOTH)
405+
{
405406
propogate_dep_back(
406-
d_node,
407-
new_dep_graph,
408-
new_change_impact,
409-
false);
407+
function_id, d_node, new_dep_graph, new_change_impact, false);
408+
}
410409
if(impact_mode==impact_modet::FORWARD ||
411410
impact_mode==impact_modet::BOTH)
411+
{
412412
propogate_dep_forward(
413-
d_node,
414-
new_dep_graph,
415-
new_change_impact,
416-
false);
413+
function_id, d_node, new_dep_graph, new_change_impact, false);
414+
}
417415
}
418416
new_impact[n_it]|=NEW;
419417
++n_it;
@@ -422,8 +420,8 @@ void change_impactt::change_impact(
422420
}
423421
}
424422

425-
426423
void change_impactt::propogate_dep_forward(
424+
const irep_idt &function_id,
427425
const dependence_grapht::nodet &d_node,
428426
const dependence_grapht &dep_graph,
429427
goto_functions_change_impactt &change_impact,
@@ -437,20 +435,26 @@ void change_impactt::propogate_dep_forward(
437435
mod_flagt data_flag = del ? DEL_DATA_DEP : NEW_DATA_DEP;
438436
mod_flagt ctrl_flag = del ? DEL_CTRL_DEP : NEW_CTRL_DEP;
439437

440-
if((change_impact[src->function][src] &data_flag)
441-
|| (change_impact[src->function][src] &ctrl_flag))
438+
if(
439+
(change_impact[function_id][src] & data_flag) ||
440+
(change_impact[function_id][src] & ctrl_flag))
442441
continue;
443442
if(it->second.get() == dep_edget::kindt::DATA
444443
|| it->second.get() == dep_edget::kindt::BOTH)
445-
change_impact[src->function][src] |= data_flag;
444+
change_impact[function_id][src] |= data_flag;
446445
else
447-
change_impact[src->function][src] |= ctrl_flag;
448-
propogate_dep_forward(dep_graph[dep_graph[src].get_node_id()], dep_graph,
449-
change_impact, del);
446+
change_impact[function_id][src] |= ctrl_flag;
447+
propogate_dep_forward(
448+
function_id,
449+
dep_graph[dep_graph[src].get_node_id()],
450+
dep_graph,
451+
change_impact,
452+
del);
450453
}
451454
}
452455

453456
void change_impactt::propogate_dep_back(
457+
const irep_idt &function_id,
454458
const dependence_grapht::nodet &d_node,
455459
const dependence_grapht &dep_graph,
456460
goto_functions_change_impactt &change_impact,
@@ -464,19 +468,24 @@ void change_impactt::propogate_dep_back(
464468
mod_flagt data_flag = del ? DEL_DATA_DEP : NEW_DATA_DEP;
465469
mod_flagt ctrl_flag = del ? DEL_CTRL_DEP : NEW_CTRL_DEP;
466470

467-
if((change_impact[src->function][src] &data_flag)
468-
|| (change_impact[src->function][src] &ctrl_flag))
471+
if(
472+
(change_impact[function_id][src] & data_flag) ||
473+
(change_impact[function_id][src] & ctrl_flag))
469474
{
470475
continue;
471476
}
472477
if(it->second.get() == dep_edget::kindt::DATA
473478
|| it->second.get() == dep_edget::kindt::BOTH)
474-
change_impact[src->function][src] |= data_flag;
479+
change_impact[function_id][src] |= data_flag;
475480
else
476-
change_impact[src->function][src] |= ctrl_flag;
477-
478-
propogate_dep_back(dep_graph[dep_graph[src].get_node_id()], dep_graph,
479-
change_impact, del);
481+
change_impact[function_id][src] |= ctrl_flag;
482+
483+
propogate_dep_back(
484+
function_id,
485+
dep_graph[dep_graph[src].get_node_id()],
486+
dep_graph,
487+
change_impact,
488+
del);
480489
}
481490
}
482491

@@ -551,18 +560,18 @@ void change_impactt::operator()()
551560
}
552561

553562
void change_impactt::output_change_impact(
554-
const irep_idt &function,
563+
const irep_idt &function_id,
555564
const goto_program_change_impactt &c_i,
556565
const goto_functionst &goto_functions,
557566
const namespacet &ns) const
558567
{
559-
goto_functionst::function_mapt::const_iterator f_it=
560-
goto_functions.function_map.find(function);
568+
goto_functionst::function_mapt::const_iterator f_it =
569+
goto_functions.function_map.find(function_id);
561570
assert(f_it!=goto_functions.function_map.end());
562571
const goto_programt &goto_program=f_it->second.body;
563572

564573
if(!compact_output)
565-
std::cout << "/** " << function << " **/\n";
574+
std::cout << "/** " << function_id << " **/\n";
566575

567576
forall_goto_program_instructions(target, goto_program)
568577
{
@@ -591,31 +600,31 @@ void change_impactt::output_change_impact(
591600
else
592601
UNREACHABLE;
593602

594-
output_instruction(prefix, goto_program, ns, function, target);
603+
output_instruction(prefix, goto_program, ns, function_id, target);
595604
}
596605
}
597606

598607
void change_impactt::output_change_impact(
599-
const irep_idt &function,
608+
const irep_idt &function_id,
600609
const goto_program_change_impactt &o_c_i,
601610
const goto_functionst &o_goto_functions,
602611
const namespacet &o_ns,
603612
const goto_program_change_impactt &n_c_i,
604613
const goto_functionst &n_goto_functions,
605614
const namespacet &n_ns) const
606615
{
607-
goto_functionst::function_mapt::const_iterator o_f_it=
608-
o_goto_functions.function_map.find(function);
616+
goto_functionst::function_mapt::const_iterator o_f_it =
617+
o_goto_functions.function_map.find(function_id);
609618
assert(o_f_it!=o_goto_functions.function_map.end());
610619
const goto_programt &old_goto_program=o_f_it->second.body;
611620

612-
goto_functionst::function_mapt::const_iterator f_it=
613-
n_goto_functions.function_map.find(function);
621+
goto_functionst::function_mapt::const_iterator f_it =
622+
n_goto_functions.function_map.find(function_id);
614623
assert(f_it!=n_goto_functions.function_map.end());
615624
const goto_programt &goto_program=f_it->second.body;
616625

617626
if(!compact_output)
618-
std::cout << "/** " << function << " **/\n";
627+
std::cout << "/** " << function_id << " **/\n";
619628

620629
goto_programt::const_targett o_target=
621630
old_goto_program.instructions.begin();
@@ -629,7 +638,7 @@ void change_impactt::output_change_impact(
629638

630639
if(old_mod_flags&DELETED)
631640
{
632-
output_instruction('-', goto_program, o_ns, function, o_target);
641+
output_instruction('-', goto_program, o_ns, function_id, o_target);
633642
++o_target;
634643
--target;
635644
continue;
@@ -681,7 +690,7 @@ void change_impactt::output_change_impact(
681690
else
682691
UNREACHABLE;
683692

684-
output_instruction(prefix, goto_program, n_ns, function, target);
693+
output_instruction(prefix, goto_program, n_ns, function_id, target);
685694
}
686695
for( ;
687696
o_target!=old_goto_program.instructions.end();
@@ -709,15 +718,16 @@ void change_impactt::output_change_impact(
709718
else
710719
UNREACHABLE;
711720

712-
output_instruction(prefix, goto_program, o_ns, function, o_target);
721+
output_instruction(prefix, goto_program, o_ns, function_id, o_target);
713722
}
714723
}
715724

716-
void change_impactt::output_instruction(char prefix,
717-
const goto_programt &goto_program,
718-
const namespacet &ns,
719-
const irep_idt &function,
720-
goto_programt::const_targett &target) const
725+
void change_impactt::output_instruction(
726+
char prefix,
727+
const goto_programt &goto_program,
728+
const namespacet &ns,
729+
const irep_idt &function_id,
730+
goto_programt::const_targett &target) const
721731
{
722732
if(compact_output)
723733
{
@@ -732,7 +742,7 @@ void change_impactt::output_instruction(char prefix,
732742
else
733743
{
734744
std::cout << prefix;
735-
goto_program.output_instruction(ns, function, std::cout, *target);
745+
goto_program.output_instruction(ns, function_id, std::cout, *target);
736746
}
737747
}
738748

src/goto-diff/unified_diff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class unified_difft
4848

4949
goto_program_difft get_diff(const irep_idt &function) const;
5050

51+
private:
5152
const goto_functionst &old_goto_functions;
5253
const namespacet ns_old;
5354
const goto_functionst &new_goto_functions;
@@ -83,7 +84,6 @@ class unified_difft
8384

8485
const differences_mapt &differences_map() const;
8586

86-
private:
8787
differences_mapt differences_map_;
8888
};
8989

0 commit comments

Comments
 (0)