diff --git a/jbmc/src/java_bytecode/java_string_library_preprocess.cpp b/jbmc/src/java_bytecode/java_string_library_preprocess.cpp index d35e8f15bed..7c39fde5d55 100644 --- a/jbmc/src/java_bytecode/java_string_library_preprocess.cpp +++ b/jbmc/src/java_bytecode/java_string_library_preprocess.cpp @@ -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); } @@ -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); } diff --git a/src/pointer-analysis/value_set.cpp b/src/pointer-analysis/value_set.cpp index 45dd493a169..21546b2e0a8 100644 --- a/src/pointer-analysis/value_set.cpp +++ b/src/pointer-analysis/value_set.cpp @@ -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; diff --git a/src/util/std_types.cpp b/src/util/std_types.cpp index ccd7e76cd2d..fbfd1be1296 100644 --- a/src/util/std_types.cpp +++ b/src/util/std_types.cpp @@ -62,10 +62,10 @@ const struct_union_typet::componentt &struct_union_typet::get_component( return static_cast(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(); } diff --git a/src/util/std_types.h b/src/util/std_types.h index 487fde2e51b..8dae717930b 100644 --- a/src/util/std_types.h +++ b/src/util/std_types.h @@ -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); }