Skip to content

Commit f7f5660

Browse files
committed
Replace requires with c_requires
Fixes #7675
1 parent fa60087 commit f7f5660

File tree

10 files changed

+36
-30
lines changed

10 files changed

+36
-30
lines changed

src/ansi-c/ansi_c_convert_type.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void ansi_c_convert_typet::read_rec(const typet &type)
250250
{
251251
const exprt &as_expr =
252252
static_cast<const exprt &>(static_cast<const irept &>(type));
253-
requires.push_back(to_unary_expr(as_expr).op());
253+
c_requires.push_back(to_unary_expr(as_expr).op());
254254
}
255255
else if(type.id() == ID_C_spec_assigns)
256256
{
@@ -322,8 +322,8 @@ void ansi_c_convert_typet::write(typet &type)
322322
type.swap(other.front());
323323

324324
// the contract expressions are meant for function types only
325-
if(!requires.empty())
326-
to_code_with_contract_type(type).requires() = std::move(requires);
325+
if(!c_requires.empty())
326+
to_code_with_contract_type(type).c_requires() = std::move(c_requires);
327327

328328
if(!assigns.empty())
329329
to_code_with_contract_type(type).assigns() = std::move(assigns);

src/ansi-c/ansi_c_convert_type.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ansi_c_convert_typet
4848
bool constructor, destructor;
4949

5050
// contracts
51-
exprt::operandst assigns, frees, ensures, requires;
51+
exprt::operandst assigns, frees, ensures, c_requires;
5252

5353
// storage spec
5454
c_storage_spect c_storage_spec;

src/ansi-c/c_typecheck_base.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -905,16 +905,16 @@ void c_typecheck_baset::typecheck_declaration(
905905
parameter_identifier, p.type());
906906
}
907907

908-
for(auto &requires : code_type.requires())
908+
for(auto &c_requires : code_type.c_requires())
909909
{
910-
typecheck_expr(requires);
911-
implicit_typecast_bool(requires);
910+
typecheck_expr(c_requires);
911+
implicit_typecast_bool(c_requires);
912912
std::string clause_type = "preconditions";
913-
check_history_expr_return_value(requires, clause_type);
914-
check_was_freed(requires, clause_type);
915-
lambda_exprt lambda{temporary_parameter_symbols, requires};
916-
lambda.add_source_location() = requires.source_location();
917-
requires.swap(lambda);
913+
check_history_expr_return_value(c_requires, clause_type);
914+
check_was_freed(c_requires, clause_type);
915+
lambda_exprt lambda{temporary_parameter_symbols, c_requires};
916+
lambda.add_source_location() = c_requires.source_location();
917+
c_requires.swap(lambda);
918918
}
919919

920920
typecheck_spec_assigns(code_type.assigns());

