Skip to content

Commit 430ab00

Browse files
Remove dead method from recursive initialization
The ::build_array_string_constructor method was originally intended to be used for building C string constructors. Unfortunately as written the condition for calling it was actually impossible to satisfy. This wasn’t noticed so far because similar code is now generated in ::build_dynamic_array_constructor instead. Dead code is a maintenance burden so it’s removed here.
1 parent 31615c6 commit 430ab00

File tree

2 files changed

+1
-38
lines changed

2 files changed

+1
-38
lines changed

src/goto-harness/recursive_initialization.cpp

+1-33
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,7 @@ code_blockt recursive_initializationt::build_constructor_body(
265265
}
266266
if(lhs_name.has_value())
267267
{
268-
if(should_be_treated_as_cstring(*lhs_name) && type == char_type())
269-
return build_array_string_constructor(result_symbol);
270-
else if(should_be_treated_as_array(*lhs_name))
268+
if(should_be_treated_as_array(*lhs_name))
271269
{
272270
CHECK_RETURN(size_symbol.has_value());
273271
return build_dynamic_array_constructor(
@@ -740,36 +738,6 @@ code_blockt recursive_initializationt::build_pointer_constructor(
740738
return body;
741739
}
742740

743-
code_blockt recursive_initializationt::build_array_string_constructor(
744-
const symbol_exprt &result) const
745-
{
746-
PRECONDITION(result.type().id() == ID_pointer);
747-
const typet &type = result.type().subtype();
748-
PRECONDITION(type.id() == ID_array);
749-
PRECONDITION(type.subtype() == char_type());
750-
const array_typet &array_type = to_array_type(type);
751-
const auto array_size =
752-
numeric_cast_v<std::size_t>(to_constant_expr(array_type.size()));
753-
code_blockt body{};
754-
755-
for(std::size_t index = 0; index < array_size - 1; index++)
756-
{
757-
index_exprt index_expr{dereference_exprt{result},
758-
from_integer(index, size_type())};
759-
auto const nondet_char =
760-
get_fresh_local_typed_symexpr("nondet_char", char_type());
761-
body.add(code_declt{nondet_char});
762-
body.add(code_assignt{index_expr, nondet_char});
763-
body.add(code_assumet{
764-
notequal_exprt{index_expr, from_integer(0, array_type.subtype())}});
765-
}
766-
body.add(code_assignt{index_exprt{dereference_exprt{result},
767-
from_integer(array_size - 1, size_type())},
768-
from_integer(0, array_type.subtype())});
769-
770-
return body;
771-
}
772-
773741
code_blockt recursive_initializationt::build_array_constructor(
774742
const exprt &depth,
775743
const symbol_exprt &result)

src/goto-harness/recursive_initialization.h

-5
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,6 @@ class recursive_initializationt
262262
const exprt &size,
263263
const optionalt<irep_idt> &lhs_name);
264264

265-
/// Constructor for strings: as array but the last element is zero.
266-
/// \param result: symbol of the result parameter
267-
/// \return the body of the constructor
268-
code_blockt build_array_string_constructor(const symbol_exprt &result) const;
269-
270265
/// Select the specified struct-member to be non-deterministically
271266
/// initialized.
272267
/// \param lhs: symbol expression of the top structure

0 commit comments

Comments
 (0)