Skip to content

Goto analyzer 5 part1 #953

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

Merged
merged 7 commits into from
May 23, 2017
Merged
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
7 changes: 7 additions & 0 deletions regression/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ DIRS = ansi-c \

test:
$(foreach var,$(DIRS), $(MAKE) -C $(var) test || exit 1;)

clean:
@for dir in *; do \
if [ -d "$$dir" ]; then \
$(MAKE) -C "$$dir" clean; \
fi; \
done;
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
43 changes: 43 additions & 0 deletions src/analyses/dependence_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Date: August 2013

#include <cassert>

#include <util/json.h>
#include <util/json_expr.h>

#include "goto_rw.h"

#include "dependence_graph.h"
Expand Down Expand Up @@ -347,6 +350,46 @@ 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(const auto &cd : control_deps)
{
json_objectt &link=graph.push_back().make_object();
link["locationNumber"]=
json_numbert(std::to_string(cd->location_number));
link["sourceLocation"]=json(cd->source_location);
link["type"]=json_stringt("control");
}

for(const auto &dd : data_deps)
{
json_objectt &link=graph.push_back().make_object();
link["locationNumber"]=
json_numbert(std::to_string(dd->location_number));
link["sourceLocation"]=json(dd->source_location);
json_stringt(dd->source_location.as_string());
link["type"]=json_stringt("data");
}

return graph;
}

/*******************************************************************\

Function: dependence_grapht::add_dep

Inputs:
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
6 changes: 6 additions & 0 deletions src/goto-programs/remove_unreachable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ void remove_unreachable(goto_programt &goto_program)
it->make_skip();
}
}

void remove_unreachable(goto_functionst &goto_functions)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the missing comment header please be added in one of the related pull requests?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness I happily note that this is in 8397d11acfc of #961 - thank you, @martin-cs!

{
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, [email protected]
#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