@@ -13,17 +13,46 @@ Author: Daniel Kroening, kroening@kroening.com
1313// / (and possibly, depending on the parameters, keep those that can be reached
1414// / from the criterion).
1515
16- #include " reachability_slicer.h"
16+ #include " full_slicer_class.h"
17+ #include " reachability_slicer_class.h"
18+
19+ #include < util/exception_utils.h>
1720
1821#include < goto-programs/cfg.h>
1922#include < goto-programs/remove_calls_no_body.h>
2023#include < goto-programs/remove_skip.h>
2124#include < goto-programs/remove_unreachable.h>
2225
23- #include < util/exception_utils .h>
26+ #include < analyses/is_threaded .h>
2427
25- #include " full_slicer_class.h"
26- #include " reachability_slicer_class.h"
28+ #include " reachability_slicer.h"
29+
30+ void reachability_slicert::operator ()(
31+ goto_functionst &goto_functions,
32+ const slicing_criteriont &criterion,
33+ bool include_forward_reachability,
34+ message_handlert &message_handler)
35+ {
36+ // Replace function calls without body by non-deterministic return values to
37+ // ensure the CFG does not consider instructions after such a call to be
38+ // unreachable.
39+ remove_calls_no_bodyt remove_calls_no_body;
40+ remove_calls_no_body (goto_functions, message_handler);
41+ goto_functions.update ();
42+
43+ cfg (goto_functions);
44+ for (const auto &gf_entry : goto_functions.function_map )
45+ {
46+ forall_goto_program_instructions (i_it, gf_entry.second .body )
47+ cfg[cfg.entry_map [i_it]].function_id = gf_entry.first ;
48+ }
49+
50+ is_threadedt is_threaded (goto_functions);
51+ fixedpoint_to_assertions (is_threaded, criterion);
52+ if (include_forward_reachability)
53+ fixedpoint_from_assertions (is_threaded, criterion);
54+ slice (goto_functions);
55+ }
2756
2857// / Get the set of nodes that correspond to the given criterion, or that can
2958// / appear in concurrent execution. None of these should be sliced away so
@@ -364,13 +393,18 @@ void reachability_slicert::slice(goto_functionst &goto_functions)
364393// / \param include_forward_reachability: Determines if only instructions
365394// / from which the criterion is reachable should be kept (false) or also
366395// / those reachable from the criterion (true)
396+ // / \param message_handler: message handler
367397void reachability_slicer (
368398 goto_modelt &goto_model,
369- const bool include_forward_reachability)
399+ const bool include_forward_reachability,
400+ message_handlert &message_handler)
370401{
371402 reachability_slicert s;
372403 assert_criteriont a;
373- s (goto_model.goto_functions , a, include_forward_reachability);
404+ s (goto_model.goto_functions ,
405+ a,
406+ include_forward_reachability,
407+ message_handler);
374408}
375409
376410// / Perform reachability slicing on goto_model for selected properties.
@@ -380,34 +414,42 @@ void reachability_slicer(
380414// / \param include_forward_reachability: Determines if only instructions
381415// / from which the criterion is reachable should be kept (false) or also
382416// / those reachable from the criterion (true)
417+ // / \param message_handler: message handler
383418void reachability_slicer (
384419 goto_modelt &goto_model,
385420 const std::list<std::string> &properties,
386- const bool include_forward_reachability)
421+ const bool include_forward_reachability,
422+ message_handlert &message_handler)
387423{
388424 reachability_slicert s;
389425 properties_criteriont p (properties);
390- s (goto_model.goto_functions , p, include_forward_reachability);
426+ s (goto_model.goto_functions ,
427+ p,
428+ include_forward_reachability,
429+ message_handler);
391430}
392431
393432// / Perform reachability slicing on goto_model for selected functions.
394433// / \param goto_model: Goto program to slice
395434// / \param functions_list: The functions relevant for the slicing (i.e. starting
396435// / point for the search in the CFG). Anything that is reachable in the CFG
397436// / starting from these functions will be kept.
437+ // / \param message_handler: message handler
398438void function_path_reachability_slicer (
399439 goto_modelt &goto_model,
400- const std::list<std::string> &functions_list)
440+ const std::list<std::string> &functions_list,
441+ message_handlert &message_handler)
401442{
402443 for (const auto &function : functions_list)
403444 {
404445 in_function_criteriont matching_criterion (function);
405446 reachability_slicert slicer;
406- slicer (goto_model.goto_functions , matching_criterion, true );
447+ slicer (
448+ goto_model.goto_functions , matching_criterion, true , message_handler);
407449 }
408450
409451 remove_calls_no_bodyt remove_calls_no_body;
410- remove_calls_no_body (goto_model.goto_functions );
452+ remove_calls_no_body (goto_model.goto_functions , message_handler );
411453
412454 goto_model.goto_functions .update ();
413455 goto_model.goto_functions .compute_loop_numbers ();
@@ -417,19 +459,24 @@ void function_path_reachability_slicer(
417459// / comprising all properties. Only instructions from which the criterion
418460// / is reachable will be kept.
419461// / \param goto_model: Goto program to slice
420- void reachability_slicer (goto_modelt &goto_model)
462+ // / \param message_handler: message handler
463+ void reachability_slicer (
464+ goto_modelt &goto_model,
465+ message_handlert &message_handler)
421466{
422- reachability_slicer (goto_model, false );
467+ reachability_slicer (goto_model, false , message_handler );
423468}
424469
425470// / Perform reachability slicing on goto_model for selected properties. Only
426471// / instructions from which the criterion is reachable will be kept.
427472// / \param goto_model: Goto program to slice
428473// / \param properties: The properties relevant for the slicing (i.e. starting
429474// / point for the search in the cfg)
475+ // / \param message_handler: message handler
430476void reachability_slicer (
431477 goto_modelt &goto_model,
432- const std::list<std::string> &properties)
478+ const std::list<std::string> &properties,
479+ message_handlert &message_handler)
433480{
434- reachability_slicer (goto_model, properties, false );
481+ reachability_slicer (goto_model, properties, false , message_handler );
435482}
0 commit comments