Skip to content

Commit f8e38fb

Browse files
committed
Add edge type parameter to ai transform method
1 parent 9091faa commit f8e38fb

22 files changed

+61
-25
lines changed

src/analyses/ai.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ bool ai_baset::visit(
365365
// initialize state, if necessary
366366
get_state(to_l);
367367

368-
new_values.transform(l, to_l, *this, ns);
368+
new_values.transform(
369+
l, to_l, *this, ns, ai_domain_baset::edge_typet::FUNCTION_LOCAL);
369370

370371
if(merge(new_values, l, to_l))
371372
have_new_values=true;
@@ -398,7 +399,8 @@ bool ai_baset::do_function_call(
398399
{
399400
// if we don't have a body, we just do an edige call -> return
400401
std::unique_ptr<statet> tmp_state(make_temporary_state(get_state(l_call)));
401-
tmp_state->transform(l_call, l_return, *this, ns);
402+
tmp_state->transform(
403+
l_call, l_return, *this, ns, ai_domain_baset::edge_typet::FUNCTION_LOCAL);
402404

403405
return merge(*tmp_state, l_call, l_return);
404406
}
@@ -415,7 +417,8 @@ bool ai_baset::do_function_call(
415417

416418
// do the edge from the call site to the beginning of the function
417419
std::unique_ptr<statet> tmp_state(make_temporary_state(get_state(l_call)));
418-
tmp_state->transform(l_call, l_begin, *this, ns);
420+
tmp_state->transform(
421+
l_call, l_begin, *this, ns, ai_domain_baset::edge_typet::CALL);
419422

420423
bool new_data=false;
421424

@@ -442,7 +445,8 @@ bool ai_baset::do_function_call(
442445
return false; // function exit point not reachable
443446

444447
std::unique_ptr<statet> tmp_state(make_temporary_state(end_state));
445-
tmp_state->transform(l_end, l_return, *this, ns);
448+
tmp_state->transform(
449+
l_end, l_return, *this, ns, ai_domain_baset::edge_typet::RETURN);
446450

447451
// Propagate those
448452
return merge(*tmp_state, l_end, l_return);

src/analyses/ai.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ class ai_baset;
3131
class ai_domain_baset
3232
{
3333
public:
34+
enum class edge_typet
35+
{
36+
FUNCTION_LOCAL,
37+
CALL,
38+
RETURN,
39+
};
40+
3441
// The constructor is expected to produce 'false'
3542
// or 'bottom'
3643
ai_domain_baset()
@@ -53,7 +60,8 @@ class ai_domain_baset
5360
locationt from,
5461
locationt to,
5562
ai_baset &ai,
56-
const namespacet &ns)=0;
63+
const namespacet &ns,
64+
edge_typet edge_type) = 0;
5765

5866
virtual void output(
5967
std::ostream &out,

src/analyses/constant_propagator.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ void constant_propagator_domaint::transform(
4545
locationt from,
4646
locationt to,
4747
ai_baset &ai,
48-
const namespacet &ns)
48+
const namespacet &ns,
49+
ai_domain_baset::edge_typet /*edge_type*/)
4950
{
5051
#ifdef DEBUG
5152
std::cout << "Transform from/to:\n";

src/analyses/constant_propagator.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class constant_propagator_domaint:public ai_domain_baset
2525
locationt from,
2626
locationt to,
2727
ai_baset &ai_base,
28-
const namespacet &ns) final override;
28+
const namespacet &ns,
29+
ai_domain_baset::edge_typet edge_type) final override;
2930

3031
virtual void output(
3132
std::ostream &out,

src/analyses/custom_bitvector_analysis.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ void custom_bitvector_domaint::transform(
269269
locationt from,
270270
locationt to,
271271
ai_baset &ai,
272-
const namespacet &ns)
272+
const namespacet &ns,
273+
ai_domain_baset::edge_typet /*edge_type*/)
273274
{
274275
// upcast of ai
275276
custom_bitvector_analysist &cba=

src/analyses/custom_bitvector_analysis.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class custom_bitvector_domaint:public ai_domain_baset
2727
locationt from,
2828
locationt to,
2929
ai_baset &ai,
30-
const namespacet &ns) final override;
30+
const namespacet &ns,
31+
ai_domain_baset::edge_typet edge_type) final override;
3132

3233
void output(
3334
std::ostream &out,

src/analyses/dependence_graph.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ void dep_graph_domaint::transform(
187187
goto_programt::const_targett from,
188188
goto_programt::const_targett to,
189189
ai_baset &ai,
190-
const namespacet &ns)
190+
const namespacet &ns,
191+
ai_domain_baset::edge_typet /*edge_type*/)
191192
{
192193
dependence_grapht *dep_graph=dynamic_cast<dependence_grapht*>(&ai);
193194
assert(dep_graph!=nullptr);

src/analyses/dependence_graph.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ class dep_graph_domaint:public ai_domain_baset
8383
goto_programt::const_targett from,
8484
goto_programt::const_targett to,
8585
ai_baset &ai,
86-
const namespacet &ns) final override;
86+
const namespacet &ns,
87+
ai_domain_baset::edge_typet edge_type) final override;
8788

