Skip to content

Remove unused class_identifier parameter from Java object factory #4506

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
22 changes: 3 additions & 19 deletions jbmc/src/java_bytecode/java_object_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ class java_object_factoryt
code_blockt &assignments,
const exprt &expr,
bool is_sub,
irep_idt class_identifier,
bool skip_classid,
lifetimet lifetime,
const optionalt<typet> &override_type,
Expand All @@ -132,7 +131,6 @@ class java_object_factoryt
code_blockt &assignments,
const exprt &expr,
bool is_sub,
irep_idt class_identifier,
bool skip_classid,
lifetimet lifetime,
const struct_typet &struct_type,
Expand Down Expand Up @@ -262,7 +260,6 @@ void java_object_factoryt::gen_pointer_target_init(
assignments,
init_expr,
false, // is_sub
"", // class_identifier
false, // skip_classid
lifetime,
{}, // no override type
Expand Down Expand Up @@ -706,7 +703,6 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
assignments,
new_symbol_expr,
false, // is_sub
"", // class_identifier
false, // skip_classid
lifetime,
{}, // no override_type
Expand Down Expand Up @@ -754,8 +750,6 @@ alternate_casest get_string_input_values_code(
/// \param expr: Struct-typed lvalue expression to initialize
/// \param is_sub: If true, `expr` is a substructure of a larger object, which
/// in Java necessarily means a base class
/// \param class_identifier: Name of the parent class. Used to initialize the
/// `@class_identifier` among others
/// \param skip_classid: If true, skip initializing `@class_identifier`
/// \param lifetime: Lifetime of the allocated objects (AUTOMATIC_LOCAL,
/// STATIC_GLOBAL, or DYNAMIC)
Expand All @@ -771,7 +765,6 @@ void java_object_factoryt::gen_nondet_struct_init(
code_blockt &assignments,
const exprt &expr,
bool is_sub,
irep_idt class_identifier,
bool skip_classid,
lifetimet lifetime,
const struct_typet &struct_type,
Expand Down Expand Up @@ -833,10 +826,10 @@ void java_object_factoryt::gen_nondet_struct_init(
// This code mirrors the `remove_java_new` pass:
auto initial_object = zero_initializer(expr.type(), source_locationt(), ns);
CHECK_RETURN(initial_object.has_value());
class_identifier = struct_tag;
const irep_idt qualified_clsid = "java::" + id2string(class_identifier);
set_class_identifier(
to_struct_expr(*initial_object), ns, struct_tag_typet(qualified_clsid));
to_struct_expr(*initial_object),
ns,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 set_class_identifier doesn't actually use ns. So this parameter could probably be removed, however that is probably a change for another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has a call to ns.follow. I still find it a bit strange that follow is defined only for namespaces and not for symbol tables, but that would definitely be a change for another (much bigger) PR. 🙂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, my mistake.

struct_tag_typet("java::" + id2string(struct_tag)));

// If the initialised type is a special-cased String type (one with length
// and data fields introduced by string-library preprocessing), initialise
Expand Down Expand Up @@ -903,7 +896,6 @@ void java_object_factoryt::gen_nondet_struct_init(
assignments,
me,
_is_sub,
class_identifier,
false, // skip_classid
lifetime,
{}, // no override_type
Expand Down Expand Up @@ -938,9 +930,6 @@ void java_object_factoryt::gen_nondet_struct_init(
/// \param is_sub:
/// If true, `expr` is a substructure of a larger object, which in Java
/// necessarily means a base class.
/// \param class_identifier:
/// Name of the parent class. Used to initialize the `@class_identifier` among
/// others.
/// \param skip_classid:
/// If true, skip initializing `@class_identifier`.
/// \param lifetime:
Expand All @@ -965,7 +954,6 @@ void java_object_factoryt::gen_nondet_init(
code_blockt &assignments,
const exprt &expr,
bool is_sub,
irep_idt class_identifier,
bool skip_classid,
lifetimet lifetime,
const optionalt<typet> &override_type,
Expand Down Expand Up @@ -1022,7 +1010,6 @@ void java_object_factoryt::gen_nondet_init(
assignments,
expr,
is_sub,
class_identifier,
skip_classid,
lifetime,
struct_type,
Expand Down Expand Up @@ -1245,7 +1232,6 @@ void java_object_factoryt::array_loop_init_code(
assignments,
arraycellref,
false, // is_sub
irep_idt(), // class_identifier
false, // skip_classid
// These are variable in number, so use dynamic allocator:
lifetimet::DYNAMIC,
Expand Down Expand Up @@ -1464,7 +1450,6 @@ exprt object_factory(
assignments,
object,
false, // is_sub
"", // class_identifier
false, // skip_classid
lifetime,
{}, // no override_type
Expand Down Expand Up @@ -1535,7 +1520,6 @@ void gen_nondet_init(
assignments,
expr,
false, // is_sub
"", // class_identifier
skip_classid,
lifetime,
{}, // no override_type
Expand Down