From 2a7a0e8993345310afc1eb7d812e1d2126cbd08a Mon Sep 17 00:00:00 2001 From: Daniel Kroening Date: Mon, 11 Sep 2017 16:21:21 +0100 Subject: [PATCH 1/4] the step number needs to be a size_t --- src/goto-programs/goto_trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/goto-programs/goto_trace.h b/src/goto-programs/goto_trace.h index 2153cffb040..08dd5234e76 100644 --- a/src/goto-programs/goto_trace.h +++ b/src/goto-programs/goto_trace.h @@ -35,7 +35,7 @@ Date: July 2005 class goto_trace_stept { public: - unsigned step_nr; + std::size_t step_nr; bool is_assignment() const { return type==typet::ASSIGNMENT; } bool is_assume() const { return type==typet::ASSUME; } From cef76593b43ee06d71032511b926aaed4428ce28 Mon Sep 17 00:00:00 2001 From: Daniel Kroening Date: Mon, 11 Sep 2017 22:02:38 +0100 Subject: [PATCH 2/4] counters need to be size_t --- src/cbmc/show_vcc.cpp | 2 +- src/goto-programs/set_properties.cpp | 8 ++++---- src/goto-symex/symex_function_call.cpp | 2 +- src/util/irep.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cbmc/show_vcc.cpp b/src/cbmc/show_vcc.cpp index 067b22461c3..620ace0bb99 100644 --- a/src/cbmc/show_vcc.cpp +++ b/src/cbmc/show_vcc.cpp @@ -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) diff --git a/src/goto-programs/set_properties.cpp b/src/goto-programs/set_properties.cpp index 43c9ea9107c..a79802118ba 100644 --- a/src/goto-programs/set_properties.cpp +++ b/src/goto-programs/set_properties.cpp @@ -45,7 +45,7 @@ void label_properties(goto_modelt &goto_model) void label_properties( goto_programt &goto_program, - std::map &property_counters) + std::map &property_counters) { for(goto_programt::instructionst::iterator it=goto_program.instructions.begin(); @@ -75,7 +75,7 @@ void label_properties( if(prefix!="") prefix+="."; - unsigned &count=property_counters[prefix]; + std::size_t &count=property_counters[prefix]; count++; @@ -87,7 +87,7 @@ void label_properties( void label_properties(goto_programt &goto_program) { - std::map property_counters; + std::map property_counters; label_properties(goto_program, property_counters); } @@ -116,7 +116,7 @@ void set_properties( void label_properties(goto_functionst &goto_functions) { - std::map property_counters; + std::map property_counters; for(goto_functionst::function_mapt::iterator it=goto_functions.function_map.begin(); diff --git a/src/goto-symex/symex_function_call.cpp b/src/goto-symex/symex_function_call.cpp index 06d519e4941..2a3c4a86dd1 100644 --- a/src/goto-symex/symex_function_call.cpp +++ b/src/goto-symex/symex_function_call.cpp @@ -138,7 +138,7 @@ void goto_symext::parameter_assignments( if(function_type.has_ellipsis()) { // These are va_arg arguments; their types may differ from call to call - unsigned va_count=0; + std::size_t va_count=0; const symbolt *va_sym=nullptr; while(!ns.lookup( id2string(function_identifier)+"::va_arg"+std::to_string(va_count), diff --git a/src/util/irep.cpp b/src/util/irep.cpp index 96c92b6174d..af2f3f18831 100644 --- a/src/util/irep.cpp +++ b/src/util/irep.cpp @@ -675,7 +675,7 @@ std::string irept::pretty(unsigned indent, unsigned max_indent) const result+=it->second.pretty(indent+2, max_indent); } - unsigned count=0; + std::size_t count=0; forall_irep(it, get_sub()) { From 69a8eaf81d0d4659eda94b872c00b7cb1d33c6f3 Mon Sep 17 00:00:00 2001 From: Daniel Kroening Date: Sat, 16 Sep 2017 09:46:09 +0100 Subject: [PATCH 3/4] use std::size_t for container indices --- src/analyses/escape_analysis.cpp | 4 +-- src/analyses/goto_check.cpp | 2 +- src/analyses/invariant_set.cpp | 22 ++++++------ src/analyses/uninitialized_domain.cpp | 2 +- src/ansi-c/c_typecheck_code.cpp | 2 +- src/ansi-c/c_typecheck_expr.cpp | 2 +- src/cpp/cpp_declarator_converter.cpp | 2 +- src/cpp/cpp_exception_id.cpp | 2 +- src/cpp/cpp_instantiate_template.cpp | 4 +-- src/cpp/cpp_internal_additions.cpp | 2 +- src/cpp/cpp_name.cpp | 4 +-- src/cpp/cpp_scope.cpp | 2 +- src/cpp/cpp_typecheck_compound_type.cpp | 6 ++-- src/cpp/cpp_typecheck_virtual_table.cpp | 4 +-- src/cpp/parse.cpp | 10 +++--- src/goto-instrument/document_properties.cpp | 8 ++--- src/goto-programs/builtin_functions.cpp | 2 +- src/goto-programs/elf_reader.cpp | 6 ++-- src/goto-programs/elf_reader.h | 10 +++--- src/goto-programs/goto_convert.cpp | 4 +-- src/goto-programs/goto_convert_exceptions.cpp | 2 +- .../remove_function_pointers.cpp | 4 +-- src/goto-programs/remove_vector.cpp | 4 +-- src/goto-programs/string_instrumentation.cpp | 24 ++++++------- src/goto-symex/symex_builtin_functions.cpp | 8 ++--- src/goto-symex/symex_target_equation.cpp | 4 +-- src/goto-symex/symex_target_equation.h | 10 +++--- .../java_local_variable_table.cpp | 4 ++- .../goto_program_dereference.cpp | 4 +-- src/pointer-analysis/value_set.cpp | 2 +- src/pointer-analysis/value_set_fi.cpp | 6 ++-- src/pointer-analysis/value_set_fivr.cpp | 10 +++--- src/pointer-analysis/value_set_fivrns.cpp | 6 ++-- src/util/base_type.cpp | 4 +-- src/util/cmdline.cpp | 4 +-- src/util/config.h | 36 +++++++++---------- src/util/json_expr.cpp | 4 +-- src/util/lispexpr.cpp | 4 +-- src/util/lispirep.cpp | 2 +- src/util/mp_arith.cpp | 2 +- 40 files changed, 122 insertions(+), 122 deletions(-) diff --git a/src/analyses/escape_analysis.cpp b/src/analyses/escape_analysis.cpp index b0129dfd0a6..507df39f770 100644 --- a/src/analyses/escape_analysis.cpp +++ b/src/analyses/escape_analysis.cpp @@ -319,7 +319,7 @@ bool escape_domaint::merge( { const std::set &b_cleanup=cleanup.second.cleanup_functions; std::set &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; @@ -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) { diff --git a/src/analyses/goto_check.cpp b/src/analyses/goto_check.cpp index b6ee194dd9f..95345814426 100644 --- a/src/analyses/goto_check.cpp +++ b/src/analyses/goto_check.cpp @@ -572,7 +572,7 @@ void goto_checkt::integer_overflow_check( // The overflow checks are binary! // We break these up. - for(unsigned i=1; i=entries.size()) { @@ -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(f, s)); } @@ -209,7 +209,7 @@ void invariant_sett::add_eq(const std::pair &p) bool constant_seen=false; mp_integer c; - for(unsigned i=0; i=2) { bool first=true; - for(unsigned j=0; jget_expr(i); @@ -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); diff --git a/src/analyses/uninitialized_domain.cpp b/src/analyses/uninitialized_domain.cpp index 48830ed204e..4f92eaebd49 100644 --- a/src/analyses/uninitialized_domain.cpp +++ b/src/analyses/uninitialized_domain.cpp @@ -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(), diff --git a/src/ansi-c/c_typecheck_code.cpp b/src/ansi-c/c_typecheck_code.cpp index 9715fc2e4d3..a45420839a4 100644 --- a/src/ansi-c/c_typecheck_code.cpp +++ b/src/ansi-c/c_typecheck_code.cpp @@ -151,7 +151,7 @@ void c_typecheck_baset::typecheck_asm(codet &code) typecheck_expr(code.op0()); - for(unsigned i=1; i( template_symbol.value.find("template_methods")); - for(unsigned i=0; i( - static_cast(template_methods.operands()[i])); + static_cast(tm)); // copy the type of the template method template_typet method_type= diff --git a/src/cpp/cpp_internal_additions.cpp b/src/cpp/cpp_internal_additions.cpp index 78384905a83..a193742643e 100644 --- a/src/cpp/cpp_internal_additions.cpp +++ b/src/cpp/cpp_internal_additions.cpp @@ -20,7 +20,7 @@ std::string c2cpp(const std::string &s) result.reserve(s.size()); - for(unsigned i=0; i::const_iterator cit2 = diff --git a/src/cpp/parse.cpp b/src/cpp/parse.cpp index 1cb4bfbe651..4de000d02eb 100644 --- a/src/cpp/parse.cpp +++ b/src/cpp/parse.cpp @@ -139,7 +139,7 @@ class new_scopet typedef std::map id_mapt; id_mapt id_map; - unsigned anon_count; + std::size_t anon_count; new_scopet *parent; @@ -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); @@ -488,7 +488,7 @@ bool Parser::SyntaxError() cpp_tokent t[ERROR_TOKENS]; - for(unsigned i=0; i &lines) for(std::list::const_iterator it=lines.begin(); it!=lines.end(); it++) { - for(unsigned j=0; jtext.size(); j++) + for(std::size_t j=0; jtext.size(); j++) if(it->text[j]!=' ') { strip=j; @@ -104,7 +104,7 @@ std::string escape_latex(const std::string &s, bool alltt) { std::string dest; - for(unsigned i=0; igoto_stack.size()) stack_is_prefix=false; - for(unsigned i=0, ilim=label_stack.size(); + for(std::size_t i=0, ilim=label_stack.size(); i!=ilim && stack_is_prefix; ++i) { @@ -2189,7 +2189,7 @@ void goto_convert( goto_programt &dest, message_handlert &message_handler) { - const unsigned errors_before= + const std::size_t errors_before= message_handler.get_message_count(messaget::M_ERROR); goto_convertt goto_convert(symbol_table, message_handler); diff --git a/src/goto-programs/goto_convert_exceptions.cpp b/src/goto-programs/goto_convert_exceptions.cpp index f34d4d2f3fa..d51a16c13ad 100644 --- a/src/goto-programs/goto_convert_exceptions.cpp +++ b/src/goto-programs/goto_convert_exceptions.cpp @@ -127,7 +127,7 @@ void goto_convertt::convert_try_catch( // add a goto to the end of the 'try' block dest.add_instruction()->make_goto(end_target); - for(unsigned i=1; isource_location.set_comment(comment); - for(unsigned i=2; i args; - for(unsigned i=1; i args; - for(unsigned i=1; i args; - for(unsigned i=1; i SSA_stepst; SSA_stepst SSA_steps; - SSA_stepst::iterator get_SSA_step(unsigned s) + SSA_stepst::iterator get_SSA_step(std::size_t s) { SSA_stepst::iterator it=SSA_steps.begin(); for(; s!=0; s--) diff --git a/src/java_bytecode/java_local_variable_table.cpp b/src/java_bytecode/java_local_variable_table.cpp index e50e96f41d3..4561d24086f 100644 --- a/src/java_bytecode/java_local_variable_table.cpp +++ b/src/java_bytecode/java_local_variable_table.cpp @@ -86,10 +86,12 @@ struct procedure_local_cfg_baset< { return args.second.begin()->first; } + unsigned get_last_node(const method_with_amapt &args) const { return (--args.second.end())->first; } + unsigned nodes_empty(const method_with_amapt &args) const { return args.second.empty(); @@ -485,7 +487,7 @@ static void populate_live_range_holes( merge_into, expanded_live_range_start, sorted_by_startpc[0]->var.start_pc); - for(unsigned idx=0; idx &cmdlinet::get_values( int cmdlinet::getoptnr(char option) const { - for(unsigned i=0; i Date: Sun, 17 Sep 2017 16:15:53 +0100 Subject: [PATCH 4/4] prefer a ranged for over indexed iteration --- src/goto-symex/symex_function_call.cpp | 4 ++-- src/java_bytecode/java_types.cpp | 6 +++--- src/langapi/language_ui.cpp | 6 ++---- src/memory-models/mm2cpp.cpp | 3 +-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/goto-symex/symex_function_call.cpp b/src/goto-symex/symex_function_call.cpp index 2a3c4a86dd1..6dc9a944010 100644 --- a/src/goto-symex/symex_function_call.cpp +++ b/src/goto-symex/symex_function_call.cpp @@ -282,8 +282,8 @@ void goto_symext::symex_function_call_code( // read the arguments -- before the locality renaming exprt::operandst arguments=call.arguments(); - for(unsigned i=0; i