Skip to content

Commit 6ca79bf

Browse files
authored
Merge pull request #6729 from feliperodri/remove-unused-function-from-contracts-module
CONTRACTS: Remove helper method check_for_looped_mallocs
2 parents 3f7f5ae + 56f317a commit 6ca79bf

File tree

2 files changed

+0
-67
lines changed

2 files changed

+0
-67
lines changed

src/goto-instrument/contracts/contracts.cpp

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,69 +1225,6 @@ goto_functionst &code_contractst::get_goto_functions()
12251225
return goto_functions;
12261226
}
12271227

1228-
bool code_contractst::check_for_looped_mallocs(const goto_programt &program)
1229-
{
1230-
// Collect all GOTOs and mallocs
1231-
std::vector<goto_programt::instructiont> back_gotos;
1232-
std::vector<goto_programt::instructiont> malloc_calls;
1233-
1234-
int index = 0;
1235-
for(goto_programt::instructiont instruction : program.instructions)
1236-
{
1237-
if(instruction.is_backwards_goto())
1238-
{
1239-
back_gotos.push_back(instruction);
1240-
}
1241-
if(instruction.is_function_call())
1242-
{
1243-
irep_idt called_name;
1244-
if(instruction.call_function().id() == ID_dereference)
1245-
{
1246-
called_name =
1247-
to_symbol_expr(
1248-
to_dereference_expr(instruction.call_function()).pointer())
1249-
.get_identifier();
1250-
}
1251-
else
1252-
{
1253-
called_name =
1254-
to_symbol_expr(instruction.call_function()).get_identifier();
1255-
}
1256-
1257-
if(called_name == "malloc")
1258-
{
1259-
malloc_calls.push_back(instruction);
1260-
}
1261-
}
1262-
index++;
1263-
}
1264-
// Make sure there are no gotos that go back such that a malloc
1265-
// is between the goto and its destination (possible loop).
1266-
for(auto goto_entry : back_gotos)
1267-
{
1268-
for(const auto &target : goto_entry.targets)
1269-
{
1270-
for(auto malloc_entry : malloc_calls)
1271-
{
1272-
if(
1273-
malloc_entry.location_number >= target->location_number &&
1274-
malloc_entry.location_number < goto_entry.location_number)
1275-
{
1276-
log.error() << "Call to malloc at location "
1277-
<< malloc_entry.location_number << " falls between goto "
1278-
<< "source location " << goto_entry.location_number
1279-
<< " and it's destination at location "
1280-
<< target->location_number << ". "
1281-
<< "Unable to complete instrumentation, as this malloc "
1282-
<< "may be in a loop." << messaget::eom;
1283-
throw 0;
1284-
}
1285-
}
1286-
}
1287-
}
1288-
return false;
1289-
}
1290-
12911228
bool code_contractst::check_frame_conditions_function(const irep_idt &function)
12921229
{
12931230
// Get the function object before instrumentation.

src/goto-instrument/contracts/contracts.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ class code_contractst
130130
/// Instrument functions to check frame conditions.
131131
bool check_frame_conditions_function(const irep_idt &function);
132132

133-
/// Check if there are any malloc statements which may be repeated because of
134-
/// a goto statement that jumps back.
135-
bool check_for_looped_mallocs(const goto_programt &program);
136-
137133
/// Apply loop contracts, whenever available, to all loops in `function`.
138134
/// Loop invariants, loop variants, and loop assigns clauses.
139135
void apply_loop_contract(

0 commit comments

Comments
 (0)