Skip to content

Commit 69a8eaf

Browse files
author
Daniel Kroening
committed
use std::size_t for container indices
1 parent cef7659 commit 69a8eaf

40 files changed

+122
-122
lines changed

src/analyses/escape_analysis.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ bool escape_domaint::merge(
319319
{
320320
const std::set<irep_idt> &b_cleanup=cleanup.second.cleanup_functions;
321321
std::set<irep_idt> &a_cleanup=cleanup_map[cleanup.first].cleanup_functions;
322-
unsigned old_size=a_cleanup.size();
322+
auto old_size=a_cleanup.size();
323323
a_cleanup.insert(b_cleanup.begin(), b_cleanup.end());
324324
if(a_cleanup.size()!=old_size)
325325
changed=true;
@@ -379,7 +379,7 @@ void escape_domaint::check_lhs(
379379
{
380380
// count the aliases
381381

382-
unsigned count=0;
382+
std::size_t count=0;
383383

384384
for(const auto &alias : aliases)
385385
{

src/analyses/goto_check.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ void goto_checkt::integer_overflow_check(
572572
// The overflow checks are binary!
573573
// We break these up.
574574

575-
for(unsigned i=1; i<expr.operands().size(); i++)
575+
for(std::size_t i=1; i<expr.operands().size(); i++)
576576
{
577577
exprt tmp;
578578

src/analyses/invariant_set.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Author: Daniel Kroening, kroening@kroening.com
2727

2828
void inv_object_storet::output(std::ostream &out) const
2929
{
30-
for(unsigned i=0; i<entries.size(); i++)
30+
for(std::size_t i=0; i<entries.size(); i++)
3131
out << "STORE " << i << ": " << to_string(i, "") << '\n';
3232
}
3333

@@ -61,7 +61,7 @@ unsigned inv_object_storet::add(const exprt &expr)
6161

6262
assert(s!="");
6363

64-
unsigned n=map.number(s);
64+
mapt::number_type n=map.number(s);
6565

6666
if(n>=entries.size())
6767
{
@@ -188,11 +188,11 @@ void invariant_sett::add(
188188
unsigned f_r=eq_set.find(p.first);
189189
unsigned s_r=eq_set.find(p.second);
190190

191-
for(unsigned f=0; f<eq_set.size(); f++)
191+
for(std::size_t f=0; f<eq_set.size(); f++)
192192
{
193193
if(eq_set.find(f)==f_r)
194194
{
195-
for(unsigned s=0; s<eq_set.size(); s++)
195+
for(std::size_t s=0; s<eq_set.size(); s++)
196196
if(eq_set.find(s)==s_r)
197197
dest.insert(std::pair<unsigned, unsigned>(f, s));
198198
}
@@ -209,7 +209,7 @@ void invariant_sett::add_eq(const std::pair<unsigned, unsigned> &p)
209209
bool constant_seen=false;
210210
mp_integer c;
211211

212-
for(unsigned i=0; i<eq_set.size(); i++)
212+
for(std::size_t i=0; i<eq_set.size(); i++)
213213
{
214214
if(eq_set.find(i)==r)
215215
{
@@ -319,12 +319,12 @@ void invariant_sett::output(
319319
INVARIANT_STRUCTURED(
320320
object_store!=nullptr, nullptr_exceptiont, "Object store is null");
321321

322-
for(unsigned i=0; i<eq_set.size(); i++)
322+
for(std::size_t i=0; i<eq_set.size(); i++)
323323
if(eq_set.is_root(i) &&
324324
eq_set.count(i)>=2)
325325
{
326326
bool first=true;
327-
for(unsigned j=0; j<eq_set.size(); j++)
327+
for(std::size_t j=0; j<eq_set.size(); j++)
328328
if(eq_set.find(j)==i)
329329
{
330330
if(first)
@@ -367,7 +367,7 @@ void invariant_sett::add_type_bounds(const exprt &expr, const typet &type)
367367

368368
if(type.id()==ID_unsignedbv)
369369
{
370-
unsigned op_width=to_unsignedbv_type(type).get_width();
370+
std::size_t op_width=to_unsignedbv_type(type).get_width();
371371

372372
if(op_width<=8)
373373
{
@@ -852,7 +852,7 @@ exprt invariant_sett::get_constant(const exprt &expr) const
852852
unsigned r=eq_set.find(a);
853853

854854
// is it a constant?
855-
for(unsigned i=0; i<eq_set.size(); i++)
855+
for(std::size_t i=0; i<eq_set.size(); i++)
856856
if(eq_set.find(i)==r)
857857
{
858858
const exprt &e=object_store->get_expr(i);
@@ -938,8 +938,8 @@ bool invariant_sett::make_union(const invariant_sett &other)
938938
eq_set.intersection(other.eq_set);
939939

940940
// inequalities
941-
unsigned old_ne_set=ne_set.size();
942-
unsigned old_le_set=le_set.size();
941+
std::size_t old_ne_set=ne_set.size();
942+
std::size_t old_le_set=le_set.size();
943943

944944
intersection(ne_set, other.ne_set);
945945
intersection(le_set, other.le_set);

src/analyses/uninitialized_domain.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ bool uninitialized_domaint::merge(
8181
locationt from,
8282
locationt to)
8383
{
84-
unsigned old_uninitialized=uninitialized.size();
84+
auto old_uninitialized=uninitialized.size();
8585

8686
uninitialized.insert(
8787
other.uninitialized.begin(),

src/ansi-c/c_typecheck_code.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void c_typecheck_baset::typecheck_asm(codet &code)
151151

152152
typecheck_expr(code.op0());
153153

154-
for(unsigned i=1; i<code.operands().size(); i++)
154+
for(std::size_t i=1; i<code.operands().size(); i++)
155155
{
156156
exprt &list=code.operands()[i];
157157
Forall_operands(it, list)

src/ansi-c/c_typecheck_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,7 @@ void c_typecheck_baset::typecheck_function_call_arguments(
26462646
throw 0;
26472647
}
26482648

2649-
for(unsigned i=0; i<arguments.size(); i++)
2649+
for(std::size_t i=0; i<arguments.size(); i++)
26502650
{
26512651
exprt &op=arguments[i];
26522652

src/cpp/cpp_declarator_converter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ void cpp_declarator_convertert::combine_types(
252252
if(decl_code_type.return_type()==symbol_code_type.return_type() &&
253253
decl_code_type.parameters().size()==symbol_code_type.parameters().size())
254254
{
255-
for(unsigned i=0; i<decl_code_type.parameters().size(); i++)
255+
for(std::size_t i=0; i<decl_code_type.parameters().size(); i++)
256256
{
257257
const code_typet::parametert &decl_parameter=
258258
decl_code_type.parameters()[i];

src/cpp/cpp_exception_id.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ irept cpp_exception_list(
7878
cpp_exception_list_rec(src, ns, "", ids);
7979
result.get_sub().resize(ids.size());
8080

81-
for(unsigned i=0; i<ids.size(); i++)
81+
for(std::size_t i=0; i<ids.size(); i++)
8282
result.get_sub()[i].id(ids[i]);
8383

8484
return result;

src/cpp/cpp_instantiate_template.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,13 @@ const symbolt &cpp_typecheckt::instantiate_template(
415415
static_cast<const exprt &>(
416416
template_symbol.value.find("template_methods"));
417417

418-
for(unsigned i=0; i<template_methods.operands().size(); i++)
418+
for(auto &tm : template_methods.operands())
419419
{
420420
cpp_saved_scope.restore();
421421

422422
cpp_declarationt method_decl=
423423
static_cast<const cpp_declarationt &>(
424-
static_cast<const irept &>(template_methods.operands()[i]));
424+
static_cast<const irept &>(tm));
425425

426426
// copy the type of the template method
427427
template_typet method_type=

src/cpp/cpp_internal_additions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ std::string c2cpp(const std::string &s)
2020

2121
result.reserve(s.size());
2222

23-
for(unsigned i=0; i<s.size(); i++)
23+
for(std::size_t i=0; i<s.size(); i++)
2424
{
2525
char ch=s[i];
2626

src/cpp/cpp_name.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ irep_idt cpp_namet::get_base_name() const
1919
const subt &sub=get_sub();
2020

2121
// find last "::"
22-
unsigned base=0;
22+
std::size_t base=0;
2323

24-
for(unsigned i=0; i<sub.size(); i++)
24+
for(std::size_t i=0; i<sub.size(); i++)
2525
{
2626
if(sub[i].id()=="::")
2727
base=i+1;

src/cpp/cpp_scope.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void cpp_scopet::lookup_identifier(
187187
id_set.insert(this);
188188

189189
#if 0
190-
for(unsigned i=0; i<parents_size(); i++)
190+
for(std::size_t i=0; i<parents_size(); i++)
191191
{
192192
cpp_idt &parent= get_parent(i);
193193
if(parent.identifier == identifier

src/cpp/cpp_typecheck_compound_type.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
599599

600600
// create symbols for the parameters
601601
code_typet::parameterst &args=code_type.parameters();
602-
unsigned i=0;
602+
std::size_t i=0;
603603
for(auto &arg : args)
604604
{
605605
irep_idt base_name=arg.get_base_name();
@@ -640,7 +640,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
640640
expr_call.arguments().reserve(args.size());
641641
expr_call.arguments().push_back(late_cast);
642642

643-
for(unsigned i=1; i < args.size(); i++)
643+
for(std::size_t i=1; i < args.size(); i++)
644644
{
645645
expr_call.arguments().push_back(
646646
namespacet(symbol_table).lookup(
@@ -657,7 +657,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
657657
code_func.arguments().reserve(args.size());
658658
code_func.arguments().push_back(late_cast);
659659

660-
for(unsigned i=1; i < args.size(); i++)
660+
for(std::size_t i=1; i < args.size(); i++)
661661
{
662662
code_func.arguments().push_back(
663663
namespacet(symbol_table).lookup(

src/cpp/cpp_typecheck_virtual_table.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void cpp_typecheckt::do_virtual_table(const symbolt &symbol)
2323

2424
const struct_typet &struct_type=to_struct_type(symbol.type);
2525

26-
for(unsigned i=0; i < struct_type.components().size(); i++)
26+
for(std::size_t i=0; i < struct_type.components().size(); i++)
2727
{
2828
const struct_typet::componentt &compo=struct_type.components()[i];
2929
if(!compo.get_bool("is_virtual"))
@@ -83,7 +83,7 @@ void cpp_typecheckt::do_virtual_table(const symbolt &symbol)
8383

8484
exprt values(ID_struct, symbol_typet(vt_symb_type.name));
8585

86-
for(unsigned i=0; i < vt_type.components().size(); i++)
86+
for(std::size_t i=0; i < vt_type.components().size(); i++)
8787
{
8888
const struct_typet::componentt &compo=vt_type.components()[i];
8989
std::map<irep_idt, exprt>::const_iterator cit2 =

src/cpp/parse.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class new_scopet
139139
typedef std::map<irep_idt, new_scopet> id_mapt;
140140
id_mapt id_map;
141141

142-
unsigned anon_count;
142+
std::size_t anon_count;
143143

144144
new_scopet *parent;
145145

@@ -382,7 +382,7 @@ class Parser // NOLINT(readability/identifiers)
382382
bool rMSCuuidof(exprt &);
383383
bool rMSC_if_existsExpr(exprt &);
384384

385-
unsigned number_of_errors;
385+
std::size_t number_of_errors;
386386
irep_idt current_function;
387387

388388
void merge_types(const typet &src, typet &dest);
@@ -488,7 +488,7 @@ bool Parser::SyntaxError()
488488

489489
cpp_tokent t[ERROR_TOKENS];
490490

491-
for(unsigned i=0; i<ERROR_TOKENS; i++)
491+
for(std::size_t i=0; i<ERROR_TOKENS; i++)
492492
lex.LookAhead(i, t[i]);
493493

494494
if(t[0].kind!='\0')
@@ -499,7 +499,7 @@ bool Parser::SyntaxError()
499499

500500
std::string message="parse error before `";
501501

502-
for(unsigned i=0; i<ERROR_TOKENS; i++)
502+
for(std::size_t i=0; i<ERROR_TOKENS; i++)
503503
if(t[i].kind!='\0')
504504
{
505505
if(i!=0)
@@ -1695,7 +1695,7 @@ bool Parser::rOtherDeclaration(
16951695

16961696
assert(!type_name.get_sub().empty());
16971697

1698-
for(unsigned i=0; i < type_name.get_sub().size(); i++)
1698+
for(std::size_t i=0; i < type_name.get_sub().size(); i++)
16991699
{
17001700
if(type_name.get_sub()[i].id() == ID_operator)
17011701
{

src/goto-instrument/document_properties.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void document_propertiest::strip_space(std::list<linet> &lines)
7878
for(std::list<linet>::const_iterator it=lines.begin();
7979
it!=lines.end(); it++)
8080
{
81-
for(unsigned j=0; j<strip && j<it->text.size(); j++)
81+
for(std::size_t j=0; j<strip && j<it->text.size(); j++)
8282
if(it->text[j]!=' ')
8383
{
8484
strip=j;
@@ -104,7 +104,7 @@ std::string escape_latex(const std::string &s, bool alltt)
104104
{
105105
std::string dest;
106106

107-
for(unsigned i=0; i<s.size(); i++)
107+
for(std::size_t i=0; i<s.size(); i++)
108108
{
109109
if(s[i]=='\\' || s[i]=='{' || s[i]=='}')
110110
dest+="\\";
@@ -125,7 +125,7 @@ std::string escape_html(const std::string &s)
125125
{
126126
std::string dest;
127127

128-
for(unsigned i=0; i<s.size(); i++)
128+
for(std::size_t i=0; i<s.size(); i++)
129129
{
130130
switch(s[i])
131131
{
@@ -141,7 +141,7 @@ std::string escape_html(const std::string &s)
141141

142142
bool is_empty(const std::string &s)
143143
{
144-
for(unsigned i=0; i<s.size(); i++)
144+
for(std::size_t i=0; i<s.size(); i++)
145145
if(isgraph(s[i]))
146146
return false;
147147

src/goto-programs/builtin_functions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ void goto_convertt::do_cpp_new(
514514
new_call.lhs()=tmp_symbol_expr;
515515
new_call.add_source_location()=rhs.source_location();
516516

517-
for(unsigned i=0; i<code_type.parameters().size(); i++)
517+
for(std::size_t i=0; i<code_type.parameters().size(); i++)
518518
if(new_call.arguments()[i].type()!=code_type.parameters()[i].type())
519519
new_call.arguments()[i].make_typecast(code_type.parameters()[i].type());
520520

src/goto-programs/elf_reader.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in)
5454
number_of_sections=elf32_header.e_shnum;
5555

5656
// iterate over these
57-
for(unsigned i=0; i<elf32_section_header_table.size(); i++)
57+
for(std::size_t i=0; i<elf32_section_header_table.size(); i++)
5858
{
5959
// go to right place
6060
in.seekg(elf32_header.e_shoff+i*elf32_header.e_shentsize);
@@ -101,7 +101,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in)
101101
number_of_sections=elf64_header.e_shnum;
102102

103103
// iterate over these
104-
for(unsigned i=0; i<elf64_section_header_table.size(); i++)
104+
for(std::size_t i=0; i<elf64_section_header_table.size(); i++)
105105
{
106106
// go to right place
107107
in.seekg(elf64_header.e_shoff+i*elf64_header.e_shentsize);
@@ -141,7 +141,7 @@ std::string elf_readert::get_string(std::streampos index) const
141141

142142
bool elf_readert::has_section(const std::string &name) const
143143
{
144-
for(unsigned i=0; i<number_of_sections; i++)
144+
for(std::size_t i=0; i<number_of_sections; i++)
145145
if(section_name(i)==name)
146146
return true;
147147

src/goto-programs/elf_reader.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -122,26 +122,26 @@ class elf_readert
122122
std::streampos string_table_offset;
123123
std::string get_string(std::streampos index) const;
124124

125-
std::string elf32_section_name(unsigned index) const
125+
std::string elf32_section_name(std::size_t index) const
126126
{
127127
return get_string(elf32_section_header_table[index].sh_name);
128128
}
129129

130-
std::string elf64_section_name(unsigned index) const
130+
std::string elf64_section_name(std::size_t index) const
131131
{
132132
return get_string(elf64_section_header_table[index].sh_name);
133133
}
134134

135-
unsigned number_of_sections;
135+
std::size_t number_of_sections;
136136

137-
std::string section_name(unsigned index) const
137+
std::string section_name(std::size_t index) const
138138
{
139139
return
140140
elf_class==ELF32?elf32_section_name(index):
141141
elf64_section_name(index);
142142
}
143143

144-
std::streampos section_offset(unsigned index) const
144+
std::streampos section_offset(std::size_t index) const
145145
{
146146
return
147147
elf_class==ELF32?elf32_section_header_table[index].sh_offset:

0 commit comments

Comments
 (0)