Skip to content

Commit 8929897

Browse files
author
kroening
committed
use std::size_t where needed
git-svn-id: svn+ssh://svn.cprover.org/srv/svn/cbmc/trunk@6495 6afb6bc1-c8e4-404c-8f48-9ae832c5b171
1 parent d065184 commit 8929897

File tree

4 files changed

+38
-25
lines changed

4 files changed

+38
-25
lines changed

src/goto-instrument/accelerate/overflow_instrumenter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ void overflow_instrumentert::overflow_expr(const exprt &expr,
8383
}
8484

8585
const typet &old_type = ns.follow(expr.op0().type());
86-
unsigned new_width = expr.type().get_int(ID_width);
87-
unsigned old_width = old_type.get_int(ID_width);
86+
std::size_t new_width = expr.type().get_int(ID_width);
87+
std::size_t old_width = old_type.get_int(ID_width);
8888

8989
if (type.id() == ID_signedbv) {
9090
if (old_type.id() == ID_signedbv) {
@@ -160,7 +160,7 @@ void overflow_instrumentert::overflow_expr(const exprt &expr,
160160

161161
if (expr.operands().size() >= 3) {
162162
// The overflow checks are binary.
163-
for (unsigned i = 1; i < expr.operands().size(); i++) {
163+
for (std::size_t i = 1; i < expr.operands().size(); i++) {
164164
exprt tmp;
165165

166166
if (i == 1) {

src/goto-instrument/accelerate/trace_automaton.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,12 @@ void automatont::move(state_sett &s, goto_programt::targett a, state_sett &t) {
299299
}
300300
}
301301

302-
void trace_automatont::get_transitions(sym_mapt &transitions) {
302+
void trace_automatont::get_transitions(sym_mapt &transitions)
303+
{
303304
automatont::transition_tablet &dtrans = dta.transitions;
304305

305-
for (unsigned int i = 0; i < dtrans.size(); ++i) {
306+
for(std::size_t i = 0; i < dtrans.size(); ++i)
307+
{
306308
automatont::transitionst &dta_transitions = dtrans[i];
307309

308310
for (automatont::transitionst::iterator it = dta_transitions.begin();
@@ -318,13 +320,14 @@ void trace_automatont::get_transitions(sym_mapt &transitions) {
318320
}
319321
}
320322

321-
void automatont::reverse(goto_programt::targett epsilon) {
323+
void automatont::reverse(goto_programt::targett epsilon)
324+
{
322325
transition_tablet old_table;
323326
statet new_init;
324327

325328
old_table.swap(transitions);
326329

327-
for (unsigned int i = 0; i < old_table.size(); i++) {
330+
for(std::size_t i = 0; i < old_table.size(); i++) {
328331
transitions.push_back(transitionst());
329332
}
330333

@@ -354,7 +357,8 @@ void automatont::reverse(goto_programt::targett epsilon) {
354357

355358
init_state = new_init;
356359

357-
for (unsigned int i = 0; i < old_table.size(); i++) {
360+
for(std::size_t i = 0; i < old_table.size(); i++)
361+
{
358362
transitionst &trans = old_table[i];
359363

360364
for (transitionst::iterator it = trans.begin();
@@ -400,8 +404,10 @@ void automatont::trim() {
400404
tmp.swap(new_states);
401405
} while (!new_states.empty());
402406

403-
for (unsigned int i = 0; i < num_states; i++) {
404-
if (reachable.find(i) == reachable.end()) {
407+
for(std::size_t i = 0; i < num_states; i++)
408+
{
409+
if (reachable.find(i) == reachable.end())
410+
{
405411
transitions[i] = transitionst();
406412
accept_states.erase(i);
407413
}
@@ -443,8 +449,9 @@ void automatont::output(std::ostream &str) {
443449
}
444450
}
445451

446-
unsigned int automatont::count_transitions() {
447-
unsigned int ret = 0;
452+
std::size_t automatont::count_transitions()
453+
{
454+
std::size_t ret = 0;
448455

449456
for (transition_tablet::iterator it = transitions.begin();
450457
it != transitions.end();

src/goto-instrument/accelerate/trace_automaton.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class automatont {
3737
void reverse(goto_programt::targett epsilon);
3838
void trim();
3939

40-
unsigned int count_transitions();
40+
std::size_t count_transitions();
4141

4242
void output(std::ostream &str);
4343

src/goto-instrument/accelerate/util.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,38 @@ typet join_types(const typet &t1, const typet &t2) {
5858
bitvector_typet b1 = to_bitvector_type(t1);
5959
bitvector_typet b2 = to_bitvector_type(t2);
6060

61-
if (is_unsigned(b1) && is_unsigned(b2)) {
61+
if (is_unsigned(b1) && is_unsigned(b2))
62+
{
6263
// We just need to take the max of their widths.
63-
unsigned int width = std::max(b1.get_width(), b2.get_width());
64+
std::size_t width = std::max(b1.get_width(), b2.get_width());
6465
return unsignedbv_typet(width);
65-
} else if(is_signed(b1) && is_signed(b2)) {
66+
}
67+
else if(is_signed(b1) && is_signed(b2))
68+
{
6669
// Again, just need to take the max of the widths.
67-
unsigned int width = std::max(b1.get_width(), b2.get_width());
70+
std::size_t width = std::max(b1.get_width(), b2.get_width());
6871
return signedbv_typet(width);
69-
} else {
72+
}
73+
else
74+
{
7075
// This is the (slightly) tricky case. If we have a signed and an
7176
// unsigned type, we're going to return a signed type. And to cast
7277
// an unsigned type to a signed type, we need the signed type to be
7378
// at least one bit wider than the unsigned type we're casting from.
74-
unsigned int signed_width = is_signed(t1) ? b1.get_width() :
75-
b2.get_width();
76-
unsigned int unsigned_width = is_signed(t1) ? b2.get_width() :
77-
b1.get_width();
79+
std::size_t signed_width = is_signed(t1) ? b1.get_width() :
80+
b2.get_width();
81+
std::size_t unsigned_width = is_signed(t1) ? b2.get_width() :
82+
b1.get_width();
7883
//unsigned_width++;
7984

80-
unsigned int width = std::max(signed_width, unsigned_width);
85+
std::size_t width = std::max(signed_width, unsigned_width);
8186

8287
return signedbv_typet(width);
8388
}
8489
}
8590

86-
std::cerr << "Tried to join types: " << t1.to_string() << " and " <<
87-
t2.to_string() << std::endl;
91+
std::cerr << "Tried to join types: "
92+
<< t1.to_string() << " and " << t2.to_string()
93+
<< std::endl;
8894
assert(!"Couldn't join types");
8995
}

0 commit comments

Comments
 (0)