8889
void output(
8990
std::ostream &out,

src/analyses/escape_analysis.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ void escape_domaint::transform(
165165
locationt from,
166166
locationt to,
167167
ai_baset &ai,
168-
const namespacet &ns)
168+
const namespacet &ns,
169+
ai_domain_baset::edge_typet /*edge_type*/)
169170
{
170171
if(has_values.is_false())
171172
return;

src/analyses/escape_analysis.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class escape_domaint:public ai_domain_baset
3232
locationt from,
3333
locationt to,
3434
ai_baset &ai,
35-
const namespacet &ns) final override;
35+
const namespacet &ns,
36+
ai_domain_baset::edge_typet edge_type) final override;
3637

3738
void output(
3839
std::ostream &out,

src/analyses/global_may_alias.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ void global_may_alias_domaint::transform(
7979
locationt from,
8080
locationt to,
8181
ai_baset &ai,
82-
const namespacet &ns)
82+
const namespacet &ns,
83+
ai_domain_baset::edge_typet /*edge_type*/)
8384
{
8485
if(has_values.is_false())
8586
return;

src/analyses/global_may_alias.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class global_may_alias_domaint:public ai_domain_baset
3232
locationt from,
3333
locationt to,
3434
ai_baset &ai,
35-
const namespacet &ns) final override;
35+
const namespacet &ns,
36+
ai_domain_baset::edge_typet edge_type) final override;
3637

3738
void output(
3839
std::ostream &out,

src/analyses/interval_domain.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ void interval_domaint::transform(
5959
locationt from,
6060
locationt to,
6161
ai_baset &ai,
62-
const namespacet &ns)
62+
const namespacet &ns,
63+
ai_domain_baset::edge_typet /*edge_type*/)
6364
{
6465
const goto_programt::instructiont &instruction=*from;
6566
switch(instruction.type)

src/analyses/interval_domain.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class interval_domaint:public ai_domain_baset
3636
locationt from,
3737
locationt to,
3838
ai_baset &ai,
39-
const namespacet &ns) final override;
39+
const namespacet &ns,
40+
ai_domain_baset::edge_typet edge_type) final override;
4041

4142
void output(
4243
std::ostream &out,

src/analyses/invariant_set_domain.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ void invariant_set_domaint::transform(
1717
locationt from_l,
1818
locationt to_l,
1919
ai_baset &ai,
20-
const namespacet &ns)
20+
const namespacet &ns,
21+
ai_domain_baset::edge_typet /*edge_type*/)
2122
{
2223
switch(from_l->type)
2324
{

src/analyses/invariant_set_domain.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class invariant_set_domaint:public ai_domain_baset
5656
locationt from_l,
5757
locationt to_l,
5858
ai_baset &ai,
59-
const namespacet &ns) final override;
59+
const namespacet &ns,
60+
ai_domain_baset::edge_typet edge_type) final override;
6061

6162
void make_top() final override
6263
{

src/analyses/is_threaded.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class is_threaded_domaint:public ai_domain_baset
5252
locationt from,
5353
locationt to,
5454
ai_baset &ai,
55-
const namespacet &ns) final override
55+
const namespacet &ns,
56+
ai_domain_baset::edge_typet /*edge_type*/) final override
5657
{
5758
// assert(reachable);
5859

src/analyses/reaching_definitions.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ void rd_range_domaint::transform(
5959
locationt from,
6060
locationt to,
6161
ai_baset &ai,
62-
const namespacet &ns)
62+
const namespacet &ns,
63+
ai_domain_baset::edge_typet /*edge_type*/)
6364
{
6465
reaching_definitions_analysist *rd=
6566
dynamic_cast<reaching_definitions_analysist*>(&ai);

src/analyses/reaching_definitions.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ class rd_range_domaint:public ai_domain_baset
117117
locationt from,
118118
locationt to,
119119
ai_baset &ai,
120-
const namespacet &ns) final override;
120+
const namespacet &ns,
121+
ai_domain_baset::edge_typet edge_type) final override;
121122

122123
void output(
123124
std::ostream &out,

src/analyses/uninitialized_domain.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ void uninitialized_domaint::transform(
2020
locationt from,
2121
locationt to,
2222
ai_baset &ai,
23-
const namespacet &ns)
23+
const namespacet &ns,
24+
ai_domain_baset::edge_typet /*edge_type*/)
2425
{
2526
if(has_values.is_false())
2627
return;

src/analyses/uninitialized_domain.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class uninitialized_domaint:public ai_domain_baset
3333
locationt from,
3434
locationt to,
3535
ai_baset &ai,
36-
const namespacet &ns) final override;
36+
const namespacet &ns,
37+
ai_domain_baset::edge_typet edge_type) final override;
3738

3839
void output(
3940
std::ostream &out,

unit/analyses/ai/ai_simplify_lhs.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
class constant_simplification_mockt:public ai_domain_baset
2626
{
2727
public:
28-
void transform(locationt, locationt, ai_baset &, const namespacet &) override
28+
void transform(
29+
locationt,
30+
locationt,
31+
ai_baset &,
32+
const namespacet &,
33+
ai_domain_baset::edge_typet) override
2934
{}
3035
void make_bottom() override
3136
{}

0 commit comments

Comments
 (0)