Skip to content

Commit fd32f9b

Browse files
committed
Resolve inherited component: support filtering by a user-specified condition
1 parent c608235 commit fd32f9b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/goto-programs/resolve_inherited_component.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ resolve_inherited_componentt::resolve_inherited_componentt(
2727
/// class specifier)
2828
/// \param include_interfaces: If true, consider inheritance from interfaces
2929
/// (parent types other than the first listed)
30+
/// \param user_filter: Predicate that should return true for symbols that can
31+
/// be returned. Those for which it returns false will be ignored.
3032
/// \return The concrete component that has been resolved
3133
optionalt<resolve_inherited_componentt::inherited_componentt>
3234
resolve_inherited_componentt::operator()(
3335
const irep_idt &class_id,
3436
const irep_idt &component_name,
35-
bool include_interfaces)
37+
bool include_interfaces,
38+
const std::function<bool(const symbolt &)> user_filter)
3639
{
3740
PRECONDITION(!class_id.empty());
3841
PRECONDITION(!component_name.empty());
@@ -47,7 +50,8 @@ resolve_inherited_componentt::operator()(
4750
const irep_idt &full_component_identifier=
4851
build_full_component_identifier(current_class, component_name);
4952

50-
if(symbol_table.has_symbol(full_component_identifier))
53+
const symbolt *symbol = symbol_table.lookup(full_component_identifier);
54+
if(symbol && user_filter(*symbol))
5155
{
5256
return inherited_componentt(current_class, component_name);
5357
}

src/goto-programs/resolve_inherited_component.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ class resolve_inherited_componentt
4747
optionalt<inherited_componentt> operator()(
4848
const irep_idt &class_id,
4949
const irep_idt &component_name,
50-
bool include_interfaces);
50+
bool include_interfaces,
51+
std::function<bool(const symbolt &)> user_filter = [](const symbolt &) {
52+
return true;
53+
});
5154

5255
static irep_idt build_full_component_identifier(
5356
const irep_idt &class_name, const irep_idt &component_name);

0 commit comments

Comments
 (0)