Skip to content

Commit 1990994

Browse files
author
martin
committed
Revert "Add edge type parameter to ai transform method"
This reverts commit f8e38fb. There are a number of problems with commit f8e38fb : 1. This is a key API and breaks out-of-tree abstract domains. 2. It doesn't take into account the invariants on transform. 3. The extra parameter duplicates information in the arguments and confuses cases; without a body a CALL instruction is not a CALL. 4. It doesn't fix all of the issues in tranform functions. 5. It doesn't fix the corresponding API issues with merge.
1 parent 3ca91bc commit 1990994

22 files changed

+25
-61
lines changed

src/analyses/ai.cpp

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

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

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

405403
return merge(*tmp_state, l_call, l_return);
406404
}
@@ -417,8 +415,7 @@ bool ai_baset::do_function_call(
417415

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

423420
bool new_data=false;
424421

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

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

451447
// Propagate those
452448
return merge(*tmp_state, l_end, l_return);

src/analyses/ai.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ 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-
4134
// The constructor is expected to produce 'false'
4235
// or 'bottom'
4336
ai_domain_baset()
@@ -60,8 +53,7 @@ class ai_domain_baset
6053
locationt from,
6154
locationt to,
6255
ai_baset &ai,
63-
const namespacet &ns,
64-
edge_typet edge_type) = 0;
56+
const namespacet &ns)=0;
6557

6658
virtual void output(
6759
std::ostream &out,

src/analyses/constant_propagator.cpp

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

src/analyses/constant_propagator.h

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

3130
virtual void output(
3231
std::ostream &out,

src/analyses/custom_bitvector_analysis.cpp

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

src/analyses/custom_bitvector_analysis.h

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

3332
void output(
3433
std::ostream &out,

src/analyses/dependence_graph.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ 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,
191-
ai_domain_baset::edge_typet /*edge_type*/)
190+
const namespacet &ns)
192191
{
193192
dependence_grapht *dep_graph=dynamic_cast<dependence_grapht*>(&ai);
194193
assert(dep_graph!=nullptr);

src/analyses/dependence_graph.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ 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,
87-
ai_domain_baset::edge_typet edge_type) final override;
86+
const namespacet &ns) final override;
8887

8988
void output(
9089
std::ostream &out,

src/analyses/escape_analysis.cpp

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

src/analyses/escape_analysis.h

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

3837
void output(
3938
std::ostream &out,

src/analyses/global_may_alias.cpp

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

src/analyses/global_may_alias.h

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

3837
void output(
3938
std::ostream &out,

src/analyses/interval_domain.cpp

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

src/analyses/interval_domain.h

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

4241
void output(
4342
std::ostream &out,

src/analyses/invariant_set_domain.cpp

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

src/analyses/invariant_set_domain.h

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

6261
void make_top() final override
6362
{

src/analyses/is_threaded.cpp

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

src/analyses/reaching_definitions.cpp

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

src/analyses/reaching_definitions.h

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

123122
void output(
124123
std::ostream &out,

src/analyses/uninitialized_domain.cpp

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

src/analyses/uninitialized_domain.h

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

3938
void output(
4039
std::ostream &out,

unit/analyses/ai/ai_simplify_lhs.cpp

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

0 commit comments

Comments
 (0)