src/cprover/instrument_contracts.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ void instrument_contract_checks(
286286
goto_programt add_at_beginning;
287287

288288
// precondition?
289-
if(!contract.requires().empty())
289+
if(!contract.c_requires().empty())
290290
{
291291
// stick these in as assumptions, preserving the ordering
292292
goto_programt dest;
293-
for(auto &assumption : contract.requires())
293+
for(auto &assumption : contract.c_requires())
294294
{
295295
exprt assumption_instance = instantiate_contract_lambda(assumption);
296296
auto fixed_assumption = add_function(f.first, assumption_instance);
@@ -338,7 +338,7 @@ void instrument_contract_checks(
338338

339339
// do 'old' in the body
340340
if(
341-
!contract.assigns().empty() || !contract.requires().empty() ||
341+
!contract.assigns().empty() || !contract.c_requires().empty() ||
342342
!contract.ensures().empty())
343343
{
344344
for(auto &instruction : body.instructions)
@@ -359,7 +359,7 @@ void instrument_contract_checks(
359359

360360
// assigns?
361361
if(
362-
!contract.assigns().empty() || !contract.requires().empty() ||
362+
!contract.assigns().empty() || !contract.c_requires().empty() ||
363363
!contract.ensures().empty())
364364
{
365365
for(auto it = body.instructions.begin(); it != body.instructions.end();
@@ -449,7 +449,7 @@ void replace_function_calls_by_contracts(
449449
goto_programt dest;
450450

451451
// assert the preconditions
452-
for(auto &precondition : contract.requires())
452+
for(auto &precondition : contract.c_requires())
453453
{
454454
auto instantiated_precondition =
455455
instantiate_contract_lambda(precondition);

src/goto-instrument/contracts/contracts.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ void code_contractst::apply_function_contract(
673673
is_fresh.add_memory_map_decl(new_program);
674674

675675
// Generate: assert(requires)
676-
for(const auto &clause : type.requires())
676+
for(const auto &clause : type.c_requires())
677677
{
678678
auto instantiated_clause =
679679
to_lambda_expr(clause).application(instantiation_values);
@@ -689,8 +689,8 @@ void code_contractst::apply_function_contract(
689689
converter,
690690
instantiated_clause,
691691
mode,
692-
[&is_fresh](goto_programt &requires) {
693-
is_fresh.update_requires(requires);
692+
[&is_fresh](goto_programt &c_requires) {
693+
is_fresh.update_requires(c_requires);
694694
},
695695
new_program,
696696
_location);
@@ -1307,7 +1307,7 @@ void code_contractst::add_contract_check(
13071307
visitor.add_memory_map_decl(check);
13081308

13091309
// Generate: assume(requires)
1310-
for(const auto &clause : code_type.requires())
1310+
for(const auto &clause : code_type.c_requires())
13111311
{
13121312
auto instantiated_clause =
13131313
to_lambda_expr(clause).application(instantiation_values);
@@ -1326,8 +1326,8 @@ void code_contractst::add_contract_check(
13261326
converter,
13271327
instantiated_clause,
13281328
function_symbol.mode,
1329-
[&visitor](goto_programt &requires) {
1330-
visitor.update_requires(requires);
1329+
[&visitor](goto_programt &c_requires) {
1330+
visitor.update_requires(c_requires);
13311331
},
13321332
check,
13331333
_location);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ void dfcc_wrapper_programt::encode_requires_clauses()
577577
goto_programt requires_program;
578578

579579
// translate each requires clause
580-
for(const auto &r : contract_code_type.requires())
580+
for(const auto &r : contract_code_type.c_requires())
581581
{
582582
exprt requires = to_lambda_expr(r).application(contract_lambda_parameters);
583583
requires.add_source_location() = r.source_location();

src/goto-programs/goto_functions.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ class goto_functionst
6767
}
6868

6969
/// Remove function from the function map
70-
void unload(const irep_idt &name) { function_map.erase(name); }
70+
void unload(const irep_idt &name)
71+
{
72+
function_map.erase(name);
73+
}
7174

7275
void clear()
7376
{

src/goto-programs/goto_model.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ class goto_modelt : public abstract_goto_modelt
6666
return *this;
6767
}
6868

69-
void unload(const irep_idt &name) { goto_functions.unload(name); }
69+
void unload(const irep_idt &name)
70+
{
71+
goto_functions.unload(name);
72+
}
7073

7174
// Implement the abstract goto model interface:
7275

src/linking/remove_internal_symbols.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static void get_symbols(
7171
find_type_and_expr_symbols(a, new_symbols);
7272
for(const exprt &e : maybe_contract.ensures())
7373
find_type_and_expr_symbols(e, new_symbols);
74-
for(const exprt &r : maybe_contract.requires())
74+
for(const exprt &r : maybe_contract.c_requires())
7575
find_type_and_expr_symbols(r, new_symbols);
7676

7777
for(const auto &s : new_symbols)

src/util/c_types.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class code_with_contract_typet : public code_typet
390390

391391
bool has_contract() const
392392
{
393-
return !ensures().empty() || !requires().empty() || !assigns().empty() ||
393+
return !ensures().empty() || !c_requires().empty() || !assigns().empty() ||
394394
!frees().empty();
395395
}
396396

@@ -414,12 +414,12 @@ class code_with_contract_typet : public code_typet
414414
return static_cast<exprt &>(add(ID_C_spec_frees)).operands();
415415
}
416416

417-
const exprt::operandst &requires() const
417+
const exprt::operandst &c_requires() const
418418
{
419419
return static_cast<const exprt &>(find(ID_C_spec_requires)).operands();
420420
}
421421

422-
exprt::operandst &requires()
422+
exprt::operandst &c_requires()
423423
{
424424
return static_cast<exprt &>(add(ID_C_spec_requires)).operands();
425425
}

0 commit comments

Comments
 (0)