Skip to content

Make struct_union_typet::component_type return a const reference #2987

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 1 commit into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
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
11 changes: 7 additions & 4 deletions jbmc/src/java_bytecode/java_string_library_preprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,14 @@ java_string_library_preprocesst::process_equals_function_operands(
/// \param type: a type containing a "data" component
/// \param symbol_table: symbol table
/// \return type of the "data" component
static typet get_data_type(const typet &type, const symbol_tablet &symbol_table)
static const typet &
get_data_type(const typet &type, const symbol_tablet &symbol_table)
{
PRECONDITION(type.id() == ID_struct || type.id() == ID_symbol_type);
if(type.id() == ID_symbol_type)
{
symbolt sym=*symbol_table.lookup(to_symbol_type(type).get_identifier());
const symbolt &sym =
symbol_table.lookup_ref(to_symbol_type(type).get_identifier());
CHECK_RETURN(sym.type.id() != ID_symbol_type);
return get_data_type(sym.type, symbol_table);
}
Expand All @@ -410,13 +412,14 @@ static typet get_data_type(const typet &type, const symbol_tablet &symbol_table)
/// \param type: a type containing a "length" component
/// \param symbol_table: symbol table
/// \return type of the "length" component
static typet
static const typet &
get_length_type(const typet &type, const symbol_tablet &symbol_table)
{
PRECONDITION(type.id() == ID_struct || type.id() == ID_symbol_type);
if(type.id() == ID_symbol_type)
{
symbolt sym=*symbol_table.lookup(to_symbol_type(type).get_identifier());
const symbolt &sym =
symbol_table.lookup_ref(to_symbol_type(type).get_identifier());
CHECK_RETURN(sym.type.id() != ID_symbol_type);
return get_length_type(sym.type, symbol_table);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pointer-analysis/value_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ exprt value_sett::make_member(
}

// give up
typet subtype=struct_union_type.component_type(component_name);
const typet &subtype = struct_union_type.component_type(component_name);
member_exprt member_expr(src, component_name, subtype);

return member_expr;
Expand Down
6 changes: 3 additions & 3 deletions src/util/std_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ const struct_union_typet::componentt &struct_union_typet::get_component(
return static_cast<const componentt &>(get_nil_irep());
}

typet struct_union_typet::component_type(
const irep_idt &component_name) const
const typet &
struct_union_typet::component_type(const irep_idt &component_name) const
{
const exprt c=get_component(component_name);
const auto &c = get_component(component_name);
assert(c.is_not_nil());
return c.type();
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/std_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class struct_union_typet:public typet
const irep_idt &component_name) const;

std::size_t component_number(const irep_idt &component_name) const;
typet component_type(const irep_idt &component_name) const;
const typet &component_type(const irep_idt &component_name) const;

irep_idt get_tag() const { return get(ID_tag); }
void set_tag(const irep_idt &tag) { set(ID_tag, tag); }
Expand Down