Skip to content

Commit 2da51e7

Browse files
committed
Typedef wmm_grapht instead of repeating template instantiation
The typedef increases maintainability and will also enable proper use of node identifier types in place of "unsigned".
1 parent 654e5ef commit 2da51e7

File tree

8 files changed

+43
-41
lines changed

8 files changed

+43
-41
lines changed

src/goto-instrument/wmm/cycle_collection.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ bool event_grapht::graph_explorert::backtrack(
393393
if(!get_com_only)
394394
{
395395
/* we first visit via po transition, if existing */
396-
for(graph<abstract_eventt>::edgest::const_iterator
396+
for(wmm_grapht::edgest::const_iterator
397397
w_it=egraph.po_out(vertex).begin();
398398
w_it!=egraph.po_out(vertex).end(); w_it++)
399399
{
@@ -436,7 +436,7 @@ bool event_grapht::graph_explorert::backtrack(
436436

437437
if(!no_comm)
438438
/* we then visit via com transitions, if existing */
439-
for(graph<abstract_eventt>::edgest::const_iterator
439+
for(wmm_grapht::edgest::const_iterator
440440
w_it=egraph.com_out(vertex).begin();
441441
w_it!=egraph.com_out(vertex).end(); w_it++)
442442
{
@@ -568,7 +568,7 @@ bool event_grapht::graph_explorert::backtrack(
568568
(!this_vertex.WRfence
569569
&& egraph[point_stack.top()].operation==abstract_eventt::Write));
570570

571-
for(graph<abstract_eventt>::edgest::const_iterator w_it=
571+
for(wmm_grapht::edgest::const_iterator w_it=
572572
egraph.po_out(vertex).begin();
573573
w_it!=egraph.po_out(vertex).end(); w_it++)
574574
{

src/goto-instrument/wmm/event_graph.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void event_grapht::print_rec_graph(std::ofstream& file, unsigned node_id,
4242
"\"];" << std::endl;
4343
visited.insert(node_id);
4444

45-
for(graph<abstract_eventt>::edgest::const_iterator
45+
for(wmm_grapht::edgest::const_iterator
4646
it=po_out(node_id).begin();
4747
it!=po_out(node_id).end(); ++it)
4848
{
@@ -52,7 +52,7 @@ void event_grapht::print_rec_graph(std::ofstream& file, unsigned node_id,
5252
print_rec_graph(file, it->first, visited);
5353
}
5454

55-
for(graph<abstract_eventt>::edgest::const_iterator
55+
for(wmm_grapht::edgest::const_iterator
5656
it=com_out(node_id).begin();
5757
it!=com_out(node_id).end(); ++it)
5858
{
@@ -111,7 +111,7 @@ void event_grapht::explore_copy_segment(std::set<unsigned>& explored,
111111
if(begin==end)
112112
return;
113113

114-
for(graph<abstract_eventt>::edgest::const_iterator it=po_out(begin).begin();
114+
for(wmm_grapht::edgest::const_iterator it=po_out(begin).begin();
115115
it!=po_out(begin).end();
116116
++it)
117117
explore_copy_segment(explored, it->first, end);

src/goto-instrument/wmm/event_graph.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class namespacet;
2929
graph of abstract events
3030
\*******************************************************************/
3131

32+
typedef graph<abstract_eventt> wmm_grapht;
33+
3234
class event_grapht
3335
{
3436
public:
@@ -194,14 +196,14 @@ class event_grapht
194196

195197
inline bool operator<(const critical_cyclet& other) const
196198
{
197-
return ( ((std::list<unsigned>) *this) < (std::list<unsigned>)other);
199+
return ( ((std::list<event_idt>) *this) < (std::list<event_idt>)other);
198200
}
199201
};
200202

201203
protected:
202204
/* graph contains po and com transitions */
203-
graph<abstract_eventt> po_graph;
204-
graph<abstract_eventt> com_graph;
205+
wmm_grapht po_graph;
206+
wmm_grapht com_graph;
205207

206208
/* parameters limiting the exploration */
207209
unsigned max_var;
@@ -365,7 +367,7 @@ class event_grapht
365367
return po_no;
366368
}
367369

368-
inline graph<abstract_eventt>::nodet &operator[](unsigned n)
370+
inline wmm_grapht::nodet &operator[](unsigned n)
369371
{
370372
return po_graph[n];
371373
}
@@ -385,22 +387,22 @@ class event_grapht
385387
return po_graph.size();
386388
}
387389

388-
inline const graph<abstract_eventt>::edgest &po_in(unsigned n) const
390+
inline const wmm_grapht::edgest &po_in(unsigned n) const
389391
{
390392
return po_graph.in(n);
391393
}
392394

393-
inline const graph<abstract_eventt>::edgest &po_out(unsigned n) const
395+
inline const wmm_grapht::edgest &po_out(unsigned n) const
394396
{
395397
return po_graph.out(n);
396398
}
397399

398-
inline const graph<abstract_eventt>::edgest &com_in(unsigned n) const
400+
inline const wmm_grapht::edgest &com_in(unsigned n) const
399401
{
400402
return com_graph.in(n);
401403
}
402404

403-
inline const graph<abstract_eventt>::edgest &com_out(unsigned n) const
405+
inline const wmm_grapht::edgest &com_out(unsigned n) const
404406
{
405407
return com_graph.out(n);
406408
}

src/goto-instrument/wmm/goto2graph.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ Function: alt_copy_segment
477477
478478
\*******************************************************************/
479479

480-
unsigned alt_copy_segment(graph<abstract_eventt>& alt_egraph,
480+
unsigned alt_copy_segment(wmm_grapht& alt_egraph,
481481
unsigned begin, unsigned end)
482482
{
483483
/* no need to duplicate the loop nodes for the SCC-detection graph -- a
@@ -1457,13 +1457,13 @@ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet& cyc)
14571457
}
14581458
assert(current_po);
14591459

1460-
const graph<abstract_eventt>::edgest& pos_cur = egraph.po_out(*e_it);
1461-
const graph<abstract_eventt>::edgest& pos_next = egraph.po_out(*(++e_it));
1460+
const wmm_grapht::edgest& pos_cur = egraph.po_out(*e_it);
1461+
const wmm_grapht::edgest& pos_next = egraph.po_out(*(++e_it));
14621462
--e_it;
14631463

14641464
bool exists_n = false;
14651465

1466-
for(graph<abstract_eventt>::edgest::const_iterator edge_it=pos_cur.begin();
1466+
for(wmm_grapht::edgest::const_iterator edge_it=pos_cur.begin();
14671467
edge_it!=pos_cur.end(); edge_it++)
14681468
{
14691469
if(pos_next.find(edge_it->first)!=pos_next.end())

src/goto-instrument/wmm/goto2graph.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class instrumentert
3838

3939
/* alternative representation of graph (SCC) */
4040
std::map<unsigned,unsigned> map_vertex_gnode;
41-
graph<abstract_eventt> egraph_alt;
41+
wmm_grapht egraph_alt;
4242

4343
unsigned unique_id;
4444

@@ -93,7 +93,7 @@ class instrumentert
9393
/* pointer to the egraph(s) that we construct */
9494
event_grapht& egraph;
9595
std::vector<std::set<unsigned> >& egraph_SCCs;
96-
graph<abstract_eventt>& egraph_alt;
96+
wmm_grapht& egraph_alt;
9797

9898
/* for thread marking (dynamic) */
9999
unsigned current_thread;

src/goto-instrument/wmm/pair_collection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ bool event_grapht::graph_pensieve_explorert::find_second_event(
8989

9090
visited_nodes.insert(current);
9191

92-
for(graph<abstract_eventt>::edgest::const_iterator
92+
for(wmm_grapht::edgest::const_iterator
9393
it=egraph.po_out(current).begin();
9494
it!=egraph.po_out(current).end(); ++it)
9595
{

src/musketeer/cycles_visitor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void cycles_visitort::po_edges(std::set<unsigned>& edges)
6161
{
6262
/* also add pos of non-delaying pos+ of cycles, as they could AC or
6363
BC */
64-
for(graph<abstract_eventt>::edgest::const_iterator
64+
for(wmm_grapht::edgest::const_iterator
6565
next_it=egraph.po_in(e_i->first).begin();
6666
next_it!=egraph.po_in(e_i->first).end();
6767
++next_it)
@@ -73,7 +73,7 @@ void cycles_visitort::po_edges(std::set<unsigned>& edges)
7373
next_it->first, new_path);
7474
}
7575

76-
for(graph<abstract_eventt>::edgest::const_iterator
76+
for(wmm_grapht::edgest::const_iterator
7777
next_it=egraph.po_out(e_i->second).begin();
7878
next_it!=egraph.po_out(e_i->second).end();
7979
++next_it)
@@ -105,7 +105,7 @@ void cycles_visitort::po_edges(std::set<unsigned>& edges)
105105
else
106106
{
107107
/* adds basic pos from this pos^+ */
108-
for(graph<abstract_eventt>::edgest::const_iterator
108+
for(wmm_grapht::edgest::const_iterator
109109
next_it=egraph.po_out(e_i.first).begin();
110110
next_it!=egraph.po_out(e_i.first).end();
111111
++next_it)
@@ -129,7 +129,7 @@ void cycles_visitort::po_edges(std::set<unsigned>& edges)
129129
else
130130
{
131131
/* adds basic pos from this pos^+ */
132-
for(graph<abstract_eventt>::edgest::const_iterator
132+
for(wmm_grapht::edgest::const_iterator
133133
next_it=egraph.po_out(e_i.first).begin();
134134
next_it!=egraph.po_out(e_i.first).end();
135135
++next_it)

src/musketeer/graph_visitor.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void const_graph_visitort::graph_explore(event_grapht& egraph, unsigned next,
4343
/* this path is not connecting a to b => return */
4444
}
4545
else {
46-
for(graph<abstract_eventt>::edgest::const_iterator
46+
for(wmm_grapht::edgest::const_iterator
4747
next_it=egraph.po_out(next).begin();
4848
next_it!=egraph.po_out(next).end();
4949
++next_it)
@@ -90,7 +90,7 @@ void const_graph_visitort::const_graph_explore(event_grapht& egraph, unsigned ne
9090
/* this path is not connecting a to b => return */
9191
}
9292
else {
93-
for(graph<abstract_eventt>::edgest::const_iterator
93+
for(wmm_grapht::edgest::const_iterator
9494
next_it=egraph.po_out(next).begin();
9595
next_it!=egraph.po_out(next).end();
9696
++next_it)
@@ -133,7 +133,7 @@ void const_graph_visitort::graph_explore_BC(event_grapht& egraph, unsigned next,
133133

134134
/* if all the incoming pos were already visited, add */
135135
bool no_other_pos = true;
136-
for(graph<abstract_eventt>::edgest::const_iterator it=
136+
for(wmm_grapht::edgest::const_iterator it=
137137
egraph.po_out(next).begin();
138138
it!=egraph.po_out(next).end();
139139
++it)
@@ -159,7 +159,7 @@ void const_graph_visitort::graph_explore_BC(event_grapht& egraph, unsigned next,
159159
assert(it!=old_path.end());
160160
}
161161
else {
162-
for(graph<abstract_eventt>::edgest::const_iterator
162+
for(wmm_grapht::edgest::const_iterator
163163
next_it=egraph.po_out(next).begin();
164164
next_it!=egraph.po_out(next).end();
165165
++next_it)
@@ -195,7 +195,7 @@ void const_graph_visitort::const_graph_explore_BC(event_grapht& egraph,
195195

196196
/* if all the incoming pos were already visited, add */
197197
bool no_other_pos = true;
198-
for(graph<abstract_eventt>::edgest::const_iterator it=
198+
for(wmm_grapht::edgest::const_iterator it=
199199
egraph.po_out(next).begin();
200200
it!=egraph.po_out(next).end();
201201
++it)
@@ -222,7 +222,7 @@ void const_graph_visitort::const_graph_explore_BC(event_grapht& egraph,
222222
assert(it!=old_path.end());
223223
}
224224
else {
225-
for(graph<abstract_eventt>::edgest::const_iterator
225+
for(wmm_grapht::edgest::const_iterator
226226
next_it=egraph.po_out(next).begin();
227227
next_it!=egraph.po_out(next).end();
228228
++next_it)
@@ -261,7 +261,7 @@ void const_graph_visitort::graph_explore_AC(event_grapht& egraph, unsigned next,
261261

262262
/* if all the incoming pos were already visited, add */
263263
bool no_other_pos = true;
264-
for(graph<abstract_eventt>::edgest::const_iterator it=
264+
for(wmm_grapht::edgest::const_iterator it=
265265
egraph.po_in(next).begin();
266266
it!=egraph.po_in(next).end();
267267
++it)
@@ -287,7 +287,7 @@ void const_graph_visitort::graph_explore_AC(event_grapht& egraph, unsigned next,
287287
assert(it!=old_path.end());
288288
}
289289
else {
290-
for(graph<abstract_eventt>::edgest::const_iterator
290+
for(wmm_grapht::edgest::const_iterator
291291
next_it=egraph.po_in(next).begin();
292292
next_it!=egraph.po_in(next).end();
293293
++next_it)
@@ -323,7 +323,7 @@ void const_graph_visitort::const_graph_explore_AC(event_grapht& egraph,
323323

324324
/* if all the incoming pos were already visited, add */
325325
bool no_other_pos = true;
326-
for(graph<abstract_eventt>::edgest::const_iterator it=
326+
for(wmm_grapht::edgest::const_iterator it=
327327
egraph.po_in(next).begin();
328328
it!=egraph.po_in(next).end();
329329
++it)
@@ -351,7 +351,7 @@ void const_graph_visitort::const_graph_explore_AC(event_grapht& egraph,
351351
assert(it!=old_path.end());
352352
}
353353
else {
354-
for(graph<abstract_eventt>::edgest::const_iterator
354+
for(wmm_grapht::edgest::const_iterator
355355
next_it=egraph.po_in(next).begin();
356356
next_it!=egraph.po_in(next).end();
357357
++next_it)
@@ -380,15 +380,15 @@ void const_graph_visitort::PT(const edget& e, std::set<unsigned>& edges) {
380380

381381
// if(!e.is_po) /* e is in po^+\po */ is_po is a flag set manually, do not
382382
// use it for checks!!
383-
const graph<abstract_eventt>::edgest& list_po_out=
383+
const wmm_grapht::edgest& list_po_out=
384384
fence_inserter.instrumenter.egraph.po_out(e.first);
385385
if(list_po_out.find(e.second)==list_po_out.end())
386386
{
387387
#ifdef BTWN1
388388
event_grapht& egraph=fence_inserter.instrumenter.egraph;
389389

390390
/* all the pos inbetween */
391-
for(graph<abstract_eventt>::edgest::const_iterator
391+
for(wmm_grapht::edgest::const_iterator
392392
next_it=egraph.po_out(e.first).begin();
393393
next_it!=egraph.po_out(e.first).end();
394394
++next_it)
@@ -444,7 +444,7 @@ void const_graph_visitort::CT(const edget& edge, std::set<unsigned>& edges) {
444444

445445
/* if one event only on this thread of the cycle, discard */
446446
if(egraph.po_in(first).size() > 0)
447-
for(graph<abstract_eventt>::edgest::const_iterator
447+
for(wmm_grapht::edgest::const_iterator
448448
next_it=egraph.po_in(first).begin();
449449
next_it!=egraph.po_in(first).end();
450450
++next_it)
@@ -456,7 +456,7 @@ void const_graph_visitort::CT(const edget& edge, std::set<unsigned>& edges) {
456456
}
457457

458458
if(egraph.po_out(second).size() > 0)
459-
for(graph<abstract_eventt>::edgest::const_iterator
459+
for(wmm_grapht::edgest::const_iterator
460460
next_it=egraph.po_out(second).begin();
461461
next_it!=egraph.po_out(second).end();
462462
++next_it)
@@ -499,7 +499,7 @@ void const_graph_visitort::CT_not_powr(const edget& edge,
499499
visited_nodes.clear();
500500

501501
if(egraph.po_in(first).size() > 0)
502-
for(graph<abstract_eventt>::edgest::const_iterator
502+
for(wmm_grapht::edgest::const_iterator
503503
next_it=egraph.po_in(first).begin();
504504
next_it!=egraph.po_in(first).end();
505505
++next_it)
@@ -511,7 +511,7 @@ void const_graph_visitort::CT_not_powr(const edget& edge,
511511
}
512512

513513
if(egraph.po_out(second).size() > 0)
514-
for(graph<abstract_eventt>::edgest::const_iterator
514+
for(wmm_grapht::edgest::const_iterator
515515
next_it=egraph.po_out(second).begin();
516516
next_it!=egraph.po_out(second).end();
517517
++next_it)

0 commit comments

Comments
 (0)