Skip to content

Commit 841e860

Browse files
author
Daniel Kroening
committed
Merge branch 'master' of github.com:diffblue/cbmc
2 parents 2f61c60 + eed4d6c commit 841e860

23 files changed

+345
-169
lines changed

src/analyses/ai.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void ai_baset::entry_state(const goto_programt &goto_program)
122122
{
123123
// The first instruction of 'goto_program' is the entry point,
124124
// and we make that 'top'.
125-
get_state(goto_program.instructions.begin()).make_top();
125+
get_state(goto_program.instructions.begin()).make_entry();
126126
}
127127

128128
/*******************************************************************\

src/analyses/ai.h

+14-19
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,14 @@ class ai_domain_baset
5454
}
5555

5656
// no states
57-
virtual void make_bottom()
58-
{
59-
}
57+
virtual void make_bottom()=0;
6058

61-
// all states
62-
virtual void make_top()
63-
{
64-
}
59+
// all states -- the analysis doesn't use this,
60+
// and domains may refuse to implement it.
61+
virtual void make_top()=0;
6562

6663
// a reasonable entry-point state
67-
virtual void make_entry()
68-
{
69-
}
64+
virtual void make_entry()=0;
7065

7166
// also add
7267
//
@@ -273,7 +268,7 @@ class ait:public ai_baset
273268
return it->second;
274269
}
275270

276-
virtual void clear()
271+
virtual void clear() override
277272
{
278273
state_map.clear();
279274
ai_baset::clear();
@@ -284,33 +279,33 @@ class ait:public ai_baset
284279
state_mapt state_map;
285280

286281
// this one creates states, if need be
287-
virtual statet &get_state(locationt l)
282+
virtual statet &get_state(locationt l) override
288283
{
289284
return state_map[l]; // calls default constructor
290285
}
291286

292287
// this one just finds states
293-
virtual const statet &find_state(locationt l) const
288+
virtual const statet &find_state(locationt l) const override
294289
{
295290
typename state_mapt::const_iterator it=state_map.find(l);
296291
if(it==state_map.end()) throw "failed to find state";
297292
return it->second;
298293
}
299294

300-
virtual bool merge(const statet &src, locationt from, locationt to)
295+
virtual bool merge(const statet &src, locationt from, locationt to) override
301296
{
302297
statet &dest=get_state(to);
303298
return static_cast<domainT &>(dest).merge(static_cast<const domainT &>(src), from, to);
304299
}
305300

306-
virtual statet *make_temporary_state(const statet &s)
301+
virtual statet *make_temporary_state(const statet &s) override
307302
{
308303
return new domainT(static_cast<const domainT &>(s));
309304
}
310305

311306
virtual void fixedpoint(
312307
const goto_functionst &goto_functions,
313-
const namespacet &ns)
308+
const namespacet &ns) override
314309
{
315310
sequential_fixedpoint(goto_functions, ns);
316311
}
@@ -324,7 +319,7 @@ class ait:public ai_baset
324319
const statet &src,
325320
goto_programt::const_targett from,
326321
goto_programt::const_targett to,
327-
const namespacet &ns)
322+
const namespacet &ns) override
328323
{
329324
throw "not implemented";
330325
}
@@ -345,7 +340,7 @@ class concurrency_aware_ait:public ait<domainT>
345340
const statet &src,
346341
goto_programt::const_targett from,
347342
goto_programt::const_targett to,
348-
const namespacet &ns)
343+
const namespacet &ns) override
349344
{
350345
statet &dest=this->get_state(to);
351346
return static_cast<domainT &>(dest).merge_shared(static_cast<const domainT &>(src), from, to, ns);
@@ -354,7 +349,7 @@ class concurrency_aware_ait:public ait<domainT>
354349
protected:
355350
virtual void fixedpoint(
356351
const goto_functionst &goto_functions,
357-
const namespacet &ns)
352+
const namespacet &ns) override
358353
{
359354
this->concurrent_fixedpoint(goto_functions, ns);
360355
}

src/analyses/constant_propagator.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ Author: Peter Schrammel
1616
class constant_propagator_domaint:public ai_domain_baset
1717
{
1818
public:
19-
virtual void transform(locationt, locationt, ai_baset &, const namespacet &);
20-
virtual void output(std::ostream &, const ai_baset &, const namespacet &) const;
19+
void transform(locationt, locationt, ai_baset &, const namespacet &) override final;
20+
void output(std::ostream &, const ai_baset &, const namespacet &) const override final;
21+
void make_top() override final { values.set_to_top(); }
22+
void make_bottom() override final { values.set_to_bottom(); }
23+
void make_entry() override final { values.set_to_top(); }
2124
bool merge(const constant_propagator_domaint &, locationt, locationt);
2225

2326
struct valuest

src/analyses/custom_bitvector_analysis.h

+9-10
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,31 @@ class custom_bitvector_analysist;
2727
class custom_bitvector_domaint:public ai_domain_baset
2828
{
2929
public:
30-
virtual void transform(
30+
void transform(
3131
locationt from,
3232
locationt to,
3333
ai_baset &ai,
34-
const namespacet &ns);
34+
const namespacet &ns) final override;
3535

36-
virtual void output(
36+
void output(
3737
std::ostream &out,
3838
const ai_baset &ai,
39-
const namespacet &ns) const;
39+
const namespacet &ns) const final override;
4040

41-
virtual void make_bottom()
41+
void make_bottom() final override
4242
{
4343
may_bits.clear();
4444
must_bits.clear();
4545
is_bottom=true;
4646
}
4747

48-
virtual void make_top()
48+
void make_top() final override
4949
{
50-
may_bits.clear();
51-
must_bits.clear();
52-
is_bottom=false;
50+
// We don't have a proper top, and refuse to do this.
51+
assert(false);
5352
}
5453

55-
virtual void make_entry()
54+
void make_entry() final override
5655
{
5756
may_bits.clear();
5857
must_bits.clear();

src/analyses/dependence_graph.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,9 @@ void dependence_grapht::add_dep(
368368
goto_programt::const_targett from,
369369
goto_programt::const_targett to)
370370
{
371-
const unsigned n_from=state_map[from].get_node_id();
371+
const node_indext n_from=state_map[from].get_node_id();
372372
assert(n_from<size());
373-
const unsigned n_to=state_map[to].get_node_id();
373+
const node_indext n_to=state_map[to].get_node_id();
374374
assert(n_to<size());
375375

376376
// add_edge is redundant as the subsequent operations also insert

src/analyses/dependence_graph.h

+71-51
Original file line numberDiff line numberDiff line change
@@ -20,56 +20,6 @@ Date: August 2013
2020

2121
class dependence_grapht;
2222

23-
class dep_graph_domaint:public ai_domain_baset
24-
{
25-
public:
26-
dep_graph_domaint():node_id((unsigned)-1)
27-
{
28-
}
29-
30-
bool merge(
31-
const dep_graph_domaint &src,
32-
goto_programt::const_targett from,
33-
goto_programt::const_targett to);
34-
35-
void transform(
36-
goto_programt::const_targett from,
37-
goto_programt::const_targett to,
38-
ai_baset &ai,
39-
const namespacet &ns);
40-
41-
virtual void output(
42-
std::ostream &out,
43-
const ai_baset &ai,
44-
const namespacet &ns) const;
45-
46-
void set_node_id(unsigned id)
47-
{
48-
node_id=id;
49-
}
50-
51-
unsigned get_node_id() const
52-
{
53-
return node_id;
54-
}
55-
56-
protected:
57-
unsigned node_id;
58-
59-
typedef std::set<goto_programt::const_targett> depst;
60-
depst control_deps, data_deps;
61-
62-
void control_dependencies(
63-
goto_programt::const_targett from,
64-
goto_programt::const_targett to,
65-
dependence_grapht &dep_graph);
66-
void data_dependencies(
67-
goto_programt::const_targett from,
68-
goto_programt::const_targett to,
69-
dependence_grapht &dep_graph,
70-
const namespacet &ns);
71-
};
72-
7323
class dep_edget
7424
{
7525
public:
@@ -114,6 +64,76 @@ struct dep_nodet:public graph_nodet<dep_edget>
11464
goto_programt::const_targett PC;
11565
};
11666

67+
class dep_graph_domaint:public ai_domain_baset
68+
{
69+
public:
70+
typedef graph<dep_nodet>::node_indext node_indext;
71+
72+
dep_graph_domaint():
73+
node_id(std::numeric_limits<node_indext>::max())
74+
{
75+
}
76+
77+
bool merge(
78+
const dep_graph_domaint &src,
79+
goto_programt::const_targett from,
80+
goto_programt::const_targett to);
81+
82+
void transform(
83+
goto_programt::const_targett from,
84+
goto_programt::const_targett to,
85+
ai_baset &ai,
86+
const namespacet &ns) final override;
87+
88+
void output(
89+
std::ostream &out,
90+
const ai_baset &ai,
91+
const namespacet &ns) const final override;
92+
93+
void make_top() final override
94+
{
95+
node_id=std::numeric_limits<node_indext>::max();
96+
}
97+
98+
void make_bottom() final override
99+
{
100+
node_id=std::numeric_limits<node_indext>::max();
101+
}
102+
103+
void make_entry() final override
104+
{
105+
node_id=std::numeric_limits<node_indext>::max();
106+
}
107+
108+
void set_node_id(node_indext id)
109+
{
110+
node_id=id;
111+
}
112+
113+
node_indext get_node_id() const
114+
{
115+
assert(node_id!=std::numeric_limits<node_indext>::max());
116+
return node_id;
117+
}
118+
119+
protected:
120+
node_indext node_id;
121+
122+
typedef std::set<goto_programt::const_targett> depst;
123+
depst control_deps, data_deps;
124+
125+
void control_dependencies(
126+
goto_programt::const_targett from,
127+
goto_programt::const_targett to,
128+
dependence_grapht &dep_graph);
129+
130+
void data_dependencies(
131+
goto_programt::const_targett from,
132+
goto_programt::const_targett to,
133+
dependence_grapht &dep_graph,
134+
const namespacet &ns);
135+
};
136+
117137
class dependence_grapht:
118138
public ait<dep_graph_domaint>,
119139
public graph<dep_nodet>
@@ -161,7 +181,7 @@ class dependence_grapht:
161181

162182
if(entry.second)
163183
{
164-
const unsigned node_id=add_node();
184+
const node_indext node_id=add_node();
165185
entry.first->second.set_node_id(node_id);
166186
nodes[node_id].PC=l;
167187
}

src/analyses/escape_analysis.h

+15-6
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,35 @@ class escape_domaint:public ai_domain_baset
3232
{
3333
}
3434

35-
virtual void transform(
35+
void transform(
3636
locationt from,
3737
locationt to,
3838
ai_baset &ai,
39-
const namespacet &ns);
39+
const namespacet &ns) override final;
4040

41-
virtual void output(
41+
void output(
4242
std::ostream &out,
4343
const ai_baset &ai,
44-
const namespacet &ns) const;
44+
const namespacet &ns) const override final;
4545

4646
bool merge(
4747
const escape_domaint &b,
4848
locationt from,
4949
locationt to);
5050

51-
void make_bottom()
51+
void make_bottom() override final
5252
{
5353
cleanup_map.clear();
5454
is_bottom=true;
5555
}
5656

57-
void make_top()
57+
void make_top() override final
58+
{
59+
// We don't have a proper top.
60+
assert(false);
61+
}
62+
63+
void make_entry() override final
5864
{
5965
cleanup_map.clear();
6066
is_bottom=false;
@@ -68,6 +74,9 @@ class escape_domaint:public ai_domain_baset
6874
std::set<irep_idt> cleanup_functions;
6975
};
7076

77+
// We track a set of 'cleanup functions' for specific
78+
// identifiers. The cleanup functions are executed
79+
// once the last pointer to an object is lost.
7180
typedef std::map<irep_idt, cleanupt > cleanup_mapt;
7281
cleanup_mapt cleanup_map;
7382

0 commit comments

Comments
 (0)