Skip to content

Commit

Permalink
Merge pull request diffblue#5893 from feliperodri/support-function-in…
Browse files Browse the repository at this point in the history
…-contracts

Adds support for function calls within contracts
  • Loading branch information
feliperodri authored Mar 10, 2021
2 parents b2c7ab0 + beb1353 commit b0b86a2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/linking/remove_internal_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,30 @@ static void get_symbols(
if(!ns.lookup(p.get_identifier(), s))
working_set.push_back(s);
}

// check for contract definitions
const exprt ensures =
static_cast<const exprt &>(code_type.find(ID_C_spec_ensures));
const exprt requires =
static_cast<const exprt &>(code_type.find(ID_C_spec_requires));

find_symbols_sett new_symbols;
find_type_and_expr_symbols(ensures, new_symbols);
find_type_and_expr_symbols(requires, new_symbols);

for(const auto &s : new_symbols)
{
// keep functions called in contracts within scope.
// should we keep local variables from the contract as well?
const symbolt *new_symbol = nullptr;
if(!ns.lookup(s, new_symbol))
{
if(new_symbol->type.id() == ID_code)
{
working_set.push_back(new_symbol);
}
}
}
}
}
}
Expand Down

0 comments on commit b0b86a2

Please sign in to comment.