Skip to content

Commit d0c7f41

Browse files
author
Daniel Kroening
committed
value_sets now have function identifiers
1 parent bef68b1 commit d0c7f41

15 files changed

+93
-65
lines changed

src/analyses/flow_insensitive_analysis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ void flow_insensitive_analysis_baset::output(
7272
{
7373
out << "////\n" << "//// Function: " << f_it->first << "\n////\n\n";
7474

75-
output(f_it->second.body, f_it->first, out);
75+
output(f_it->first, f_it->second.body, out);
7676
}
7777
}
7878

7979
void flow_insensitive_analysis_baset::output(
80-
const goto_programt &,
8180
const irep_idt &,
82-
std::ostream &out) const
81+
const goto_programt &,
82+
std::ostream &out)
8383
{
8484
get_state().output(ns, out);
8585
}

src/analyses/flow_insensitive_analysis.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ class flow_insensitive_abstract_domain_baset
4747

4848
virtual bool transform(
4949
const namespacet &ns,
50+
const irep_idt &function_from,
5051
locationt from,
52+
const irep_idt &function_to,
5153
locationt to)=0;
5254

5355
virtual ~flow_insensitive_abstract_domain_baset()
@@ -146,20 +148,13 @@ class flow_insensitive_analysis_baset
146148
std::ostream &out);
147149

148150
virtual void output(
151+
const irep_idt &function_identifier,
149152
const goto_programt &goto_program,
150-
std::ostream &out)
151-
{
152-
output(goto_program, "", out);
153-
}
153+
std::ostream &out);
154154

155155
protected:
156156
const namespacet &ns;
157157

158-
virtual void output(
159-
const goto_programt &goto_program,
160-
const irep_idt &identifier,
161-
std::ostream &out) const;
162-
163158
typedef std::priority_queue<locationt> working_sett;
164159

165160
locationt get_next(working_sett &working_set);

src/pointer-analysis/goto_program_dereference.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void goto_program_dereferencet::get_value_set(
228228
const exprt &expr,
229229
value_setst::valuest &dest)
230230
{
231-
value_sets.get_values(current_target, expr, dest);
231+
value_sets.get_values(current_function, current_target, expr, dest);
232232
}
233233

