Skip to content

Commit 6f43d38

Browse files
author
Daniel Kroening
authored
Merge pull request #332 from tautschnig/numeric-limits
Use numeric limits instead of (unsigned)-1
2 parents d3e2058 + 4ee0c97 commit 6f43d38

File tree

9 files changed

+234
-227
lines changed

9 files changed

+234
-227
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: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ Function: event_grapht::print_rec_graph
3333
3434
\*******************************************************************/
3535

36-
void event_grapht::print_rec_graph(std::ofstream& file, unsigned node_id,
37-
std::set<unsigned>& visited)
36+
void event_grapht::print_rec_graph(std::ofstream& file, event_idt node_id,
37+
std::set<event_idt>& visited)
3838
{
3939
const abstract_eventt& node=operator[](node_id);
4040
file << node_id << "[label=\"" << node << ", " << node.source_location <<
4141
"\"];" << std::endl;
4242
visited.insert(node_id);
4343

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

54-
for(graph<abstract_eventt>::edgest::const_iterator
54+
for(wmm_grapht::edgest::const_iterator
5555
it=com_out(node_id).begin();
5656
it!=com_out(node_id).end(); ++it)
5757
{
@@ -75,8 +75,8 @@ Function: event_grapht::print_graph
7575

7676
void event_grapht::print_graph() {
7777
assert(po_order.size()>0);
78-
std::set<unsigned> visited;
79-
unsigned root=po_order.front();
78+
std::set<event_idt> visited;
79+
event_idt root=po_order.front();
8080
std::ofstream file;
8181
file.open("graph.dot");
8282
file << "digraph G {" << std::endl;
@@ -98,8 +98,8 @@ Function: event_grapht::copy_segment
9898
9999
\*******************************************************************/
100100

101-
void event_grapht::explore_copy_segment(std::set<unsigned>& explored,
102-
unsigned begin, unsigned end) const
101+
void event_grapht::explore_copy_segment(std::set<event_idt>& explored,
102+
event_idt begin, event_idt end) const
103103
{
104104
//std::cout << "explores " << begin << " against " << end << std::endl;
105105
if(explored.find(begin)!=explored.end())
@@ -110,13 +110,13 @@ void event_grapht::explore_copy_segment(std::set<unsigned>& explored,
110110
if(begin==end)
111111
return;
112112

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

119-
unsigned event_grapht::copy_segment(unsigned begin, unsigned end)
119+
event_idt event_grapht::copy_segment(event_idt begin, event_idt end)
120120
{
121121
const abstract_eventt& begin_event=operator[](begin);
122122
const abstract_eventt& end_event=operator[](end);
@@ -136,25 +136,25 @@ unsigned event_grapht::copy_segment(unsigned begin, unsigned end)
136136

137137
message.status() << "tries to duplicate between " << begin_event.source_location
138138
<< " and " << end_event.source_location << messaget::eom;
139-
std::set<unsigned> covered;
139+
std::set<event_idt> covered;
140140

141141
/* collects the nodes of the subgraph */
142142
explore_copy_segment(covered, begin, end);
143143

144144
if(covered.size()==0)
145145
return end;
146146

147-
// for(std::set<unsigned>::const_iterator it=covered.begin(); it!=covered.end(); ++it)
147+
// for(std::set<event_idt>::const_iterator it=covered.begin(); it!=covered.end(); ++it)
148148
// std::cout << "covered: " << *it << std::endl;
149149

150-
std::map<unsigned, unsigned> orig2copy;
150+
std::map<event_idt, event_idt> orig2copy;
151151

152152
/* duplicates nodes */
153-
for(std::set<unsigned>::const_iterator it=covered.begin();
153+
for(std::set<event_idt>::const_iterator it=covered.begin();
154154
it!=covered.end();
155155
++it)
156156
{
157-
const unsigned new_node=add_node();
157+
const event_idt new_node=add_node();
158158
operator[](new_node)(operator[](*it));
159159
orig2copy[*it]=new_node;
160160
}
@@ -164,11 +164,11 @@ unsigned event_grapht::copy_segment(unsigned begin, unsigned end)
164164
// (working on back-edges...)
165165

166166
/* replicates the po_s forward-edges -- O(#E^2) */
167-
for(std::set<unsigned>::const_iterator it_i=covered.begin();
167+
for(std::set<event_idt>::const_iterator it_i=covered.begin();
168168
it_i!=covered.end();
169169
++it_i)
170170
{
171-
for(std::set<unsigned>::const_iterator it_j=covered.begin();
171+
for(std::set<event_idt>::const_iterator it_j=covered.begin();
172172
it_j!=covered.end();
173173
++it_j)
174174
{
@@ -186,11 +186,11 @@ unsigned event_grapht::copy_segment(unsigned begin, unsigned end)
186186

187187
// TODO: to move to goto2graph, after po_s construction
188188
/* replicates the cmp-edges -- O(#E x #G) */
189-
for(std::set<unsigned>::const_iterator it_i=covered.begin();
189+
for(std::set<event_idt>::const_iterator it_i=covered.begin();
190190
it_i!=covered.end();
191191
++it_i)
192192
{
193-
for(unsigned it_j=0;
193+
for(event_idt it_j=0;
194194
it_j<size();
195195
++it_j)
196196
{
@@ -546,8 +546,8 @@ bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast)
546546
if(first.unsafe_pair(second,model)
547547
&& (first.thread!=second.thread || egraph.are_po_ordered(back(),*s_it)))
548548
{
549-
std::list<unsigned>::const_iterator before_first;
550-
std::list<unsigned>::const_iterator after_second;
549+
std::list<event_idt>::const_iterator before_first;
550+
std::list<event_idt>::const_iterator after_second;
551551

552552
before_first = end();
553553
--before_first;
@@ -580,8 +580,8 @@ bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast)
580580
if(first.unsafe_pair_lwfence(second,model)
581581
&& (first.thread!=second.thread || egraph.are_po_ordered(back(),*s_it)))
582582
{
583-
std::list<unsigned>::const_iterator before_first;
584-
std::list<unsigned>::const_iterator after_second;
583+
std::list<event_idt>::const_iterator before_first;
584+
std::list<event_idt>::const_iterator after_second;
585585

586586
before_first = end();
587587
--before_first;
@@ -1331,7 +1331,7 @@ Function: event_grapht::critical_cyclet::hide_internals
13311331

13321332
void event_grapht::critical_cyclet::hide_internals(critical_cyclet& reduced) const
13331333
{
1334-
std::set<unsigned> reduced_evts;
1334+
std::set<event_idt> reduced_evts;
13351335
const_iterator first_it, prev_it=end();
13361336

13371337
/* finds an element first of its thread */

0 commit comments

Comments
 (0)