Skip to content

Commit 813efa3

Browse files
author
Daniel Kroening
committed
strengthen type of parameter of gather_field_types
The first parameter of ci_lazy_methods_neededt::gather_field_types is always a struct_tag_typet. This is now reflected in the signature.
1 parent e1e2009 commit 813efa3

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

jbmc/src/java_bytecode/ci_lazy_methods_needed.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void ci_lazy_methods_neededt::initialize_instantiated_classes_from_pointer(
105105
// explore again even if we've seen this classid before in the array case.
106106
if(add_needed_class(param_classid) || is_java_array_tag(param_classid))
107107
{
108-
gather_field_types(pointer_type.subtype(), ns);
108+
gather_field_types(class_type, ns);
109109
}
110110

111111
if(is_java_generic_type(pointer_type))
@@ -126,31 +126,26 @@ void ci_lazy_methods_neededt::initialize_instantiated_classes_from_pointer(
126126
/// \param class_type: root of class tree to search
127127
/// \param ns: global namespaces.
128128
void ci_lazy_methods_neededt::gather_field_types(
129-
const typet &class_type,
129+
const struct_tag_typet &class_type,
130130
const namespacet &ns)
131131
{
132-
const auto &underlying_type = to_struct_type(ns.follow(class_type));
132+
const auto &underlying_type = ns.follow_tag(class_type);
133+
133134
if(is_java_array_tag(underlying_type.get_tag()))
134135
{
135-
// If class_type is not a symbol this may be a reference array,
136-
// but we can't tell what type.
137-
if(class_type.id() == ID_struct_tag)
136+
const typet &element_type = java_array_element_type(class_type);
137+
if(element_type.id() == ID_pointer)
138138
{
139-
const typet &element_type =
140-
java_array_element_type(to_struct_tag_type(class_type));
141-
if(element_type.id() == ID_pointer)
142-
{
143-
// This is a reference array -- mark its element type available.
144-
add_all_needed_classes(to_pointer_type(element_type));
145-
}
139+
// This is a reference array -- mark its element type available.
140+
add_all_needed_classes(to_pointer_type(element_type));
146141
}
147142
}
148143
else
149144
{
150145
for(const auto &field : underlying_type.components())
151146
{
152-
if(field.type().id() == ID_struct || field.type().id() == ID_struct_tag)
153-
gather_field_types(field.type(), ns);
147+
if(field.type().id() == ID_struct_tag)
148+
gather_field_types(to_struct_tag_type(field.type()), ns);
154149
else if(field.type().id() == ID_pointer)
155150
{
156151
if(field.type().subtype().id() == ID_struct_tag)

jbmc/src/java_bytecode/ci_lazy_methods_needed.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class ci_lazy_methods_neededt
6262
const pointer_typet &pointer_type,
6363
const namespacet &ns);
6464

65-
void gather_field_types(const typet &class_type, const namespacet &ns);
65+
void
66+
gather_field_types(const struct_tag_typet &class_type, const namespacet &ns);
6667
};
6768

6869
#endif

0 commit comments

Comments
 (0)