Skip to content

Adds support for function calls within contracts #5893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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