Skip to content

Goto analyzer 5 part1 #952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
50 changes: 50 additions & 0 deletions src/analyses/dependence_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Date: August 2013

#include <cassert>

#include <util/json.h>

#include "goto_rw.h"

#include "dependence_graph.h"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/analyses/dependence_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ class dep_graph_domaint:public ai_domain_baset
const ai_baset &ai,
const namespacet &ns) const final;

void make_top() final
jsont output_json(
const ai_baset &ai,
const namespacet &ns) const override;

void make_top() final override
{
assert(node_id!=std::numeric_limits<node_indext>::max());

Expand Down
4 changes: 2 additions & 2 deletions src/analyses/interval_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
23 changes: 2 additions & 21 deletions src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/goto-programs/remove_unreachable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

1 change: 1 addition & 0 deletions src/goto-programs/remove_unreachable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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