Skip to content

Use std::size_t #1368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/analyses/escape_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ bool escape_domaint::merge(
{
const std::set<irep_idt> &b_cleanup=cleanup.second.cleanup_functions;
std::set<irep_idt> &a_cleanup=cleanup_map[cleanup.first].cleanup_functions;
unsigned old_size=a_cleanup.size();
auto old_size=a_cleanup.size();
a_cleanup.insert(b_cleanup.begin(), b_cleanup.end());
if(a_cleanup.size()!=old_size)
changed=true;
Expand Down Expand Up @@ -379,7 +379,7 @@ void escape_domaint::check_lhs(
{
// count the aliases

unsigned count=0;
std::size_t count=0;

for(const auto &alias : aliases)
{
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/goto_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ void goto_checkt::integer_overflow_check(
// The overflow checks are binary!
// We break these up.

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

Expand Down
22 changes: 11 additions & 11 deletions src/analyses/invariant_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Author: Daniel Kroening, kroening@kroening.com

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

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

assert(s!="");

unsigned n=map.number(s);
mapt::number_type n=map.number(s);

if(n>=entries.size())
{
Expand Down Expand Up @@ -188,11 +188,11 @@ void invariant_sett::add(
unsigned f_r=eq_set.find(p.first);
unsigned s_r=eq_set.find(p.second);

for(unsigned f=0; f<eq_set.size(); f++)
for(std::size_t f=0; f<eq_set.size(); f++)
{
if(eq_set.find(f)==f_r)
{
for(unsigned s=0; s<eq_set.size(); s++)
for(std::size_t s=0; s<eq_set.size(); s++)
if(eq_set.find(s)==s_r)
dest.insert(std::pair<unsigned, unsigned>(f, s));
}
Expand All @@ -209,7 +209,7 @@ void invariant_sett::add_eq(const std::pair<unsigned, unsigned> &p)
bool constant_seen=false;
mp_integer c;

for(unsigned i=0; i<eq_set.size(); i++)
for(std::size_t i=0; i<eq_set.size(); i++)
{
if(eq_set.find(i)==r)
{
Expand Down Expand Up @@ -319,12 +319,12 @@ void invariant_sett::output(
INVARIANT_STRUCTURED(
object_store!=nullptr, nullptr_exceptiont, "Object store is null");

for(unsigned i=0; i<eq_set.size(); i++)
for(std::size_t i=0; i<eq_set.size(); i++)
if(eq_set.is_root(i) &&
eq_set.count(i)>=2)
{
bool first=true;
for(unsigned j=0; j<eq_set.size(); j++)
for(std::size_t j=0; j<eq_set.size(); j++)
if(eq_set.find(j)==i)
{
if(first)
Expand Down Expand Up @@ -367,7 +367,7 @@ void invariant_sett::add_type_bounds(const exprt &expr, const typet &type)

if(type.id()==ID_unsignedbv)
{
unsigned op_width=to_unsignedbv_type(type).get_width();
std::size_t op_width=to_unsignedbv_type(type).get_width();

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

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

// inequalities
unsigned old_ne_set=ne_set.size();
unsigned old_le_set=le_set.size();
std::size_t old_ne_set=ne_set.size();
std::size_t old_le_set=le_set.size();

intersection(ne_set, other.ne_set);
intersection(le_set, other.le_set);
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/uninitialized_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool uninitialized_domaint::merge(
locationt from,
locationt to)
{
unsigned old_uninitialized=uninitialized.size();
auto old_uninitialized=uninitialized.size();

uninitialized.insert(
other.uninitialized.begin(),
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/c_typecheck_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void c_typecheck_baset::typecheck_asm(codet &code)

typecheck_expr(code.op0());

for(unsigned i=1; i<code.operands().size(); i++)
for(std::size_t i=1; i<code.operands().size(); i++)
{
exprt &list=code.operands()[i];
Forall_operands(it, list)
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2646,7 +2646,7 @@ void c_typecheck_baset::typecheck_function_call_arguments(
throw 0;
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/cbmc/show_vcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void bmct::show_vcc_plain(std::ostream &out)
symex_target_equationt::SSA_stepst::const_iterator
last_it=has_threads?equation.SSA_steps.end():s_it;

for(unsigned count=1; p_it!=last_it; p_it++)
for(std::size_t count=1; p_it!=last_it; p_it++)
if(p_it->is_assume() || p_it->is_assignment() || p_it->is_constraint())
{
if(!p_it->ignore)
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_declarator_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void cpp_declarator_convertert::combine_types(
if(decl_code_type.return_type()==symbol_code_type.return_type() &&
decl_code_type.parameters().size()==symbol_code_type.parameters().size())
{
for(unsigned i=0; i<decl_code_type.parameters().size(); i++)
for(std::size_t i=0; i<decl_code_type.parameters().size(); i++)
{
const code_typet::parametert &decl_parameter=
decl_code_type.parameters()[i];
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_exception_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ irept cpp_exception_list(
cpp_exception_list_rec(src, ns, "", ids);
result.get_sub().resize(ids.size());

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

return result;
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_instantiate_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,13 @@ const symbolt &cpp_typecheckt::instantiate_template(
static_cast<const exprt &>(
template_symbol.value.find("template_methods"));

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

cpp_declarationt method_decl=
static_cast<const cpp_declarationt &>(
static_cast<const irept &>(template_methods.operands()[i]));
static_cast<const irept &>(tm));

// copy the type of the template method
template_typet method_type=
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_internal_additions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ std::string c2cpp(const std::string &s)

result.reserve(s.size());

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

Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ irep_idt cpp_namet::get_base_name() const
const subt &sub=get_sub();

// find last "::"
unsigned base=0;
std::size_t base=0;

for(unsigned i=0; i<sub.size(); i++)
for(std::size_t i=0; i<sub.size(); i++)
{
if(sub[i].id()=="::")
base=i+1;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void cpp_scopet::lookup_identifier(
id_set.insert(this);

#if 0
for(unsigned i=0; i<parents_size(); i++)
for(std::size_t i=0; i<parents_size(); i++)
{
cpp_idt &parent= get_parent(i);
if(parent.identifier == identifier
Expand Down
6 changes: 3 additions & 3 deletions src/cpp/cpp_typecheck_compound_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ void cpp_typecheckt::typecheck_compound_declarator(

// create symbols for the parameters
code_typet::parameterst &args=code_type.parameters();
unsigned i=0;
std::size_t i=0;
for(auto &arg : args)
{
irep_idt base_name=arg.get_base_name();
Expand Down Expand Up @@ -640,7 +640,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
expr_call.arguments().reserve(args.size());
expr_call.arguments().push_back(late_cast);

for(unsigned i=1; i < args.size(); i++)
for(std::size_t i=1; i < args.size(); i++)
{
expr_call.arguments().push_back(
namespacet(symbol_table).lookup(
Expand All @@ -657,7 +657,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
code_func.arguments().reserve(args.size());
code_func.arguments().push_back(late_cast);

for(unsigned i=1; i < args.size(); i++)
for(std::size_t i=1; i < args.size(); i++)
{
code_func.arguments().push_back(
namespacet(symbol_table).lookup(
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_typecheck_virtual_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void cpp_typecheckt::do_virtual_table(const symbolt &symbol)

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

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

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

for(unsigned i=0; i < vt_type.components().size(); i++)
for(std::size_t i=0; i < vt_type.components().size(); i++)
{
const struct_typet::componentt &compo=vt_type.components()[i];
std::map<irep_idt, exprt>::const_iterator cit2 =
Expand Down
10 changes: 5 additions & 5 deletions src/cpp/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class new_scopet
typedef std::map<irep_idt, new_scopet> id_mapt;
id_mapt id_map;

unsigned anon_count;
std::size_t anon_count;

new_scopet *parent;

Expand Down Expand Up @@ -382,7 +382,7 @@ class Parser // NOLINT(readability/identifiers)
bool rMSCuuidof(exprt &);
bool rMSC_if_existsExpr(exprt &);

unsigned number_of_errors;
std::size_t number_of_errors;
irep_idt current_function;

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

cpp_tokent t[ERROR_TOKENS];

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

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

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

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

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

for(unsigned i=0; i < type_name.get_sub().size(); i++)
for(std::size_t i=0; i < type_name.get_sub().size(); i++)
{
if(type_name.get_sub()[i].id() == ID_operator)
{
Expand Down
8 changes: 4 additions & 4 deletions src/goto-instrument/document_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void document_propertiest::strip_space(std::list<linet> &lines)
for(std::list<linet>::const_iterator it=lines.begin();
it!=lines.end(); it++)
{
for(unsigned j=0; j<strip && j<it->text.size(); j++)
for(std::size_t j=0; j<strip && j<it->text.size(); j++)
if(it->text[j]!=' ')
{
strip=j;
Expand All @@ -104,7 +104,7 @@ std::string escape_latex(const std::string &s, bool alltt)
{
std::string dest;

for(unsigned i=0; i<s.size(); i++)
for(std::size_t i=0; i<s.size(); i++)
{
if(s[i]=='\\' || s[i]=='{' || s[i]=='}')
dest+="\\";
Expand All @@ -125,7 +125,7 @@ std::string escape_html(const std::string &s)
{
std::string dest;

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/goto-programs/builtin_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void goto_convertt::do_cpp_new(
new_call.lhs()=tmp_symbol_expr;
new_call.add_source_location()=rhs.source_location();

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

Expand Down
6 changes: 3 additions & 3 deletions src/goto-programs/elf_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in)
number_of_sections=elf32_header.e_shnum;

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

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

bool elf_readert::has_section(const std::string &name) const
{
for(unsigned i=0; i<number_of_sections; i++)
for(std::size_t i=0; i<number_of_sections; i++)
if(section_name(i)==name)
return true;

Expand Down
Loading