Skip to content

Commit c24b008

Browse files
author
Remi Delmas
committed
CONTRACTS: use size_t for assigns clause size
1 parent 6822adb commit c24b008

9 files changed

+15
-16
lines changed

src/goto-instrument/contracts/dynamic-frames/dfcc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ dfcct::dfcct(goto_modelt &goto_model, messaget &log)
113113
instrument,
114114
spec_functions,
115115
dsl_contract_handler),
116-
max_assigns_clause_size(-1)
116+
max_assigns_clause_size(0)
117117
{
118118
}
119119

@@ -333,7 +333,7 @@ void dfcct::transform_goto_model(
333333
other_symbols.erase(wrapper_id);
334334

335335
// upate max contract size
336-
const int assigns_clause_size =
336+
const std::size_t assigns_clause_size =
337337
dsl_contract_handler.get_assigns_clause_size(contract_id);
338338
if(assigns_clause_size > max_assigns_clause_size)
339339
max_assigns_clause_size = assigns_clause_size;

src/goto-instrument/contracts/dynamic-frames/dfcc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class dfcct
196196

197197
/// Tracks the maximum number of targets in any assigns clause handled in the
198198
/// transformation (used to specialize/unwind loops in DFCC library functions)
199-
int max_assigns_clause_size;
199+
std::size_t max_assigns_clause_size;
200200

201201
/// Checks preconditions on arguments of \ref transform_goto_model.
202202
///

src/goto-instrument/contracts/dynamic-frames/dfcc_contract_handler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ class dfcc_contract_handlert
7171

7272
/// Returns the size of the assigns clause of the given contract_id
7373
/// in number of targets.
74-
virtual const int get_assigns_clause_size(const irep_idt &contract_id) = 0;
74+
virtual const std::size_t
75+
get_assigns_clause_size(const irep_idt &contract_id) = 0;
7576
};
7677

7778
#endif

src/goto-instrument/contracts/dynamic-frames/dfcc_dsl_contract_functions.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ dfcc_dsl_contract_functionst::get_spec_frees_function_symbol() const
8383
return ns.lookup(spec_frees_function_id);
8484
}
8585

86-
const int dfcc_dsl_contract_functionst::get_nof_assigns_targets() const
86+
const std::size_t dfcc_dsl_contract_functionst::get_nof_assigns_targets() const
8787
{
8888
return nof_assigns_targets;
8989
}
9090

91-
const int dfcc_dsl_contract_functionst::get_nof_frees_targets() const
91+
const std::size_t dfcc_dsl_contract_functionst::get_nof_frees_targets() const
9292
{
9393
return nof_frees_targets;
9494
}
@@ -118,10 +118,8 @@ void dfcc_dsl_contract_functionst::gen_spec_assigns_function()
118118
{
119119
// use a dummy symbol for __CPROVER_return_value
120120
// which does occur in the assigns clause anyway
121-
symbolt dummy;
122-
dummy.name = "dummy_return_value";
123-
dummy.type = code_with_contract.return_type();
124-
lambda_parameters.push_back(dummy.symbol_expr());
121+
lambda_parameters.push_back(
122+
symbol_exprt("dummy_return_value", code_with_contract.return_type()));
125123
}
126124

127125
for(const auto &param_id : spec_code_type.parameter_identifiers())

src/goto-instrument/contracts/dynamic-frames/dfcc_dsl_contract_functions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ class dfcc_dsl_contract_functionst
8787
const symbolt &get_spec_frees_function_symbol() const;
8888

8989
/// Returns the maximum number of targets in the assigns clause
90-
const int get_nof_assigns_targets() const;
90+
const std::size_t get_nof_assigns_targets() const;
9191

9292
/// Returns the maximum number of targets in the frees clause
93-
const int get_nof_frees_targets() const;
93+
const std::size_t get_nof_frees_targets() const;
9494

9595
/// The function symbol carrying the contract
9696
const symbolt &pure_contract_symbol;

src/goto-instrument/contracts/dynamic-frames/dfcc_dsl_contract_handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ dfcc_dsl_contract_handlert::get_contract_functions(const irep_idt &contract_id)
7575
return dfcc_dsl_contract_handlert::contract_cache.at(contract_id);
7676
}
7777

78-
const int
78+
const std::size_t
7979
dfcc_dsl_contract_handlert::get_assigns_clause_size(const irep_idt &contract_id)
8080
{
8181
return get_contract_functions(contract_id).get_nof_assigns_targets();

src/goto-instrument/contracts/dynamic-frames/dfcc_dsl_contract_handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class dfcc_dsl_contract_handlert : public dfcc_contract_handlert
9696
std::set<irep_idt> &function_pointer_contracts) override;
9797

9898
/// Returns the size assigns clause of the given contract in number of targets
99-
const int get_assigns_clause_size(const irep_idt &contract_id) override;
99+
const std::size_t get_assigns_clause_size(const irep_idt &contract_id) override;
100100

101101
/// Searches for a symbol named "contract::contract_id" that has a type
102102
/// signature compatible with that of "contract_id", or creates an empty one

src/goto-instrument/contracts/dynamic-frames/dfcc_library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ static const std::map<dfcc_funt, int> to_unwind = {
413413

414414
bool dfcc_libraryt::specialized = false;
415415

416-
void dfcc_libraryt::specialize(const int contract_assigns_size)
416+
void dfcc_libraryt::specialize(const std::size_t contract_assigns_size)
417417
{
418418
log.debug() << "->dfcc_libraryt::specialize(" << contract_assigns_size << ") "
419419
<< messaget::eom;

src/goto-instrument/contracts/dynamic-frames/dfcc_library.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class dfcc_libraryt
204204
/// Specializes the library by unwinding loops in library functions
205205
/// to the given assigns clause size.
206206
/// \param contract_assigns_size_hint size of the assigns clause being checked
207-
void specialize(const int contract_assigns_size_hint);
207+
void specialize(const std::size_t contract_assigns_size_hint);
208208

209209
/// Adds an ASSERT(false) body to all front-end functions
210210
/// __CPROVER_object_whole

0 commit comments

Comments
 (0)