234234
void goto_program_dereferencet::dereference_expr(
@@ -348,9 +348,11 @@ void goto_program_dereferencet::dereference_instruction(
348348
}
349349

350350
void goto_program_dereferencet::dereference_expression(
351+
const irep_idt &function_identifier,
351352
goto_programt::const_targett target,
352353
exprt &expr)
353354
{
355+
current_function=function_identifier;
354356
current_target=target;
355357
#if 0
356358
valid_local_variables=&target->local_variables;
@@ -427,6 +429,7 @@ void pointer_checks(
427429
}
428430

429431
void dereference(
432+
const irep_idt &function_identifier,
430433
goto_programt::const_targett target,
431434
exprt &expr,
432435
const namespacet &ns,
@@ -436,5 +439,5 @@ void dereference(
436439
symbol_tablet new_symbol_table;
437440
goto_program_dereferencet
438441
goto_program_dereference(ns, new_symbol_table, options, value_sets);
439-
goto_program_dereference.dereference_expression(target, expr);
442+
goto_program_dereference.dereference_expression(function_identifier, target, expr);
440443
}

src/pointer-analysis/goto_program_dereference.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class goto_program_dereferencet:protected dereference_callbackt
5050
void pointer_checks(goto_functionst &goto_functions);
5151

5252
void dereference_expression(
53+
const irep_idt &function,
5354
goto_programt::const_targett target,
5455
exprt &expr);
5556

@@ -92,6 +93,7 @@ class goto_program_dereferencet:protected dereference_callbackt
9293
const std::set<irep_idt> *valid_local_variables;
9394
#endif
9495
source_locationt dereference_location;
96+
irep_idt current_function;
9597
goto_programt::const_targett current_target;
9698

9799
std::set<exprt> assertions;

src/pointer-analysis/value_set_analysis.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class value_set_analysis_templatet:
5959
public:
6060
// interface value_sets
6161
virtual void get_values(
62+
const irep_idt &function_identifier,
6263
locationt l,
6364
const exprt &expr,
6465
value_setst::valuest &dest)

src/pointer-analysis/value_set_analysis_fi.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class value_set_analysis_fit:
3535

3636
typedef flow_insensitive_analysist<value_set_domain_fit> baset;
3737

38-
virtual void initialize(const goto_programt &goto_program);
39-
virtual void initialize(const goto_functionst &goto_functions);
38+
void initialize(const goto_programt &goto_program) override;
39+
void initialize(const goto_functionst &goto_functions) override;
4040

4141
protected:
4242
track_optionst track_options;
@@ -58,15 +58,16 @@ class value_set_analysis_fit:
5858

5959
public:
6060
// interface value_sets
61-
virtual void get_values(
61+
void get_values(
62+
const irep_idt &function_identifier,
6263
locationt l,
6364
const exprt &expr,
64-
std::list<exprt> &dest)
65+
std::list<exprt> &dest) override
6566
{
6667
state.value_set.from_function =
67-
state.value_set.function_numbering.number(l->function);
68+
state.value_set.function_numbering.number(function_identifier);
6869
state.value_set.to_function =
69-
state.value_set.function_numbering.number(l->function);
70+
state.value_set.function_numbering.number(function_identifier);
7071
state.value_set.from_target_index = l->location_number;
7172
state.value_set.to_target_index = l->location_number;
7273
state.value_set.get_value_set(expr, dest, ns);

src/pointer-analysis/value_set_analysis_fivr.h

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,31 @@ class value_set_analysis_fivrt:
3535

3636
typedef flow_insensitive_analysist<value_set_domain_fivrt> baset;
3737

38-
virtual void initialize(const goto_programt &goto_program);
39-
virtual void initialize(const goto_functionst &goto_functions);
38+
void initialize(const goto_programt &goto_program) override;
39+
void initialize(const goto_functionst &goto_functions) override;
4040

4141
using baset::output;
42-
void output(locationt l, std::ostream &out)
42+
void output(
43+
const irep_idt &function_identifier,
44+
locationt l,
45+
std::ostream &out)
4346
{
44-
state.value_set.set_from(l->function, l->location_number);
45-
state.value_set.set_to(l->function, l->location_number);
47+
state.value_set.set_from(function_identifier, l->location_number);
48+
state.value_set.set_to(function_identifier, l->location_number);
4649
state.output(ns, out);
4750
}
4851

49-
void output(const goto_programt &goto_program, std::ostream &out)
52+
void output(
53+
const irep_idt &function_identifier,
54+
const goto_programt &goto_program,
55+
std::ostream &out) override
5056
{
5157
forall_goto_program_instructions(it, goto_program)
5258
{
5359
out << "**** " << it->source_location << '\n';
54-
output(it, out);
60+
output(function_identifier, it, out);
5561
out << '\n';
56-
goto_program.output_instruction(ns, "", out, *it);
62+
goto_program.output_instruction(ns, function_identifier, out, *it);
5763
out << '\n';
5864
}
5965
}
@@ -78,15 +84,16 @@ class value_set_analysis_fivrt:
7884

7985
public:
8086
// interface value_sets
81-
virtual void get_values(
87+
void get_values(
88+
const irep_idt &function_identifier,
8289
locationt l,
8390
const exprt &expr,
84-
std::list<exprt> &dest)
91+
std::list<exprt> &dest) override
8592
{
8693
state.value_set.from_function =
87-
state.value_set.function_numbering.number(l->function);
94+
state.value_set.function_numbering.number(function_identifier);
8895
state.value_set.to_function =
89-
state.value_set.function_numbering.number(l->function);
96+
state.value_set.function_numbering.number(function_identifier);
9097
state.value_set.from_target_index = l->location_number;
9198
state.value_set.to_target_index = l->location_number;
9299
state.value_set.get_value_set(expr, dest, ns);

src/pointer-analysis/value_set_analysis_fivrns.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,27 @@ class value_set_analysis_fivrnst:
4141

4242
using baset::output;
4343

44-
virtual void output(locationt l, std::ostream &out)
44+
void output(
45+
const irep_idt &function_identifier,
46+
locationt l,
47+
std::ostream &out)
4548
{
46-
state.value_set.set_from(l->function, l->location_number);
47-
state.value_set.set_to(l->function, l->location_number);
49+
state.value_set.set_from(function_identifier, l->location_number);
50+
state.value_set.set_to(function_identifier, l->location_number);
4851
state.output(ns, out);
4952
}
5053

51-
void output(const goto_programt &goto_program, std::ostream &out)
54+
void output(
55+
const irep_idt &function_identifier,
56+
const goto_programt &goto_program,
57+
std::ostream &out)
5258
{
5359
forall_goto_program_instructions(it, goto_program)
5460
{
5561
out << "**** " << it->source_location << '\n';
56-
output(it, out);
62+
output(function_identifier, it, out);
5763
out << '\n';
58-
goto_program.output_instruction(ns, "", out, *it);
64+
goto_program.output_instruction(ns, function_identifier, out, *it);
5965
out << '\n';
6066
}
6167
}
@@ -81,14 +87,15 @@ class value_set_analysis_fivrnst:
8187
public:
8288
// interface value_sets
8389
virtual void get_values(
90+
const irep_idt &function_identifier,
8491
locationt l,
8592
const exprt &expr,
8693
std::list<exprt> &dest)
8794
{
8895
state.value_set.from_function =
89-
state.value_set.function_numbering.number(l->function);
96+
state.value_set.function_numbering.number(function_identifier);
9097
state.value_set.to_function =
91-
state.value_set.function_numbering.number(l->function);
98+
state.value_set.function_numbering.number(function_identifier);
9299
state.value_set.from_target_index = l->location_number;
93100
state.value_set.to_target_index = l->location_number;
94101
state.value_set.get_value_set(expr, dest, ns);

src/pointer-analysis/value_set_domain_fi.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ Author: Daniel Kroening, [email protected]
1616

1717
bool value_set_domain_fit::transform(
1818
const namespacet &ns,
19+
const irep_idt &function_from,
1920
locationt from_l,
21+
const irep_idt &function_to,
2022
locationt to_l)
2123
{
2224
value_set.changed = false;
2325

24-
value_set.set_from(from_l->function, from_l->location_number);
25-
value_set.set_to(to_l->function, to_l->location_number);
26+
value_set.set_from(function_from, from_l->location_number);
27+
value_set.set_to(function_to, to_l->location_number);
2628

2729
// std::cout << "transforming: " <<
2830
// from_l->function << " " << from_l->location_number << " to " <<
@@ -49,7 +51,7 @@ bool value_set_domain_fit::transform(
4951
const code_function_callt &code=
5052
to_code_function_call(from_l->code);
5153

52-
value_set.do_function_call(to_l->function, code.arguments(), ns);
54+
value_set.do_function_call(function_to, code.arguments(), ns);
5355
}
5456
break;
5557

src/pointer-analysis/value_set_domain_fi.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,32 @@ class value_set_domain_fit:public flow_insensitive_abstract_domain_baset
3131

3232
virtual void output(
3333
const namespacet &ns,
34-
std::ostream &out) const
34+
std::ostream &out) const override
3535
{
3636
value_set.output(ns, out);
3737
}
3838

39-
virtual void initialize(const namespacet &)
39+
void initialize(const namespacet &) override
4040
{
4141
value_set.clear();
4242
}
4343

44-
virtual bool transform(
44+
bool transform(
4545
const namespacet &ns,
46+
const irep_idt &function_from,
4647
locationt from_l,
47-
locationt to_l);
48+
const irep_idt &function_to,
49+
locationt to_l) override;
4850

49-
virtual void get_reference_set(
51+
void get_reference_set(
5052
const namespacet &ns,
5153
const exprt &expr,
52-
expr_sett &expr_set)
54+
expr_sett &expr_set) override
5355
{
5456
value_set.get_reference_set(expr, expr_set, ns);
5557
}
5658

57-
virtual void clear(void)
59+
void clear(void) override
5860
{
5961
value_set.clear();
6062
}

src/pointer-analysis/value_set_domain_fivr.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ Author: Daniel Kroening, [email protected]
1616

1717
bool value_set_domain_fivrt::transform(
1818
const namespacet &ns,
19+
const irep_idt &function_from,
1920
locationt from_l,
21+
const irep_idt &function_to,
2022
locationt to_l)
2123
{
22-
value_set.set_from(from_l->function, from_l->location_number);
23-
value_set.set_to(to_l->function, to_l->location_number);
24+
value_set.set_from(function_from, from_l->location_number);
25+
value_set.set_to(function_to, to_l->location_number);
2426

2527
#if 0
2628
std::cout << "Transforming: " <<
@@ -45,7 +47,7 @@ bool value_set_domain_fivrt::transform(
4547
const code_function_callt &code=
4648
to_code_function_call(from_l->code);
4749

48-
value_set.do_function_call(to_l->function, code.arguments(), ns);
50+
value_set.do_function_call(function_to, code.arguments(), ns);
4951
break;
5052
}
5153

src/pointer-analysis/value_set_domain_fivr.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,34 @@ class value_set_domain_fivrt:public flow_insensitive_abstract_domain_baset
2424

2525
// overloading
2626

27-
virtual void output(
27+
void output(
2828
const namespacet &ns,
29-
std::ostream &out) const
29+
std::ostream &out) const override
3030
{
3131
value_set.output(ns, out);
3232
}
3333

34-
virtual void initialize(
35-
const namespacet &)
34+
void initialize(const namespacet &) override
3635
{
3736
value_set.clear();
3837
}
3938

40-
virtual bool transform(
39+
bool transform(
4140
const namespacet &ns,
41+
const irep_idt &function_from,
4242
locationt from_l,
43-
locationt to_l);
43+
const irep_idt &function_to,
44+
locationt to_l) override;
4445

45-
virtual void get_reference_set(
46+
void get_reference_set(
4647
const namespacet &ns,
4748
const exprt &expr,
48-
expr_sett &expr_set)
49+
expr_sett &expr_set) override
4950
{
5051
value_set.get_reference_set(expr, expr_set, ns);
5152
}
5253

53-
virtual void clear(void)
54+
void clear(void) override
5455
{
5556
value_set.clear();
5657
}

0 commit comments

Comments
 (0)