From baa57412a7e7a0dbc40c2ad26d31e9dcf5110d6a Mon Sep 17 00:00:00 2001 From: Daniel Poetzl Date: Fri, 10 Feb 2017 12:51:25 +0000 Subject: [PATCH 1/6] Use ai function output in goto-instrument. --- .../goto_instrument_parse_options.cpp | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/goto-instrument/goto_instrument_parse_options.cpp b/src/goto-instrument/goto_instrument_parse_options.cpp index 9c30bae5612..0ee4c125bb5 100644 --- a/src/goto-instrument/goto_instrument_parse_options.cpp +++ b/src/goto-instrument/goto_instrument_parse_options.cpp @@ -506,16 +506,7 @@ int goto_instrument_parse_optionst::doit() reaching_definitions_analysist rd_analysis(ns); rd_analysis(goto_functions, ns); - forall_goto_functions(f_it, goto_functions) - { - if(f_it->second.body_available()) - { - std::cout << "////\n"; - std::cout << "//// Function: " << f_it->first << '\n'; - std::cout << "////\n\n"; - rd_analysis.output(ns, f_it->second.body, std::cout); - } - } + rd_analysis.output(ns, goto_functions, std::cout); return 0; } @@ -528,17 +519,7 @@ int goto_instrument_parse_optionst::doit() dependence_grapht dependence_graph(ns); dependence_graph(goto_functions, ns); - forall_goto_functions(f_it, goto_functions) - { - if(f_it->second.body_available()) - { - std::cout << "////\n"; - std::cout << "//// Function: " << f_it->first << '\n'; - std::cout << "////\n\n"; - dependence_graph.output(ns, f_it->second.body, std::cout); - } - } - + dependence_graph.output(ns, goto_functions, std::cout); dependence_graph.output_dot(std::cout); return 0; From 3eed077891cc93ac010090cdc80c146fc788a086 Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 22 May 2017 20:18:48 +0100 Subject: [PATCH 2/6] Add output_json to the dependence_graph abstract domain. --- src/analyses/dependence_graph.cpp | 50 +++++++++++++++++++++++++++++++ src/analyses/dependence_graph.h | 4 +++ 2 files changed, 54 insertions(+) diff --git a/src/analyses/dependence_graph.cpp b/src/analyses/dependence_graph.cpp index 9c8d70a884f..144bb215d91 100644 --- a/src/analyses/dependence_graph.cpp +++ b/src/analyses/dependence_graph.cpp @@ -11,6 +11,8 @@ Date: August 2013 #include +#include + #include "goto_rw.h" #include "dependence_graph.h" @@ -345,6 +347,54 @@ void dep_graph_domaint::output( } } +/*******************************************************************\ + +Function: dep_graph_domaint::output_json + + Inputs: The abstract interpreter and the namespace. + + Outputs: The domain, formatted as a JSON object. + + Purpose: Outputs the current value of the domain. + +\*******************************************************************/ + + +jsont dep_graph_domaint::output_json( + const ai_baset &ai, + const namespacet &ns) const +{ + json_arrayt graph; + + for(dep_graph_domaint::depst::const_iterator cdi=control_deps.begin(); + cdi!=control_deps.end(); + ++cdi) + { + json_objectt &link=graph.push_back().make_object(); + link["location_number"]= + json_numbert(std::to_string((*cdi)->location_number)); + link["source_location"]= + json_stringt((*cdi)->source_location.as_string()); + link["type"]=json_stringt("control"); + } + + for(dep_graph_domaint::depst::const_iterator ddi=data_deps.begin(); + ddi!=data_deps.end(); + ++ddi) + { + json_objectt &link=graph.push_back().make_object(); + link["location_number"]= + json_numbert(std::to_string((*ddi)->location_number)); + link["source_location"]= + json_stringt((*ddi)->source_location.as_string()); + link["type"]=json_stringt("data"); + } + + return graph; +} + + + /*******************************************************************\ Function: dependence_grapht::add_dep diff --git a/src/analyses/dependence_graph.h b/src/analyses/dependence_graph.h index fae7c7adbd4..8c94c1dde4c 100644 --- a/src/analyses/dependence_graph.h +++ b/src/analyses/dependence_graph.h @@ -87,6 +87,10 @@ class dep_graph_domaint:public ai_domain_baset const ai_baset &ai, const namespacet &ns) const final; + jsont output_json( + const ai_baset &ai, + const namespacet &ns) const override; + void make_top() final { assert(node_id!=std::numeric_limits::max()); From 4d15a3e44c77bb2bb9da2c0105d58d8dc48088fb Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 22 May 2017 20:25:06 +0100 Subject: [PATCH 3/6] Improve annotation of dependence graph declarations. --- src/analyses/dependence_graph.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/analyses/dependence_graph.h b/src/analyses/dependence_graph.h index 8c94c1dde4c..1294a40295e 100644 --- a/src/analyses/dependence_graph.h +++ b/src/analyses/dependence_graph.h @@ -91,7 +91,7 @@ class dep_graph_domaint:public ai_domain_baset const ai_baset &ai, const namespacet &ns) const override; - void make_top() final + void make_top() final override { assert(node_id!=std::numeric_limits::max()); From 37fe40d2cd6089296933d7a61d839d4b46857b21 Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 22 May 2017 20:20:54 +0100 Subject: [PATCH 4/6] Add utility function for remove_unreachable. --- src/goto-programs/remove_unreachable.cpp | 7 +++++++ src/goto-programs/remove_unreachable.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/goto-programs/remove_unreachable.cpp b/src/goto-programs/remove_unreachable.cpp index 14f92e97be1..8c87f205e96 100644 --- a/src/goto-programs/remove_unreachable.cpp +++ b/src/goto-programs/remove_unreachable.cpp @@ -55,3 +55,10 @@ void remove_unreachable(goto_programt &goto_program) it->make_skip(); } } + +void remove_unreachable(goto_functionst &goto_functions) +{ + Forall_goto_functions(f_it, goto_functions) + remove_unreachable(f_it->second.body); +} + diff --git a/src/goto-programs/remove_unreachable.h b/src/goto-programs/remove_unreachable.h index 694cd8c0af8..4fd423641f1 100644 --- a/src/goto-programs/remove_unreachable.h +++ b/src/goto-programs/remove_unreachable.h @@ -12,5 +12,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_functions.h" void remove_unreachable(goto_programt &goto_program); +void remove_unreachable(goto_functionst &goto_functions); #endif // CPROVER_GOTO_PROGRAMS_REMOVE_UNREACHABLE_H From 3961712d85c4d079e1ed34d16e7f1e566cbbc964 Mon Sep 17 00:00:00 2001 From: martin Date: Tue, 23 May 2017 00:01:04 +0100 Subject: [PATCH 5/6] Fix formatting of comments in interval domain. --- src/analyses/interval_domain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/analyses/interval_domain.cpp b/src/analyses/interval_domain.cpp index 1faf8c52364..7ac597bb6ca 100644 --- a/src/analyses/interval_domain.cpp +++ b/src/analyses/interval_domain.cpp @@ -157,8 +157,8 @@ bool interval_domaint::merge( for(int_mapt::iterator it=int_map.begin(); it!=int_map.end(); ) // no it++ { - //search for the variable that needs to be merged - //containers have different size and variable order + // search for the variable that needs to be merged + // containers have different size and variable order const int_mapt::const_iterator b_it=b.int_map.find(it->first); if(b_it==b.int_map.end()) { From 407f377c78dbc7719f5fe804af79bfc56446735b Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 22 May 2017 23:59:59 +0100 Subject: [PATCH 6/6] White space fix up in test case. --- .../constant_propagation_10/constant_propagation_10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c b/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c index 169f7965b9d..f0dea39a424 100644 --- a/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c +++ b/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c @@ -4,7 +4,7 @@ int main() signed int i; signed int j; i = 0; - if(!(i >= 2)) + if(!(i >= 2)) { j = j + 1; i = i + 1;