Skip to content

Commit fedc90b

Browse files
author
Daniel Kroening
authored
Merge pull request #953 from martin-cs/goto-analyzer-5-part1
Goto analyzer 5 part1
2 parents 0bc21fa + 784f2ed commit fedc90b

File tree

8 files changed

+67
-25
lines changed

8 files changed

+67
-25
lines changed

regression/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ DIRS = ansi-c \
1212

1313
test:
1414
$(foreach var,$(DIRS), $(MAKE) -C $(var) test || exit 1;)
15+
16+
clean:
17+
@for dir in *; do \
18+
if [ -d "$$dir" ]; then \
19+
$(MAKE) -C "$$dir" clean; \
20+
fi; \
21+
done;

regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ int main()
44
signed int i;
55
signed int j;
66
i = 0;
7-
if(!(i >= 2))
7+
if(!(i >= 2))
88
{
99
j = j + 1;
1010
i = i + 1;

src/analyses/dependence_graph.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Date: August 2013
1111

1212
#include <cassert>
1313

14+
#include <util/json.h>
15+
#include <util/json_expr.h>
16+
1417
#include "goto_rw.h"
1518

1619
#include "dependence_graph.h"
@@ -347,6 +350,46 @@ void dep_graph_domaint::output(
347350

348351
/*******************************************************************\
349352
353+
Function: dep_graph_domaint::output_json
354+
355+
Inputs: The abstract interpreter and the namespace.
356+
357+
Outputs: The domain, formatted as a JSON object.
358+
359+
Purpose: Outputs the current value of the domain.
360+
361+
\*******************************************************************/
362+
363+
jsont dep_graph_domaint::output_json(
364+
const ai_baset &ai,
365+
const namespacet &ns) const
366+
{
367+
json_arrayt graph;
368+
369+
for(const auto &cd : control_deps)
370+
{
371+
json_objectt &link=graph.push_back().make_object();
372+
link["locationNumber"]=
373+
json_numbert(std::to_string(cd->location_number));
374+
link["sourceLocation"]=json(cd->source_location);
375+
link["type"]=json_stringt("control");
376+
}
377+
378+
for(const auto &dd : data_deps)
379+
{
380+
json_objectt &link=graph.push_back().make_object();
381+
link["locationNumber"]=
382+
json_numbert(std::to_string(dd->location_number));
383+
link["sourceLocation"]=json(dd->source_location);
384+
json_stringt(dd->source_location.as_string());
385+
link["type"]=json_stringt("data");
386+
}
387+
388+
return graph;
389+
}
390+
391+
/*******************************************************************\
392+
350393
Function: dependence_grapht::add_dep
351394
352395
Inputs:

src/analyses/dependence_graph.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ class dep_graph_domaint:public ai_domain_baset
8787
const ai_baset &ai,
8888
const namespacet &ns) const final;
8989

90-
void make_top() final
90+
jsont output_json(
91+
const ai_baset &ai,
92+
const namespacet &ns) const override;
93+
94+
void make_top() final override
9195
{
9296
assert(node_id!=std::numeric_limits<node_indext>::max());
9397

src/analyses/interval_domain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ bool interval_domaint::merge(
157157
for(int_mapt::iterator it=int_map.begin();
158158
it!=int_map.end(); ) // no it++
159159
{
160-
//search for the variable that needs to be merged
161-
//containers have different size and variable order
160+
// search for the variable that needs to be merged
161+
// containers have different size and variable order
162162
const int_mapt::const_iterator b_it=b.int_map.find(it->first);
163163
if(b_it==b.int_map.end())
164164
{

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -506,16 +506,7 @@ int goto_instrument_parse_optionst::doit()
506506
reaching_definitions_analysist rd_analysis(ns);
507507
rd_analysis(goto_functions, ns);
508508

509-
forall_goto_functions(f_it, goto_functions)
510-
{
511-
if(f_it->second.body_available())
512-
{
513-
std::cout << "////\n";
514-
std::cout << "//// Function: " << f_it->first << '\n';
515-
std::cout << "////\n\n";
516-
rd_analysis.output(ns, f_it->second.body, std::cout);
517-
}
518-
}
509+
rd_analysis.output(ns, goto_functions, std::cout);
519510

520511
return 0;
521512
}
@@ -528,17 +519,7 @@ int goto_instrument_parse_optionst::doit()
528519
dependence_grapht dependence_graph(ns);
529520
dependence_graph(goto_functions, ns);
530521

531-
forall_goto_functions(f_it, goto_functions)
532-
{
533-
if(f_it->second.body_available())
534-
{
535-
std::cout << "////\n";
536-
std::cout << "//// Function: " << f_it->first << '\n';
537-
std::cout << "////\n\n";
538-
dependence_graph.output(ns, f_it->second.body, std::cout);
539-
}
540-
}
541-
522+
dependence_graph.output(ns, goto_functions, std::cout);
542523
dependence_graph.output_dot(std::cout);
543524

544525
return 0;

src/goto-programs/remove_unreachable.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,9 @@ void remove_unreachable(goto_programt &goto_program)
5555
it->make_skip();
5656
}
5757
}
58+
59+
void remove_unreachable(goto_functionst &goto_functions)
60+
{
61+
Forall_goto_functions(f_it, goto_functions)
62+
remove_unreachable(f_it->second.body);
63+
}

src/goto-programs/remove_unreachable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ Author: Daniel Kroening, [email protected]
1212
#include "goto_functions.h"
1313

1414
void remove_unreachable(goto_programt &goto_program);
15+
void remove_unreachable(goto_functionst &goto_functions);
1516

1617
#endif // CPROVER_GOTO_PROGRAMS_REMOVE_UNREACHABLE_H

0 commit comments

Comments
 (0)